26 lines
921 B
Dart
Executable File
26 lines
921 B
Dart
Executable File
import 'package:flutter/foundation.dart';
|
|
import 'package:flutter_tts/flutter_tts.dart';
|
|
import 'package:translator_lux/global/global_state.dart';
|
|
|
|
class TtsUtil {
|
|
static initTts() async {
|
|
debugPrint("TTS Service init start");
|
|
await GlobalState.ttsController.setSharedInstance(true);
|
|
await GlobalState.ttsController.setIosAudioCategory(
|
|
IosTextToSpeechAudioCategory.ambient,
|
|
[
|
|
IosTextToSpeechAudioCategoryOptions.allowBluetooth,
|
|
IosTextToSpeechAudioCategoryOptions.allowBluetoothA2DP,
|
|
IosTextToSpeechAudioCategoryOptions.mixWithOthers
|
|
],
|
|
IosTextToSpeechAudioMode.voicePrompt);
|
|
await GlobalState.ttsController.awaitSpeakCompletion(true);
|
|
await GlobalState.ttsController.awaitSynthCompletion(true);
|
|
debugPrint("TTS Service init success");
|
|
}
|
|
|
|
static translatorTtsPlay(String text) {
|
|
GlobalState.ttsController.speak(text);
|
|
}
|
|
}
|