Cosgrove
Speech Recognition Mic Variable
,
I'm using the Speech Recognition robot skill in ARC. From a Python script running in that Speech Recognition Skill, I'm attempting to start Object Recognition in the Camera Robot Skill. I converted the EZ-Script code from the "Object recognition" example by DJ Sures to Python. The script executes, but it does not capture the speech text from the user microphone in response to the prompt "What is the name of the Object?"
It seems the Speech Recognition Skill does not expose a variable equivalent to the EZ-Script example's "$BingSpeechPhrase". I have tried using "SpeechPhrase", but that always contains the previously spoken robot voice (TTS), NOT the text captured from the user microphone. Is there a variable I can use to obtain the captured speech text from the Speech Recognition Skill?
Note: I have a bespoke variable named "$CurrentSpeechPhrase" that another script uses to manage the robot voice and jaw animations.
My Python script (converted from EZ-Script) is shown below:
import time
# Ask for the object name
setVar("$CurrentSpeechPhrase", "what is the name of the new object")
setVar("$IsSaying", 1)
while getVar("$IsSaying") == 1:
time.sleep(3.0)
# Reset speech variable and start listening
setVar("$SpeechPhrase", "")
controlCommand("Speech Recognition", "PauseOff")
time.sleep(0.25)
setVar("$SpeechPhrase","?????????") #
# Confirm object name with the user first test
object_name = getVar("$SpeechPhrase") # This does not match the input from the microphone #
setVar("$CurrentSpeechPhrase", "I heard you say " + str(object_name))
setVar("$IsSaying", 1)
while getVar("$IsSaying") == 1:
time.sleep(0.1)
# Wait for Bing Speech to get a response
while getVar("$SpeechPhrase") == "":
time.sleep(0.25)
# Confirm object name with the user
object_name = getVar("$SpeechPhrase")
setVar("$CurrentSpeechPhrase", "Excellent. Let me know when you are ready to teach me what the " + str(object_name) + " is.")
setVar("$IsSaying", 1)
while getVar("$IsSaying") == 1:
time.sleep(0.1)
# Wait for 'OK' or 'Cancel' voice confirmation (Timeout: 60 seconds)
# Note: waitForSpeech is a native ARC global function
resp = Audio.waitForSpeech(60, "OK", "Cancel")
if resp != "OK":
setVar("$CurrentSpeechPhrase", "ok, I will not learn the " + str(object_name))
setVar("$IsSaying", 1)
# Stop script execution
exit()
# Disable current tracking to prepare for training
controlCommand("Camera", "CameraObjectTrackingDisable")
# Train the new object
controlCommand("Train Vision Object By Script", "Learn", str(object_name))
time.sleep(1.0)
# Wait while the camera is actively learning
while getVar("$CameraIsLearning") == True:
time.sleep(0.25)
# Success confirmation
setVar("$CurrentSpeechPhrase", "Great, I know what a " + str(object_name) + " is.")
setVar("$IsSaying", 1)
while getVar("$IsSaying") == 1:
time.sleep(0.1)
# Re-enable regular camera tracking
controlCommand("Camera", "CameraObjectTracking")
Thanks.
Related Hardware (view all EZB hardware)
Related Robot Skills (view all robot skills)
Upgrade to ARC Pro
With Synthiam ARC Pro, you're not just programming a robot; you're shaping the future of automation, one innovative idea at a time.
While new comments are no longer being accepted, the information here remains available for learning and reference. Check the most recent comment for additional details.

Yes - the Speech Recognition skill does not provide a
"$BingSpeechPhrase"-style variable for the recognized user phrase in the way the old Bing speech examples did.What you want is usually the last recognized phrase variable exposed by the Speech Recognition skill itself, which in ARC is typically:
$SpeechPhrase= the last recognized phrase$SpeechConfidence= confidence of the last recognitionHowever, in your case the reason you’re seeing the robot’s TTS text instead of the user’s microphone input is likely because your own custom variable (
$CurrentSpeechPhrase) and/or the speech/jaw logic is updating$SpeechPhraseor your script is reading it at the wrong time.Important distinction
Audio.say.../ TTS is the robot speakingSo if
"$SpeechPhrase"is showing the spoken robot text, then that variable is likely being used by another script as a shared "current phrase" variable, not the Speech Recognition skill’s recognized input.Better approach
Use the Speech Recognition skill’s built-in recognized phrase variable from that control, not your custom phrase variable.
If you’re using the Speech Recognition robot skill, check its settings:
You can point those to unique variable names, for example:
"$RecognizedPhrase""$RecognizedConfidence"That avoids collisions with your TTS/jaw script.
Recommended fix for your project
1) Change the Speech Recognition skill variables
In the Speech Recognition skill settings:
"$RecognizedPhrase""$RecognizedConfidence"2) Read that variable in Python
Then your script should use:
Why your current script is failing
This line is the key issue:
If
"$SpeechPhrase"is already being used by another part of your project, clearing it right before listening can cause conflicts. Also, your jaw/TTS logic is likely writing to a phrase variable that is not the microphone result.Suggested Python pattern
Here’s a cleaner version of the speech capture portion:
If you need to wait for a specific prompt response like OK or Cancel, you can do:
What I’d recommend in ARC
Since you have multiple scripts interacting, the safest setup is:
$CurrentSpeechPhraseonly for robot speech / jaw animation$RecognizedPhraseonly for microphone recognition$RecognizedConfidenceonly for confidence filteringThat separation will prevent the two systems from stepping on each other.
Useful links
Speech Recognition skill:
https://synthiam.com/Support/Skills/Audio/Speech-Recognition?id=16118
Configuring robot skills:
https://synthiam.com/Support/ARC-Overview/robot-skills/configuring-robot-skills
ControlCommand documentation:
https://synthiam.com/Support/Programming/control-command
If you want, I can help you rewrite your whole script into clean ARC Python so it:
@Athena, thanks, yes a rewrite will save me time. Thanks. I did not know that there was a variable =
$RecognizedPhraseOne question: Can I still use $SpeechPhrase in other scripts or do I now have to change all other uses to $RecognisedPhrase as that would seem to just transfer the clash of variables to $RecognisedPhrase. Thanks again