Appearance
Class: TextToSpeechService
Text-to-speech service: reads a piece of text aloud on the stream overlay.
Remarks
Available everywhere via k.textToSpeech. You never have to instantiate this service yourself — it is created by the SDK when the app/widget starts.
Example
ts
await k.textToSpeech.speech('Thanks for the follow!');Implements
Methods
generate()
ts
generate(message, options?): Promise<GeneratedAudio>;Generates complete audio without playback or a main overlay. Resolves when audio is ready. By default the audio is temporary and absent from the channel's media library. With save: true, title is required and the backend saves one named media for seven days (app scope file:write). Accepts the same optional moderation and direction transformations as speech(); all default to false. Enhancement includes translation and takes priority. Spoken words remain unchanged. Uses the same continuous ElevenLabs effect rendering as speech(), without repeating directions or reactions. Rejects with status 422 and reason tts_no_playable_content if nothing can play. Preparation failures reject without synthesis or a raw fallback.
Parameters
message
string
options?
TtsGenerationOptions = {}
Returns
Promise<GeneratedAudio>
speech()
Call Signature
ts
speech(message, moderate?): Promise<void>;Reads a piece of text aloud through text-to-speech on the overlay.
Parameters
message
string
The text to vocalize.
moderate?
boolean
If true, the text is moderated (filtered) before being read.
Returns
Promise<void>
A promise that resolves when accepted. Does not wait for audio generation or playback.
Default Value
false
Example
ts
await k.textToSpeech.speech('A big congratulations to the winner!', true);Call Signature
ts
speech(message, options?): Promise<void>;Requests playback on main (default) or this app's current overlay. With translate_instructions or enhance_instructions, waits for preparation and optional moderation. Enhancement takes priority if both are true; spoken words and their language are never rewritten. ElevenLabs keeps speech continuous across effects; internal changes use audio timestamps. OpenAI keeps separate segments. Direction-only prefixes inherit the first spoken fragment's effects; constant effects need no timestamps. Directions and reactions are never automatically repeated. Voice and sound commands remain block boundaries. Blocks without words produce no audio; soundboards remain playable. Missing required timestamps fail generation. Rejects with status 422 and reason tts_no_playable_content if nothing can play, before any AI call or generation quota. Does not wait for audio generation or playback. A preparation failure rejects without synthesis or a raw fallback. save defaults to false. With save: true, title is required and the backend saves one named media for seven days. Apps need file:write to save; the backend prefixes the authenticated app slug. No upload is needed.
Parameters
message
string
options?
Returns
Promise<void>