Spokestack¶
This module contains the Spokestack client for text to speech
-
exception
spokestack.tts.clients.spokestack.
TTSError
(response)[source]¶ Bases:
Exception
Text to speech error wrapper
-
class
spokestack.tts.clients.spokestack.
TextToSpeechClient
(key_id, key_secret, url='https://api.spokestack.io/v1')[source]¶ Bases:
object
Spokestack Text to Speech Client
- Parameters
key_id (str) – identity from spokestack api credentials
key_secret (str) – secret key from spokestack api credentials
url (str) – spokestack api url
-
synthesize
(utterance, mode='text', voice='demo-male', profile='default')[source]¶ Converts the given utterance to speech.
Text can be formatted as plain text (mode=”text”), SSML (mode=”ssml”), or Speech Markdown (mode=”markdown”).
This method also supports different formats for the synthesized audio via the profile argument. The supported profiles and their associated formats are:
default: 24kHz, 64kbps mono MP3
alexa: 24kHz, 48kbps mono MP3
discord: 48kHz, 64kbpz stereo OPUS
twilio: 8kHz, 64kbpz mono MP3
- Parameters
utterance (str) – string that needs to be rendered as speech.
mode (str) – synthesis mode to use with utterance. text, ssml, markdown.
voice (str) – name of the tts voice.
profile (str) – name of the audio profile used to create the resulting stream.
- Returns
Encoded audio response in the form of a sequence of bytes
- Return type
(Iterator[bytes])
-
synthesize_url
(utterance, mode='text', voice='demo-male', profile='default')[source]¶ Converts the given utterance to speech accessible by a URL.
Text can be formatted as plain text (mode=”text”), SSML (mode=”ssml”), or Speech Markdown (mode=”markdown”).
This method also supports different formats for the synthesized audio via the profile argument. The supported profiles and their associated formats are:
default: 24kHz, 64kbps mono MP3
alexa: 24kHz, 48kbps mono MP3
discord: 48kHz, 64kbpz stereo OPUS
twilio: 8kHz, 64kbpz mono MP3
- Parameters
utterance (str) – string that needs to be rendered as speech.
mode (str) – synthesis mode to use with utterance. text, ssml, markdown.
voice (str) – name of the tts voice.
profile (str) – name of the audio profile used to create the resulting stream.
Returns: URL of the audio clip
- Return type
str