tts

Type aliases

CustomTtsProvider

Ƭ CustomTtsProvider: (text: string, voice: { emotion: string ; lang: string ; options?: { [x: string]: any; } ; speaker: string ; speed: number ; variation: number }) => Response | Audio | Promise<Response | Audio>

A custom text-to-speech callback.

Given a text and voice parameters, the callback must return either an Audio object, or a Fetch API's [Response] object containing the audio data. Both of them can also be wrapped in a Promise.

example using an external TTS API

application.customTtsProvider = (text) => fetch(`https://example.com/say?text=${text}`);

example using pre-recorded audio files

application.customTtsProvider = (text) => dasha.audio.fromFile(`/path/to/audio/${text}.mp3`);

Type declaration:

▸ (text: string, voice: { emotion: string ; lang: string ; options?: { [x: string]: any; } ; speaker: string ; speed: number ; variation: number }): Response | Audio | Promise<Response | Audio>

Parameters:

NameType
textstring
voiceobject
voice.emotionstring
voice.langstring
voice.options?object
voice.speakerstring
voice.speednumber
voice.variationnumber

Returns: Response | Audio | Promise<Response | Audio>


TtsDispatcher

Ƭ TtsDispatcher<TInput, TOutput>: (conv: Conversation<TInput, TOutput>) => TtsProviderName | Promise<TtsProviderName>

A callback that selects a text-to-speech engine for the conversations.

deprecated use {@link Conversation.audio.tts} instead

Type parameters:

NameType
TInputRecord<string, unknown>
TOutputRecord<string, unknown>

Type declaration:

▸ (conv: Conversation<TInput, TOutput>): TtsProviderName | Promise<TtsProviderName>

Parameters:

NameType
convConversation<TInput, TOutput>

Returns: TtsProviderName | Promise<TtsProviderName>


TtsProviderName

Ƭ TtsProviderName: "default" | "custom" | "dasha"

A text-to-speech provider to use for the application.

"default" means the default TTS engine.

"dasha" means Dasha.AI's own TTS engine.

"custom" means using your own TTS via the Application.customTtsProvider.

Functions

synthesize

synthesize(text: string, voice: { emotion: string ; lang: string ; options?: { [x: string]: any; } ; speaker: string ; speed: number ; variation: number }, options: { account?: Account ; providerName: string }): Promise<Uint8Array>

Parameters:

NameType
textstring
voiceobject
voice.emotionstring
voice.langstring
voice.options?object
voice.speakerstring
voice.speednumber
voice.variationnumber
optionsobject
options.account?Account
options.providerNamestring

Returns: Promise<Uint8Array>

Found a mistake? Email us, and we'll send you a free t-shirt!

Enroll in beta

Request invite to our private Beta program for developers to join the waitlist. No spam, we promise.