Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wireless headsets support #210

Closed
rayrapetyan opened this issue May 9, 2021 · 16 comments
Closed

Wireless headsets support #210

rayrapetyan opened this issue May 9, 2021 · 16 comments
Labels
android enhancement New feature or request

Comments

@rayrapetyan
Copy link
Contributor

rayrapetyan commented May 9, 2021

Hello. It would be nice to have a support for a wireless headsets (currently only default device's microphone is utilized).

At least for Android it should be as simple as adding few lines of code:

https://stackoverflow.com/questions/28086403/android-speech-recognizer-with-bluetooth-microphone
https://stackoverflow.com/questions/8681085/android-voice-recognition-through-bluetooth

I haven't tried them though.

The question is if it's also easy to do the same on iOS.

Thanks.

@sowens-csd
Copy link
Contributor

AFAIK wired headsets already work fine because they become the default when plugged in. I've definitely used them on iOS though not on Android. Have you tried it? I

I haven't tried Bluetooth. I guess that you did and it doesn't work? Did you try on both Android and iOS?

@rayrapetyan
Copy link
Contributor Author

rayrapetyan commented May 14, 2021

Thanks Stephen! Just curious - how did you test wired headset, I mean when it's plugged in your phone is nearby anyway, so how do you know headset's mic (and not the built-in microphone) was used?

I tried BT on Android and yeah, it doesn't work. My BT mic doesn't work even on the in-system voice input (e.g. when you use mic on a standard google keyboard voice input). It works (and turns on automatically) only on incoming call (in any app supporting calls). I think this is all by design and that's how it's expected to work. At the same time I'm sure BT mic can be turned on explicitly (using steps from links above).

@rayrapetyan
Copy link
Contributor Author

There is one thing I'm afraid will not work though... Every time I test my mic at e.g. https://mictests.com/, I can hear "Call ended" at the end of test. So if it's a hardware feature, it might be hard to disable programmatically (if at all possible).

@rayrapetyan
Copy link
Contributor Author

UPD: I've just tested a wired headset and mic becomes default, I've scratched the mic while recording so I'm 100% sure it works. Tried few more BT - none of them work with this plugin. Also, not all BT say "call ended" at https://mictests.com, so I think it's configurable from the headsets supporting tools\apps.

@rayrapetyan rayrapetyan changed the title Headsets support Wireless headsets support May 14, 2021
@sylvainjack
Copy link

sylvainjack commented Nov 5, 2021

Hi everyone,
I encountered the same problem with apple AIRPODS : speech to text didn't work. In the same app, I use tts_ (text to speech) and had the same problem. The sound wouldn't go through the AirPods.
Apparently, I found this on the flutter_tts package (text to speech) :
await flutterTts
.setIosAudioCategory(IosTextToSpeechAudioCategory.playAndRecord, [
IosTextToSpeechAudioCategoryOptions.allowBluetooth,
IosTextToSpeechAudioCategoryOptions.allowBluetoothA2DP,
IosTextToSpeechAudioCategoryOptions.mixWithOthers
]);

This actually solved the problem for TEXT TO SPEECH and the SPEECH TO TEXT packages. Both now work on my iPhone. Haven't tested it on Android.

@sowens-csd
Copy link
Contributor

Current state of this is that @sylvainjack's suggested fix is released os Bluetooth should be working on iOS. The Android version needs updates to properly support Bluetooth.

sowens-csd pushed a commit that referenced this issue Dec 11, 2021
@sowens-csd
Copy link
Contributor

Android support for bluetooth is now in the repo version. If anyone has a chance to test it that would be welcome. I've tried it on a Samsung with headphones and it seems to be working.

@sowens-csd sowens-csd added android enhancement New feature or request and removed waiting for response labels Dec 11, 2021
@rayrapetyan
Copy link
Contributor Author

Thanks, tested it today.
By itself it works fine, but when https://pub.dev/packages/text_to_speech is also used, occasionally output voice becomes muted (you can't hear anything in headphones nor from speaker). Calling "setVolume" right before "speak" doesn't help. What could be the reason?

@sowens-csd
Copy link
Contributor

Thanks for testing it so quickly. Does the volume issue only happen if you are using a Bluetooth device or does it happen even if you have bluetooth turned off completely?

@rayrapetyan
Copy link
Contributor Author

Only when Bluetooth device is connected and used.

@sowens-csd
Copy link
Contributor

Thanks, I'll try to reproduce and see what I can do. In general volume issues on Android are painful.

@sowens-csd
Copy link
Contributor

I think I have a reproduce but for me it is happening every second phrase. So I start a listen, then use speak to play back what I just said. The first time it works properly, the second time it is either very low volume or not working at all, not sure which. That pattern then repeats. Do you see the same behaviour or different?

@rayrapetyan
Copy link
Contributor Author

Exactly! Every second phrase is muted. I've tried SetVolume before each phrase and it didn't help.

@sowens-csd
Copy link
Contributor

Excellent, glad yours is the same.

Okay, I've just committed a potential fix. It resolves the issue for me. I was only stopping the bluetooth headset on an explicit stop or cancel. This version stops it every time speech ends. Let me know if this works for you.

@rayrapetyan
Copy link
Contributor Author

It works now, thanks!

@sowens-csd
Copy link
Contributor

This is published as 5.4.0 on pub.dev. Thanks for the help verifying this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
android enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants