Unsolved External process from Qml
-
-
-
@jsulm ya i checked...after checking that code only i used var in the code as shown above...but i didn't get that clearly so posted this in forum.
-
if(receivedString.localeCompare("GOTO MUSIC") == 0) { console.log("play music") } else { console.log("please try again") }
-
@jsulm
i tried with both the codes...its going to else part.onPlaymusicsignal: { console.log("Recorded Voice :" + recordedString) var receivedString = recordedString console.log(receivedString) if(receivedString.localeCompare("GOTO MUSIC") == 0) { console.log("play music") musicScreen.visible= true } else { console.log("please try again") }
onPlaymusicsignal: { console.log("Recorded Voice :" + recordedString) var receivedString = recordedString var GotoMusicString = new String("GOTO MUSIC") console.log(receivedString) if(receivedString.localeCompare(GotoMusicString) == 0) { console.log("play music") musicScreen.visible= true } else { console.log("please try again") } }
-
@Naveen_D Maybe receivedString contains a new line character at the end?
-
@jsulm this is the output i am getting from the started process and the same output i am sending through the signal to qml
output>>>> "\n<<< please speak >>> \n\n \n\n"
output>>>> "Received Command: "GOTO MUSIC"\n"
Output of regular exp is: ""GOTO MUSIC""
signal data is >> ""GOTO MUSIC""qml: Recorded Voice :"GOTO MUSIC"
qml: "GOTO MUSIC"
qml: please try again -
@Naveen_D It look like your string is not "GOTO MUSIC" but ""GOTO MUSIC""
You have " at the beginning and end of the string as part of the string. -
@Naveen_D To remove those " do:
var receivedString = recordedString.slice(1, -1)
-
@jsulm yes that " was the part of that string...i got the output thanks...
one more doubt...is there any other method...because i have lot of commands like GOTO MUSIC for which i need to give functionality. -
@Naveen_D The easiest way would be to fix your process so it does not put the recognized strings inside "".
If this is not possible then you need to change the way you're parsing the output of that process, so your regular exceptions do not match "