SpeechToTextUltraWidgetImplementation.dart
1.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import 'package:flutter/material.dart';
import 'package:speech_to_text_ultra/speech_to_text_ultra.dart';
class SpeechToTextUltraWidgetImplementation extends StatefulWidget {
const SpeechToTextUltraWidgetImplementation({super.key});
@override
State<SpeechToTextUltraWidgetImplementation> createState() => _SpeechToTextUltraWidgetImplementationState();
}
class _SpeechToTextUltraWidgetImplementationState extends State<SpeechToTextUltraWidgetImplementation> {
bool mIsListening = false;
String mEntireResponse = '';
String mLiveResponse = '';
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.white,
appBar: AppBar(
backgroundColor: Colors.teal,
centerTitle :true,
title: const Text('Speech To Text Ultra',style: TextStyle(fontSize: 20,fontWeight: FontWeight.w500),),
),
body: Center(
child: SingleChildScrollView(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
mIsListening
? Text('$mEntireResponse $mLiveResponse')
: Text(mEntireResponse),
const SizedBox(height: 20),
SpeechToTextUltra(
ultraCallback:
(String liveText, String finalText, bool isListening) {
setState(() {
mLiveResponse = liveText;
mEntireResponse = finalText;
mIsListening = isListening;
});
},
// toPauseIcon: const Icon(Icons.pause),
// toStartIcon: const Icon(Icons.mic),
// pauseIconColor: Colors.black,
// startIconColor: Colors.black,
),
const SizedBox(
height: 10,
),
],
),
),
),
);
}
}