Important fix (voice breaks app)
This commit is contained in:
parent
bd71f99a55
commit
c780564129
|
@ -115,6 +115,12 @@ class _AppState extends State<App> {
|
|||
await FlutterDisplayMode.setHighRefreshRate();
|
||||
} catch (_) {}
|
||||
|
||||
SharedPreferences.setPrefix("ollama.");
|
||||
SharedPreferences tmp = await SharedPreferences.getInstance();
|
||||
setState(() {
|
||||
prefs = tmp;
|
||||
});
|
||||
|
||||
if ((await Permission.bluetoothConnect.isGranted) &&
|
||||
(await Permission.microphone.isGranted)) {
|
||||
voiceSupported = await speech.initialize();
|
||||
|
@ -122,12 +128,6 @@ class _AppState extends State<App> {
|
|||
prefs!.setBool("voiceModeEnabled", false);
|
||||
voiceSupported = false;
|
||||
}
|
||||
|
||||
SharedPreferences.setPrefix("ollama.");
|
||||
SharedPreferences tmp = await SharedPreferences.getInstance();
|
||||
setState(() {
|
||||
prefs = tmp;
|
||||
});
|
||||
}
|
||||
|
||||
load();
|
||||
|
|
|
@ -8,6 +8,7 @@ import 'package:ollama_app/worker/setter.dart';
|
|||
import 'package:speech_to_text/speech_to_text.dart' as stt;
|
||||
import 'package:ollama_dart/ollama_dart.dart' as llama;
|
||||
import 'package:datetime_loop/datetime_loop.dart';
|
||||
import 'package:volume_controller/volume_controller.dart';
|
||||
|
||||
import 'main.dart';
|
||||
import 'worker/sender.dart';
|
||||
|
@ -190,6 +191,71 @@ class _ScreenVoiceState extends State<ScreenVoice> {
|
|||
var tmp = aiText;
|
||||
tmp.replaceAll("-", ".");
|
||||
tmp.replaceAll("*", ".");
|
||||
|
||||
// var volume = await VolumeController().getVolume();
|
||||
// var voicesTmp1 = await voice.getLanguages;
|
||||
// var voices = jsonEncode(voicesTmp1);
|
||||
// var isVoiceAvailable = (await voice.isLanguageAvailable(
|
||||
// (prefs!.getString("voiceLanguage") ?? "en_US")
|
||||
// .replaceAll("_", "-")))
|
||||
// .toString();
|
||||
// var voices2Tmp1 = await speech.locales();
|
||||
// var voices2Tmp2 = [];
|
||||
// for (var voice in voices2Tmp1) {
|
||||
// voices2Tmp2.add(voice.localeId.replaceAll("_", "-"));
|
||||
// }
|
||||
// var voices2 = jsonEncode(voices2Tmp2);
|
||||
// await showDialog(
|
||||
// // ignore: use_build_context_synchronously
|
||||
// context: context,
|
||||
// builder: (context) {
|
||||
// return Dialog.fullscreen(
|
||||
// child: ListView(children: [
|
||||
// const Row(
|
||||
// crossAxisAlignment: CrossAxisAlignment.center,
|
||||
// mainAxisSize: MainAxisSize.max,
|
||||
// children: [
|
||||
// Expanded(child: Divider(color: Colors.red)),
|
||||
// SizedBox(width: 8),
|
||||
// Text("START", style: TextStyle(color: Colors.red)),
|
||||
// SizedBox(width: 8),
|
||||
// Expanded(child: Divider(color: Colors.red))
|
||||
// ]),
|
||||
// Text((prefs!.getString("voiceLanguage") ?? "en_US")
|
||||
// .replaceAll("_", "-")),
|
||||
// const Divider(),
|
||||
// Text(volume.toString()),
|
||||
// const Divider(),
|
||||
// Text(voices),
|
||||
// const Divider(),
|
||||
// Text(voicesTmp1
|
||||
// .contains((prefs!.getString("voiceLanguage") ?? "en_US")
|
||||
// .replaceAll("_", "-"))
|
||||
// .toString()),
|
||||
// const Divider(),
|
||||
// Text(isVoiceAvailable),
|
||||
// const Divider(),
|
||||
// Text(voices2),
|
||||
// const Divider(),
|
||||
// Text(voices2Tmp2
|
||||
// .contains((prefs!.getString("voiceLanguage") ?? "en_US")
|
||||
// .replaceAll("_", "-"))
|
||||
// .toString()),
|
||||
// const Divider(),
|
||||
// Text(speech.isAvailable.toString()),
|
||||
// const Row(
|
||||
// crossAxisAlignment: CrossAxisAlignment.center,
|
||||
// mainAxisSize: MainAxisSize.max,
|
||||
// children: [
|
||||
// Expanded(child: Divider(color: Colors.red)),
|
||||
// SizedBox(width: 8),
|
||||
// Text("END", style: TextStyle(color: Colors.red)),
|
||||
// SizedBox(width: 8),
|
||||
// Expanded(child: Divider(color: Colors.red))
|
||||
// ])
|
||||
// ]));
|
||||
// });
|
||||
|
||||
voice.speak(tmp);
|
||||
}
|
||||
},
|
||||
|
|
|
@ -1003,6 +1003,14 @@ packages:
|
|||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "14.2.1"
|
||||
volume_controller:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: volume_controller
|
||||
sha256: "189bdc7a554f476b412e4c8b2f474562b09d74bc458c23667356bce3ca1d48c9"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.0.7"
|
||||
web:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
|
|
@ -43,6 +43,7 @@ dependencies:
|
|||
permission_handler: ^11.3.1
|
||||
datetime_loop: ^1.2.0
|
||||
dynamic_color: ^1.7.0
|
||||
volume_controller: ^2.0.7
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
|
|
Loading…
Reference in New Issue