speak method
The presenter's line text in locale, charged each time by the ORYKSA interaction cost
table (OryksaTvSpeech.interactionsSpent; a line not counted is not shown). voice false:
subtitles only, no voice wanted. cachedRev: the device already has this line with that
voice revision, so the server may only count it and send no voice. The bytes may be empty
(subtitles only). Null when the server gave nothing for it. Throws on other errors.
Implementation
@override
Future<OryksaTvSpeech?> speak(String text, {required String locale, bool whisper = false, bool voice = true, String? cachedRev}) async {
final l = oryksaTvNormalizeLocale(locale);
try {
final a = await client.requestAudio('/client/tts', {
'text': text,
if (l.isNotEmpty) 'locale': l,
'purpose': 'presenter',
'platform': platform,
if (whisper) 'whisper': true,
// Subtitles only: the server counts the line and sends no voice.
if (!voice) 'voice': false,
// The device has this line with this voice: the server counts it and need not make the voice again.
if (voice && cachedRev != null && cachedRev.isNotEmpty) ...{'cached': true, 'voice_rev': cachedRev},
});
return OryksaTvSpeech(
a.bytes,
locale: a.header('x-oryksa-locale') ?? l,
voiceRev: a.header('x-oryksa-voice-rev'),
interactionsSpent: int.tryParse(a.header('x-oryksa-interactions-spent') ?? ''),
);
} on OryksaException catch (e) {
if (e.code == 'voice_unavailable') return null;
rethrow;
}
}