Playable Media

This is a wrapper class for TTS strings and file names.

class PlayableMedia

A class that specifies some text to say using TTS, or the name of a file to play. It also supplies functions to help configure the TTS engine and voice to use when speaking TTS. This class is used by some of the functions supplied by the high level UAS API library.

To use this class it must first be imported:

from prosody.uas import PlayableMedia

Usage example:

from prosody.uas import Hangup, Error, PlayableMedia

def main(channel, application_instance_id, file_man, my_log, application_parameters):
    media = PlayableMedia(text_to_say='Good morning.', channel=channel)
Optional argument:
  • file_to_play

    the name of a file to play.

  • digits_to_play

    a digit string to play as DTMF tones.

  • text_to_say

    a string of text to say using TTS.

  • tts_engine

    the name of the TTS engine to use when speaking.

  • tts_voice

    the name of the TTS voice to use when speaking.

  • barge_in

    a barge-in flag

  • channel

    the call channel; although this is optional, it is recommended to pass it in

  • cipher

    for encryption or decryption, supply the cipher here.

  • text_is_private

    the TTS text should be treated as private.

digits_to_play(digits_to_play)

Set a digit string to play.

Setting this option will replace any options that may have been previously set by text_to_say or file_to_play.

file_to_play(filename, cipher=None)

Set a file name to play.

Setting this option will replace any options that may have been previously set by text_to_say or digits_to_play.

For encryption or decryption, supply the cipher here.

get_file_to_play()

Get the name of the file to play.

get_log_safe_text_to_say()

Get the text to say in a log safe format.

Also, add the TTS engine and voice to the string, if required.

get_text_to_say()

Get the text to say.

Also, add the TTS engine and voice to the string, if required.

is_file()

Return True if a file name has been set.

is_text()

Return True if some text to say has been set.

set_text_is_private(text_is_private)

Set whether the TTS text is private. If it is private this will be added to the TTS string.

set_tts_engine_and_voice(engine, voice)

Set a TTS engine and voice. These will be added to the TTS string.

text_to_say(text_to_say)

Set some text to say using TTS.

Setting this option will replace any options that may have been previously set by file_to_play or digits_to_play.

This function will also check the XML formatting of the text string and it will raise an Error exception if any errors are detected.