dlutton / flutter_tts

Flutter Text to Speech package
MIT License
613 stars 258 forks source link

Does it work with plug or bluetooth headset on Android? #436

Open TranTuanManh opened 1 year ago

TranTuanManh commented 1 year ago

💬 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:

VarmaTech commented 11 months ago

Same to here . Its not working when bluetooth is connected Android Not working. Ios : Its not working with non-apple headsets

longtimedeveloper commented 11 months ago

@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'),
          ),
        ],
      ),
    );
  }
}
josephcrowell commented 11 months ago

It uses the built in Android/iOS APIs internally, so any issue should/would be with the device/OS itself, not this library.