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:
Name | Type |
---|---|
text | string |
voice | object |
voice.emotion | string |
voice.lang | string |
voice.options? | object |
voice.speaker | string |
voice.speed | number |
voice.variation | number |
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:
Name | Type |
---|---|
TInput | Record<string, unknown> |
TOutput | Record<string, unknown> |
Type declaration:
▸ (conv
: Conversation<TInput, TOutput>): TtsProviderName | Promise<TtsProviderName>
Parameters:
Name | Type |
---|---|
conv | Conversation<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:
Name | Type |
---|---|
text | string |
voice | object |
voice.emotion | string |
voice.lang | string |
voice.options? | object |
voice.speaker | string |
voice.speed | number |
voice.variation | number |
options | object |
options.account? | Account |
options.providerName | string |
Returns: Promise<Uint8Array>