Expand description
Sound-related functions. It can beep, play wav files, or convert text to speech.
Note that all methods of the module spawn system processes and return
std::process::Child
objects. The methods are asynchronous (they return
immediately after child process was spawned, without waiting for its
completion), but you can call wait() on the returned result.
§Examples
use ev3dev_lang_rust::sound;
// Play "bark.wav", return immediately:
sound::play("bark.wav")?;
// Introduce yourself, wait for completion:
sound::speak("Hello, I am Robot")?.wait()?;
Functions§
- beep
- Call beep command.
- beep_
args - Call beep command with the provided arguments.
- get_
volume - Gets the current sound volume by parsing the output of
amixer get <channel>
. It tries to determine the default channel by runningamixer scontrols
. If that fails as well, it uses thePlayback
channel, as that is the only channel on the EV3. - get_
volume_ channel - Gets the current sound volume by parsing the output of
amixer get <channel>
. - play
- Play wav file
- set_
volume - Sets the sound volume to the given percentage [0-100] by calling
amixer -q set <channel> <pct>%
. It tries to determine the default channel by runningamixer scontrols
. If that fails as well, it uses thePlayback
channel, as that is the only channel on the EV3. - set_
volume_ channel - Sets the sound volume to the given percentage [0-100] by calling
amixer -q set <channel> <pct>%
. - speak
- Speak the given text aloud.
- tone
- Play tone sequence. The tone_sequence parameter is a list of tuples, where each tuple contains up to three numbers. The first number is frequency in Hz, the second is duration in milliseconds, and the third is delay in milliseconds between this and the next tone in the sequence.
- tone_
sequence - Play tone sequence. The tone_sequence parameter is a list of tuples, where each tuple contains up to three numbers. The first number is frequency in Hz, the second is duration in milliseconds, and the third is delay in milliseconds between this and the next tone in the sequence.