From 1977b73afa40b09634d62d8dc47871ecc4eadb97 Mon Sep 17 00:00:00 2001 From: MrCsabaToth Date: Sat, 19 Oct 2024 22:53:33 -0700 Subject: [PATCH] Initialize MediaKit even if TTS initialization fails on a FAW because of some engine problem --- lib/bootstrap.dart | 2 ++ lib/speech/service/tts.dart | 3 --- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/bootstrap.dart b/lib/bootstrap.dart index 4fe36c4..44d62f1 100644 --- a/lib/bootstrap.dart +++ b/lib/bootstrap.dart @@ -16,6 +16,7 @@ import 'package:inspector_gadget/location/service/location.dart'; import 'package:inspector_gadget/preferences/service/preferences.dart'; import 'package:inspector_gadget/speech/service/stt.dart'; import 'package:inspector_gadget/speech/service/tts.dart'; +import 'package:media_kit/media_kit.dart'; Future bootstrap(FutureOr Function() builder) async { await runZonedGuarded>( @@ -47,6 +48,7 @@ Future bootstrap(FutureOr Function() builder) async { final sttService = SttService(); GetIt.I.registerSingleton(sttService); unawaited(sttService.init()); + MediaKit.ensureInitialized(); final ttsService = TtsService(); GetIt.I.registerSingleton(ttsService); unawaited(ttsService.init()); diff --git a/lib/speech/service/tts.dart b/lib/speech/service/tts.dart index 81d04f1..f82bda0 100644 --- a/lib/speech/service/tts.dart +++ b/lib/speech/service/tts.dart @@ -2,7 +2,6 @@ import 'dart:io'; import 'package:flutter_tts/flutter_tts.dart'; import 'package:inspector_gadget/common/state_logging_mixin.dart'; -import 'package:media_kit/media_kit.dart'; import 'package:speech_to_text/speech_to_text.dart'; import 'package:strings/strings.dart'; @@ -65,8 +64,6 @@ class TtsService with StateLoggingMixin { logEvent('TTS error: $msg'); }); - MediaKit.ensureInitialized(); - return this; }