feat(tts): server-backed TTS engine selection
Introduce server TTS support and engine selection while keeping device TTS as the default. - Add new persistence keys for storing TTS engine and selected server voice (ttsEngine, ttsServerVoiceId, ttsServerVoiceName). - Extend TextToSpeechService to support two engines: TtsEngine.device (FlutterTts) and TtsEngine.server (remote audio). - Wire in an AudioPlayer and optional ApiService to fetch raw audio bytes from the server and play them, with event hooks mapped to existing lifecycle callbacks. - Implement fallback to device TTS on server errors or empty responses, and ensure player lifecycle (pause/stop/dispose) is handled when using server engine. - Allow engine and preferred voice to be configured before initialization and updated at runtime via updateSettings. This enables selecting a server-side voice and using a remote TTS provider while preserving compatibility with the existing device TTS implementation.
This commit is contained in:
@@ -1830,7 +1830,11 @@ Future<List<String>> availableVoices(Ref ref) async {
|
||||
if (api == null) return [];
|
||||
|
||||
try {
|
||||
return await api.getAvailableVoices();
|
||||
final voices = await api.getAvailableServerVoices();
|
||||
return voices
|
||||
.map((v) => (v['name'] ?? v['id'] ?? '').toString())
|
||||
.where((s) => s.isNotEmpty)
|
||||
.toList();
|
||||
} catch (e) {
|
||||
DebugLogger.error('voices-failed', scope: 'voices', error: e);
|
||||
return [];
|
||||
|
||||
Reference in New Issue
Block a user