opsoro.sound

This module defines the interface for communicating with the sound module.

class opsoro.sound._Sound[source]

Bases: object

__init__()[source]

Sound class, used to play sound and speak text.

get_file(filename, tts=False)[source]

Returns audio file data according to the given filename.

Parameters:filename (string) – file to return the data from
Returns:Soundfile data.
Return type:var
play_file(filename)[source]

Plays an audio file according to the given filename.

Parameters:filename (string) – file to play
Returns:True if sound is playing.
Return type:bool
say_tts(text, generate_only=False)[source]

Converts a string to a soundfile using Text-to-Speech libraries

Parameters:
  • text (string) – text to convert to speech
  • generate_only (bool) – do not play the soundfile once it is created
stop_sound()[source]

Stop the played sound.

wait_for_sound()[source]

Wait until the played sound is done.

opsoro.sound.tts

This module defines the interface for communicating with the TTS libraries.

class opsoro.sound.tts._TTS[source]

Bases: object

__init__()[source]

TTS class, used to convert text to speech.

create(text)[source]

Takes a string of text, converts it using the PicoTTS engine, and plays it. Wave files are buffered in /tmp/OnoTTS/<text>.wav. First call blocks while PicoTTS generates the .wav, this may take about a second. Subsequent calls of the same text return immediately. If you wish to avoid this, sound files can be generated on beforehand by using generate_only=True.

Parameters:text (string) – text to convert to speech
Returns:path to the sound file
Return type:string
create_espeak(text, file_path, language, gender, delay, speed)[source]

Convert text to speech using the espeak TTS library.

Parameters:
  • text (string) – text to convert to speech
  • file_path (string) – file path to store the speech soundfile
  • language (string) – language initials
  • gender (string) – specify gender (m for male, f for female)
  • delay (int) – delay between words in ms
  • speed (int) – speed in words-per-minute
create_pico(text, file_path)[source]

Convert text to speech using the pico2wave TTS library.

Parameters:
  • text (string) – text to convert to speech
  • file_path (string) – file path to store the speech soundfile