flutter_tts icon indicating copy to clipboard operation
flutter_tts copied to clipboard

Does it work with plug or bluetooth headset on Android?

Open TranTuanManh opened this issue 2 years ago • 3 comments

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

  • [ ] :robot: Android

TranTuanManh avatar Nov 12 '23 15:11 TranTuanManh

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

VarmaTech avatar Nov 22 '23 01:11 VarmaTech

@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'),
          ),
        ],
      ),
    );
  }
}

longtimedeveloper avatar Dec 03 '23 18:12 longtimedeveloper

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

josephcrowell avatar Dec 06 '23 00:12 josephcrowell