Nevermind I found the mistake .D Here's the updated code:
'--- Many thanks to Kirill Kudryavtsev @ kin0shkin from
https://sbtg.ru/ for the script!
'--- Begin Script
dim translateInput as string = "Source" 'Input name with Translator
dim origInput as string = "Duck" 'Input name with Original audio track
dim volumeStandart as string = "100" 'Volume Orig. input when the Translator is silent
dim fadeTimeStandart as string = "1200" 'Duration increase the volume Orig. when the Translator is silent
dim volumeSpeaking as string = "60" 'Volume of the Original input when the Translator speaks
dim fadeTimeSpeaking as string = "200" 'Duration fading Orig. when the Translator speaks
dim voicethreshold as string = "0.02" 'Response threshold to the interpreter's signal, from 0 to 1 (logical scale)
'Corresponds to the values (not the length) on the volume slider: 0.5 = 50% ~ = -6dB, 0.1 = 10% ~ = -20dB ...
'Response may not work with a single pulse signal, but works well with a signal such as voice or music
dim checkingIter as integer = 2 'Number of iterations to check for translator silence before firing
dim checkingIterTime as integer = 200 'Interval (milliseconds) between check iterations (recommended from 100, default 200)
'So it lasts. verifying that the translation is silent and you can turn on Orig. = checkingIter * checkingIterTime (milliseconds)
'---- End of settings ----
dim voicemeter as string = ""
dim speaking as boolean = false
dim silence as boolean = false
dim silencechecking as integer = 0
dim muted as boolean = false
do while true
dim xml as string = API.XML()
dim x as new system.xml.xmldocument
x.loadxml(xml)
voicemeter = (x.SelectSingleNode("//input[@title='"& translateInput &"']/@meterF1").Value)
if (x.SelectSingleNode("//input[@title='"& translateInput &"']/@meterF2").Value) > voicemeter
voicemeter = (x.SelectSingleNode("//input[@title='"& translateInput &"']/@meterF2").Value)
end if
Console.WriteLine(voicemeter)
muted = (x.SelectSingleNode("//input[@title='"& translateInput &"']/@muted").Value)
'API.Function("SetText",Input:="TextInput",SelectedName:="Timer.Text" ,Value:=voicemeter)
'console.writeline(voicemeter)
if voicemeter > voicethreshold And voicemeter.IndexOfAny("[E]".ToCharArray) = -1 And Not muted
if silencechecking >= checkingIter '<> 0 '!=
'console.writeline("Speaking")
silencechecking = 0
'API.Function("SetTextColour",Input:="TextInput",SelectedName:="Timer.Text",Value:="yellow")
'API.Function("SetText",Input:="TextInput",SelectedName:="Timer.Text" ,Value:="Перевод говорит! " + voicemeter)
Input.Find(origInput).Function("SetVolumeFade", volumeSpeaking + "," + fadeTimeSpeaking)
else 'this has initially been missing so silencechecking could never reach the value of "2" unless the translator input has been silenced or turned down
silencechecking += 1
end if
'console.writeline(silencechecking)
else
if silencechecking < checkingIter
silencechecking += 1
end if
if silencechecking = checkingIter
'console.writeline("Silence")
'API.Function("SetTextColour",Input:="TextInput",SelectedName:="Timer.Text",Value:="white")
'API.Function("SetText",Input:="TextInput",SelectedName:="Timer.Text" ,Value:="Перевод молчит! " + voicemeter)
Input.Find(origInput).Function("SetVolumeFade", volumeStandart + "," + fadeTimeStandart)
silencechecking = checkingIter + 1
end if
'console.writeline(silencechecking)
end if
sleep(checkingIterTime)
Loop
'--- End Script