diff options
author | Anuj-S62 <anuj603362@gmail.com> | 2024-07-11 15:18:31 +0530 |
---|---|---|
committer | Anuj-S62 <anuj603362@gmail.com> | 2024-07-21 19:52:11 +0530 |
commit | 0b59086cdddd40689e57969aa7914ba38f1ec2dd (patch) | |
tree | 975c38663f57d497eeab0e2649e51308aef9a755 /lib/screens/loading_screen.dart | |
parent | ecd34435c1a74b39bf41d59ad479fdc85d0afb7b (diff) |
Update Voice Agent Flutter App
- update voice-agent flutter app to use whisper AI for
speech-to-text functionality.
- Integrated SharedPreferences to store the application state.
Bug-AGL: SPEC-5200
Change-Id: I9a05b1d135c1fa07949333391ff828f166b7fe8e
Signed-off-by: Anuj-S62 <anuj603362@gmail.com>
Diffstat (limited to 'lib/screens/loading_screen.dart')
-rw-r--r-- | lib/screens/loading_screen.dart | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/lib/screens/loading_screen.dart b/lib/screens/loading_screen.dart new file mode 100644 index 0000000..f4d6c6d --- /dev/null +++ b/lib/screens/loading_screen.dart @@ -0,0 +1,81 @@ +import 'dart:async'; + +import 'package:flutter/cupertino.dart'; +import 'package:flutter_voiceassistant/screens/home_screen.dart'; +import 'package:provider/provider.dart'; +import 'package:shared_preferences/shared_preferences.dart'; + +import '../models/app_state.dart'; +import '../utils/app_config.dart'; + +class Loading extends StatelessWidget { + final AppConfig config; + final String wakeWord; + Loading({required this.config, required this.wakeWord}); + + Future<void> initialize(BuildContext context) async { + // Initialize the app + final appState = context.read<AppState>(); + bool isWakeWordMode = false; + String intentEngine = "snips"; + String streamId = ""; + bool isCommandProcessing = false; + String commandProcessingText = "Processing..."; + String sttFramework = "vosk"; + bool onlineMode = false; + + SharedPreferences prefs = await SharedPreferences.getInstance(); + prefs.reload(); + if(prefs.containsKey('isWakeWordMode')) { + isWakeWordMode = await prefs.getBool('isWakeWordMode')!; + } + if(prefs.containsKey('intentEngine')) { + intentEngine = await prefs.getString('intentEngine')!; + } + if(prefs.containsKey('streamId')) { + streamId = await prefs.getString('streamId')!; + } + if(prefs.containsKey('isCommandProcessing')) { + isCommandProcessing = await prefs.getBool('isCommandProcessing')!; + } + if(prefs.containsKey('commandProcessingText')) { + commandProcessingText = await prefs.getString('commandProcessingText')!; + } + if(prefs.containsKey('sttFramework')) { + sttFramework = await prefs.getString('sttFramework')!; + } + if(prefs.containsKey('onlineMode')) { + onlineMode = await prefs.getBool('onlineMode')!; + } + + appState.isWakeWordMode = isWakeWordMode; + appState.intentEngine = intentEngine; + appState.streamId = streamId; + appState.isCommandProcessing = isCommandProcessing; + appState.commandProcessingText = commandProcessingText; + appState.sttFramework = sttFramework; + appState.onlineMode = onlineMode; + + print('isWakeWordMode: $isWakeWordMode'); + print('intentEngine: $intentEngine'); + print('streamId: $streamId'); + print('isCommandProcessing: $isCommandProcessing'); + print('commandProcessingText: $commandProcessingText'); + print('sttFramework: $sttFramework'); + print('onlineMode: $onlineMode'); + } + + @override + Widget build(BuildContext context) { + return FutureBuilder( + future: initialize(context), + builder: (context, snapshot) { + if (snapshot.connectionState == ConnectionState.done) { + return HomePage(config: config, wakeWord: wakeWord); + } else { + return CupertinoActivityIndicator(); + } + }, + ); + } +} |