Audio
Make the robot speak and play sounds, set the volume, and wait for the person to say one of a list of phrases. Speech and sound come out of whichever speaker the project plays audio through, the computer or an EZB, which is chosen on the EZB Connection robot skill. Speech uses the project's text to speech robot skill, and listening uses its speech to text robot skill.
Where to find it: type Audio. in a Python script, or open the ARCx API view of the script editor and expand Audio
Commands
| Command | What it does |
|---|---|
| Audio.GetOutput | Where speech and audio will be heard, for a script that wants to log or display it. |
| Audio.GetVolume | The master output volume as a percentage, where 100 is unchanged. |
| Audio.IsConnected | Whether the first EZB (EZB 0) is connected. |
| Audio.Say | Speak the text and carry on. |
| Audio.SayWait | Speak the text and wait until it has finished being heard before carrying on. |
| Audio.SetVolume | Set the master output volume as a percentage, 0 to 200, where 100 is unchanged. |
| Audio.SoundNote | Plays a musical note out of the first EZB's (EZB 0) speaker and carries on without waiting, using the last wave shape set (a sine wave by default). |
| Audio.Stop | Stop everything ARCx is playing, wherever it is playing. |
| Audio.WaitForAnySpeech | Shows a popup and waits until anything at all is spoken, using the project's speech to text robot skill. |
| Audio.WaitForSpeech | Shows a popup with a button for each phrase and waits until one is spoken (through the project's speech to text robot skill) or clicked. |
| Audio.WaitForSpeechRange | Shows a popup with a button for each whole number from start to end and waits until one is spoken or clicked. |
Details
Audio.GetOutput
Where speech and audio will be heard, for a script that wants to log or display it.
Audio.GetOutput()
Gives back: str. A description of the speaker in use, such as "PC speaker" or "EZB 0 speaker".
Audio.GetVolume
The master output volume as a percentage, where 100 is unchanged.
Audio.GetVolume()
Gives back: float. The master output volume, 0 to 200.
Audio.IsConnected
Whether the first EZB (EZB 0) is connected. Fails with an error if the project has no EZB 0.
Audio.IsConnected()
Audio.IsConnected(ezbIndex)
| Value | Type | What it is |
|---|---|---|
ezbIndex |
int | Optional. Which EZB to use, 0 being the first one. |
Gives back: bool. Whether EZB 0 is connected.
Audio.Say
Speak the text and carry on. It comes out of whichever speaker the project is set to - the computer's or an EZB's - which is configured on the EZB Connection robot skill, and in Options, Preferences for this machine. There is deliberately no say-out-of-the-EZB command: where the robot's voice comes from is a property of the robot, not of every line of script that makes it talk.
Audio.Say(txt)
| Value | Type | What it is |
|---|---|---|
txt |
str | The text to speak. |
Audio.SayWait
Speak the text and wait until it has finished being heard before carrying on.
Audio.SayWait(txt)
| Value | Type | What it is |
|---|---|---|
txt |
str | The text to speak. |
Audio.SetVolume
Set the master output volume as a percentage, 0 to 200, where 100 is unchanged. It applies to everything ARCx plays, at whichever speaker it is playing out of.
Audio.SetVolume(volume)
| Value | Type | What it is |
|---|---|---|
volume |
int | The volume percentage, 0 to 200. Values outside that range are clamped. |
Audio.SoundNote
Plays a musical note out of the first EZB's (EZB 0) speaker and carries on without waiting, using the last wave shape set (a sine wave by default). Silent if the EZB is not connected.
Audio.SoundNote(note, length)
Audio.SoundNote(note, length, signalType)
Audio.SoundNote(note, length, signalType, ezbIndex)
| Value | Type | What it is |
|---|---|---|
note |
str | The note name, C1 to B3, with flats written like Eb2. A2 is 440 Hz. |
length |
int | How long to play it, in milliseconds, up to 60000. |
signalType |
int | Optional. The wave shape: 0 sine, 1 square, 2 triangle, 3 sawtooth, 4 pulse, 5 white noise, 6 gauss noise, 7 digital noise. |
ezbIndex |
int | Optional. Which EZB to use, 0 being the first one. |
Audio.Stop
Stop everything ARCx is playing, wherever it is playing.
Audio.Stop()
Audio.WaitForAnySpeech
Shows a popup and waits until anything at all is spoken, using the project's speech to text robot skill. Fails with an error if no web browser is connected to show the popup.
Audio.WaitForAnySpeech(timeoutSeconds, textPrompt)
| Value | Type | What it is |
|---|---|---|
timeoutSeconds |
int | How many seconds to wait before giving up. |
textPrompt |
str | The text shown as the popup's title. |
Gives back: str. The words heard, "timeout" when time ran out, "canceled" when cancelled or the script was stopped, or an empty string if recognition failed.
Audio.WaitForSpeech
Shows a popup with a button for each phrase and waits until one is spoken (through the project's speech to text robot skill) or clicked. Fails with an error if no phrases are given or no web browser is connected to show the popup.
Audio.WaitForSpeech(timeoutSeconds, *phraseArray)
| Value | Type | What it is |
|---|---|---|
timeoutSeconds |
int | How many seconds to wait before giving up. |
phraseArray |
str | Any number of values. The phrases to listen for, each also shown as a button. |
Gives back: str. The phrase heard or clicked, "timeout" when time ran out, "canceled" when cancelled or the script was stopped, or an empty string if recognition failed.
Audio.WaitForSpeechRange
Shows a popup with a button for each whole number from start to end and waits until one is spoken or clicked. Fails with an error if no web browser is connected.
Audio.WaitForSpeechRange(timeoutSeconds, start, end)
Audio.WaitForSpeechRange(timeoutSeconds, start, end, increment)
| Value | Type | What it is |
|---|---|---|
timeoutSeconds |
int | How many seconds to wait before giving up. |
start |
int | The first number offered. |
end |
int | The last number offered. It may be below start to count down. |
increment |
int | Optional. The step between numbers. Must not be 0, and at most 100 numbers are allowed. |
Gives back: str. The number heard or clicked as text, "timeout" when time ran out, "canceled" when cancelled or the script was stopped, or an empty string if recognition failed.