tts

Type aliases

CustomTtsProvider

Ƭ CustomTtsProvider: (text: string, voice: { emotion: string ; lang: string ; 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 ; speaker: string ; speed: number ; variation: number }): Response | Audio | Promise<Response | Audio>

Parameters:

NameType
textstring
voiceobject
voice.emotionstring
voice.langstring
voice.speakerstring
voice.speednumber
voice.variationnumber

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


CustomTtsSpeaker

Ƭ CustomTtsSpeaker: object

Type declaration:

NameType
createdTimeDate
lastUpdatedTimeDate
namestring

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" | "voice-cloning" | "dasha-emotional"

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

addOrUpdateCustomSpeakerByName

addOrUpdateCustomSpeakerByName(name: string, voiceFileContent: Uint8Array, options?: { account?: Account }): Promise<CustomTtsSpeaker>

Parameters:

NameType
namestring
voiceFileContentUint8Array
options?object
options.account?Account

Returns: Promise<CustomTtsSpeaker>


deleteCustomSpeakerByName

deleteCustomSpeakerByName(name: string, options?: { account?: Account }): Promise<void>

Parameters:

NameType
namestring
options?object
options.account?Account

Returns: Promise<void>


getCustomSpeakerByName

getCustomSpeakerByName(name: string, options?: { account?: Account }): Promise<CustomTtsSpeaker>

Parameters:

NameType
namestring
options?object
options.account?Account

Returns: Promise<CustomTtsSpeaker>


getCustomSpeakers

getCustomSpeakers(options?: { account?: Account }): Promise<CustomTtsSpeaker[]>

Parameters:

NameType
options?object
options.account?Account

Returns: Promise<CustomTtsSpeaker[]>


synthesize

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

Parameters:

NameType
textstring
voiceobject
voice.emotionstring
voice.langstring
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.