Control sounds and words which can play from your programming device's speaker or the robot itself (R2-D2 only).
Plays a sound from your programming device. When a sound is played, the true boolean will cause the program to wait until the sound plays completely before continuing to the next command. Change to false to continue to the next command immediately. If you want to use timing different than the wait/continue commands allow, you can follow a true (continue) command with a delay() command so the subsequent logic is delayed for the given duration.
To play a specific sound from a specific category, include the category and the sound name, in this format:
await Sound.Category.SoundName.play()
You can randomize all sounds by not declaring a Category and SoundName, such as await Sound.play(true). If you declare a Category but leave the SoundName blank it will randomize in the given category, such as await Sound.Animal.play(true).
As an example, to play the Chime sound effect from the Effects category without waiting until completion to proceed, use the following:
JavaScript: await Sound.Effects.Chime.play(false);
Python: await Sound.Effects.Chime.play(False)
Parameters:
blocking — whether to wait for the sound to finish before continuing program execution. Defaults to true.
If you would like to preview the available sounds, you can do so by using the sound block in the block canvas.
Uses the text-to-speech engine to speak a given string from the programming device. Supports all languages available with your device's text-to-speech engine.
For example, you can use the speak command to have your program say 'Hello World":
JavaScript: await speak('Hello World', true)
Python: await speak('Hello World', True)
Parameters:
words {string} - The text string to be spoken
blocking {boolean} - A boolean value that controls if the speech finishes before continuing execution (wait = true, continue = false)
String values can be concatenated to make them dynamic. The additional values can be variables, parameters, or sensors, and/or in the form of numbers, strings, booleans, or colors. The wait/continue playback (true/false boolean) is handled the same as the Play Sound function.
For example, to speak the current heading use:
JavaScript: await speak(buildString("The heading is" + Math.round(getHeading())), true)
Python: await speak(build_string(["The heading is" + str(Math.round(get_heading()))]), True)
Plays unique Star Wars Droid Sounds that are available for BB-8, BB-9E and R2-D2. To play a specific sound for a specific Droid from a specific category, include the Droid type, category, and sound name in this format:
Sound.DroidName.Category.SoundName.play()
The Droid names are written as BB8, BB9E, and R2D2. For R2-D2, these sounds are played on the Droid itself. For BB-8 and BB-9E, these sounds are played in the Sphero Edu app.
You can randomize all sounds for a Droid by not declaring a Category and SoundName, such as Sound.R2D2.play(). If you declare a Category but leave the SoundName blank it will randomize in the given category, such as Sound.R2D2.General.play(). To play the R2-D2 Burnout sound use R2D2.Sound.General.Burnout.play().
*R2-Q5 Droid Sounds are not available