Comments (13)
import 'package:flutter/material.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:speech_to_text/speech_to_text.dart';
import 'package:youtube_player_flutter/youtube_player_flutter.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Demo Speech To Text',
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
useMaterial3: true,
),
home: const MyHomePage(title: 'Demo Speech To Text'),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key, required this.title});
final String title;
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
title: Text(widget.title),
),
body: const Padding(
padding: EdgeInsets.all(16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
_YoutubePlayerWidget(),
SizedBox(height: 16),
_SpeechToTextWidget(),
],
),
),
);
}
}
class _YoutubePlayerWidget extends StatelessWidget {
const _YoutubePlayerWidget();
@override
Widget build(BuildContext context) {
print('_YoutubePlayerWidget build');
return YoutubePlayer(
controller: YoutubePlayerController(
initialVideoId: 'iLnmTe5Q2Qw',
flags: const YoutubePlayerFlags(
autoPlay: true,
),
),
showVideoProgressIndicator: true,
);
}
}
class _SpeechToTextWidget extends StatefulWidget {
const _SpeechToTextWidget();
@override
State<_SpeechToTextWidget> createState() => _SpeechToTextWidgetState();
}
class _SpeechToTextWidgetState extends State<_SpeechToTextWidget> {
SpeechToText speechToText = SpeechToText();
bool availableSpeech = false;
@override
void initState() {
super.initState();
_initSpeechToText();
}
Future<void> _initSpeechToText() async {
final permissionStatus = await Permission.speech.request();
if (!permissionStatus.isGranted) {
return;
}
availableSpeech = await speechToText.initialize();
return;
}
Future<void> _listenSpeechToText() async {
if (!availableSpeech) {
return;
}
speechToText.listen(
onResult: (value) {},
onSoundLevelChange: (value) {},
listenMode: ListenMode.search,
);
}
@override
Widget build(BuildContext context) {
print('_SpeechToTextWidget build');
return FilledButton(
onPressed: () async {
_listenSpeechToText();
},
child: const Text('Speech To Text'),
);
}
}
from speech_to_text.
YouTube player sounds like a different issue than 374. Because SpeechToText takes over the audio channel while it is listening I can see why YouTube might pause. Do you have start/stop sounds configured in your app?
from speech_to_text.
YouTube player sounds like a different issue than 374. Because SpeechToText takes over the audio channel while it is listening I can see why YouTube might pause. Do you have start/stop sounds configured in your app?
I played the video on mute, but the problem is still not resolved. Is this the default behavior when I combine them together?
from speech_to_text.
I don't know, I've never tried it. Do you have the start/stop sounds configured? If you do I'd suggest trying it without them. If it still pauses that would tell us something.
from speech_to_text.
I don't know, I've never tried it. Do you have the start/stop sounds configured? If you do I'd suggest trying it without them. If it still pauses that would tell us something.
I don't understand. What do you want me to start/stop sound of?
from speech_to_text.
Probably same issue here. I'm trying to make a talking app with speech_to_text and then play the response audio with audio player or something, but once I trigger speech_to_text no other sound can be played until I reopen a new simulator, seems like this audio channel issue but I tried all the possible stop and start methods I can and no luck.
YouTube player sounds like a different issue than 374. Because SpeechToText takes over the audio channel while it is listening I can see why YouTube might pause. Do you have start/stop sounds configured in your app?
from speech_to_text.
@sowens-csd When I call speechToText.listen(), It blocks the current playing video in video_player package also.
from speech_to_text.
@xweng1016 Have you found any workaround?
from speech_to_text.
have you got any solution for this , i also want to use speech to text and record the same audio and play in the app when needed
from speech_to_text.
@kuberanb Can you describe more detail about your case?
from speech_to_text.
@wamynobe I want the audio recording and speech_to_text to work simulataneously that is when i click the button the audio should record and store it in storage and get the text from the audio and show it in the screen . When i try to enable both at same time the speech_to_text stops listening so how to fix this , i have also mentioned you in my code
from speech_to_text.
@kuberanb because speech_to_text is running on main thread and so do the audio media. my suggestion is that you should try another way to use speech to text. such as build your own speech to text package. I am working on a new speech to text that is spawned by another thread. You can try this approach.
from speech_to_text.
@kuberanb to reconfirm that the audio resource using by webview or some packages like flutter_video ... conflicted with speech to text audio resource so it will pause audio or even the video.
from speech_to_text.
Related Issues (20)
- Support Flutter web WASM HOT 1
- Error when user stay in silent dont possible refresh the widgets
- Error when using TTS HOT 1
- onResult called after onDone
- Error 7 not reported
- SpeechRecognitionError: error_permission && error_client HOT 1
- android , if no network, I got error: error_language_not_sopported HOT 1
- Slow when start listening HOT 1
- Error 9 on Android Emulator HOT 1
- Not working with many browsers HOT 1
- Not working on ipad HOT 1
- Does it uses device resources for comuputation or some cloud server ? HOT 4
- Android device stops listening in mid-speech - additional context provided HOT 1
- Is there a way to listen for changes to SpeechToText.isListening? HOT 2
- failing recognition on ios simulators when connected via BT headset HOT 1
- google_maps_flutter ^2.7.0 is incompatible with speech_to_text > HOT 1
- How to overcome error_language_not_supported with `onDevice: true` `SpeechListenOptions`? HOT 2
- Workaround when SpeechToTextPlatform.instance.locales() returns duplicates HOT 2
- SpeechToText instance returns null HOT 1
- Remove references to deprecated v1 Android embedding HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from speech_to_text.