added send functionality to icon.

This commit is contained in:
Joshua
2024-07-10 13:44:16 -06:00
parent 097b99e0e6
commit 711991c7bf
13 changed files with 363 additions and 281 deletions
+9 -9
View File
@@ -3,15 +3,15 @@ import 'package:speech_to_text/speech_to_text.dart' as stt;
/// Handles standard Speech-To-Text using on-device processing.
class SpeechToText {
final stt.SpeechToText _speechToText = stt.SpeechToText();
bool _speechEnabled = false;
final stt.SpeechToText speechToText = stt.SpeechToText();
bool speechEnabled = false;
String text = "";
// Check if speech recognition is enabled.
bool isSpeechEnabled() => _speechEnabled;
bool isSpeechEnabled() => speechEnabled;
Future<String> getTextWhenReady() async {
await _speechToText.stop();
await speechToText.stop();
return text;
}
@@ -22,22 +22,22 @@ class SpeechToText {
void reset() => text = "";
/// Start a speech recognition session
void _startListening() async => await _speechToText.listen(onResult: _onSpeechResult);
void startListening() async => await speechToText.listen(onResult: onSpeechResult);
/// Manually stop the active speech recognition session
/// Note that there are also timeouts that each platform enforces
/// and the SpeechToText plugin supports setting timeouts on the
/// listen method.
void _stopListening() async => await _speechToText.stop();
void stopListening() async => await speechToText.stop();
SpeechToText() {
_initSpeech();
initSpeech();
}
/// This has to happen only once per app
void _initSpeech() async => _speechEnabled = await _speechToText.initialize();
void initSpeech() async => speechEnabled = await speechToText.initialize();
/// This is the callback that the SpeechToText plugin calls when
/// the platform returns recognized words.
void _onSpeechResult(SpeechRecognitionResult result) => text = result.recognizedWords;
String onSpeechResult(SpeechRecognitionResult result) => (text = result.recognizedWords);
}