The Navigator icon The Navigator Path-planning navigator using ARC NMS position and obstacle data to map, log trajectories, and autonomously follow waypoints. Try it →
Australia
Asked
Resolved Resolved by Athena!
Speech Recognition Mic Variable

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)
EZ-B V4 by EZ-Robot
EZ-B v4/2 robot controller: dual Cortex ARM, Wi-Fi, audio/video, 24 servo/digital ports, I2C/UART, camera and Synthiam ARC control for custom robots
Wi-Fi / USB
Servos 24
Camera
Audio
UART 3
I2C
ADC 8
Digital 24

Related Robot Skills (view all robot skills)
Train camera vision objects via controlcommand(), attach camera, start learning, monitor progress, and return object name for scripts.
Windows Speech Recognition skill: detect custom phrases via PC mic, trigger configurable scripts/actions with adjustable confidence.

ARC Pro

Upgrade to ARC Pro

Become a Synthiam ARC Pro subscriber to unleash the power of easy and powerful robot programming

#9  

Hahaha - that would be a good start! The biggest challenge is that all these great services have turned into paid online subscriptions. None of these services publish their product for free because they need to generate revenue to pay for their employees. We are always keeping our eyes open for open-source products as well. Still, for services involving recognizers and synthesizers, they seem to be limited to large datacenter-style computing, probably because they require so much processing to convert any speech into words.

If you use Total Speech Recognition, make sure you use a very good microphone. Generally, we recommend a headset microphone. Or, one of those microphones that you can wear on your lapel.