Websocket Client icon Websocket Client — WebSocket client for ARC: open/send messages, store server responses in a variable, run a response script, and track connection status. Try it →
 

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 JavaScript 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: string. 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: number. 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 number Optional. Which EZB to use, 0 being the first one.

Gives back: boolean. 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 string 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 string 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 number 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 string The note name, C1 to B3, with flats written like Eb2. A2 is 440 Hz.
length number How long to play it, in milliseconds, up to 60000.
signalType number Optional. The wave shape: 0 sine, 1 square, 2 triangle, 3 sawtooth, 4 pulse, 5 white noise, 6 gauss noise, 7 digital noise.
ezbIndex number 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 number How many seconds to wait before giving up.
textPrompt string The text shown as the popup's title.

Gives back: string. 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 number How many seconds to wait before giving up.
phraseArray string Any number of values. The phrases to listen for, each also shown as a button.

Gives back: string. 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 number How many seconds to wait before giving up.
start number The first number offered.
end number The last number offered. It may be below start to count down.
increment number Optional. The step between numbers. Must not be 0, and at most 100 numbers are allowed.

Gives back: string. 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.