'How to solve flutter tts noise
Listen my problem in this short video.
I've tested this case by using some other audio packages(tts、text to speech), but the result is the same, is this problem caused by the Android studio emulator?
I've tried reinstalling, changing every device and API, and changing the audio buffer size,but nothing solves the problem in android studio emulator noise.
In addition, I changed the emulator to bluestacks 5 and genymotion, but it became no sound
question
1.How can I fix android studio emulator noise problem in windows 10?
2.Why can't bluestacks 5 and genymotion play sound
import 'package:flutter/material.dart';
import 'package:flutter_tts/flutter_tts.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
home: MyHomePage(),
);
}
}
class MyHomePage extends StatelessWidget {
MyHomePage({Key? key}) : super(key: key);
final FlutterTts flutterTts = FlutterTts();
speak() async{
//print(await flutterTts.setPitch);
await flutterTts.setLanguage("en-US");
//await flutterTts.setPitch(1.0);
//await flutterTts.speak(text);
await flutterTts.speak('hello how are you');
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
centerTitle: true,
title: Text('tts'),
),
body: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(
'Press this button to say hello',
textAlign: TextAlign.center,
style: TextStyle(fontSize: 20),
),
Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
ElevatedButton(
onPressed: () async{
speak();
},
child: Column(
children: <Widget>[
Text('say hello',style: TextStyle(
fontSize: 20,
color: Colors.white,
),
)
],
),
)
],
),
)
],
),
);
}
}
Solution 1:[1]
I suggest testing the following on your current emulator setup, a real device, and genymotion/stacks emulator (all three things):
- Does ANY audio play properly such as a youtube video, or sound settings demo?
If no, then STOP HERE: the problem has nothing to do with your code -- it has to do with the device, or in the case of an emulator, a bug with the way the emulator is using the audio hardware of the host device.
- Does the tts engine demo test work properly in the devices settings?
If no, then STOP HERE: the problem is with the tts engine on the device.
- Does your app work properly?
If no, then the problem could be your code. (but if you've already passed stages 1 and 2, then I very much doubt this will fail).
PS - If your app works on a real device then you really don't have a problem.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Nerdy Bunz |
