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

iOS: When audio is used by another app, STT stops working, but "SpeechRecognitionError" shows no errors and "isListening" shows true #470

Open
kodjima33 opened this issue Jan 2, 2024 · 6 comments

Comments

@kodjima33
Copy link

kodjima33 commented Jan 2, 2024

Steps to reproduce

  1. Copy the code from the official guide or code example that I use, that I copied from here with ErrorListener and add "isListening" status check
  2. Start Speech recognition process in IOS app
  3. Hover/collapse app (speech recording is still active)
  4. Open any app that uses audio or start music on same device
  5. Speech-to-text stops functioning

Note: if you skip steps 3&4, result will be same

Expected:

  • SpeechRecognitionError to show an error
  • isListening to show False

Actual result
SpeechRecognitionError will show no errors
isListening status shows "True"

Example screenshot in Xcode: https://share.cleanshot.com/wYNyM1qs

Environment: iPhone 15, iOS 17

speech_to_text version: latest

What I tried to do: researched 20+ topics and issues regarding continuous use like this but didn't find anything that solves my usecase

I'm not very technical, but If anyone has dealt with this before and could help - would love to pay. My email is kodjima33@gmail.com and telegram is @kodjima33

@OmAr-Kader
Copy link

OmAr-Kader commented Jan 2, 2024

Upwork

Actually STT still working for your app audio(which it stopped) but it is isolated from device sound(other app's audio).

developer.apple

Screenshot 2024-01-02 073013

Unfortunately, it is not a trivial task to get access to the system sound output (which is probably a good thing, from a security standpoint).

The solutions will generally involve setting up a 'fake' audio device that audio can get played through instead of the default output device you've chosen, and you need "Method channel" for that (Not Flutter)

But if you just want to detect "isListening," you can handle audio interruptions separately

@Kaival-Patel
Copy link

Came from Upwork :)
Have you tried this package
https://pub.dev/packages/audio_service

For overriding the default settings for the audio services for iPhone as I have worked with this in past and working fine? My usecase was to record the sound from mic when video is playing. (Recording the voiceover)

@sowens-csd sowens-csd added the iOS label Jan 2, 2024
@sowens-csd
Copy link
Contributor

If you add a step 6 and bring the STT app back to the foreground does the active listening session still work? Or does it only work once a new listening session is started?

@kodjima33
Copy link
Author

@sowens-csd

If you add a step 6 and bring the STT app back to the foreground does the active listening session still work? Or does it only work once a new listening session is started?

I think it only works once we kill STT and then start a new listening session, but the problem is that we cannot even restart it because we don't know if the speech STT stopped listening or is still active. Because there are no errors.

However we found a trick with looking at invokeFlutter: soundlevel change

@sowens-csd
Copy link
Contributor

Thanks for the clarification. I'll have a look at detecting that error. Hopefully doable.

@hassanrazzaq8
Copy link

@Kaival-Patel my use case is same to yours like I want to use speech to text in iOS while running music but starting speechtotext effect on music and when I try to stop speech to text it also stops the music I am using just_audio ignorer to play the music
@sowens-csd

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants