Open TranTuanManh opened 1 year ago
Same to here . Its not working when bluetooth is connected Android Not working. Ios : Its not working with non-apple headsets
@TranTuanManh @VarmaTech I just wrote an Android program and TTS played the sound on my Android Bluetooth headset.
import 'package:flutter/material.dart';
import 'package:flutter_tts/flutter_tts.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
debugShowCheckedModeBanner: false,
home: const Home(),
);
}
}
class Home extends StatefulWidget {
const Home({super.key});
@override
State<Home> createState() => _HomeState();
}
class _HomeState extends State<Home> {
final FlutterTts tts = FlutterTts();
final TextEditingController controller = TextEditingController(text: 'Hello world');
@override
void initState() {
super.initState();
initialize();
}
void initialize() async {
await tts.setLanguage('en-US');
await tts.setSpeechRate(0.4);
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
TextField(
controller: controller,
),
ElevatedButton(
onPressed: () {
tts.speak(controller.text);
},
child: const Text('Speak'),
),
],
),
);
}
}
It uses the built in Android/iOS APIs internally, so any issue should/would be with the device/OS itself, not this library.
💬 Questions and Help
I'm sorry about that I have no device to test this. Currently my users reported that they tried the both of headset types but didn't work.
Version: 3.8.3
Platform: