iOS Question Headphones problem with speech recognition

HuZz

Member
Licensed User
Hi,
I'm finding a curious problem that I can not argue.
In my app I use iSpeechRecognition to get commands ... everything ok, everything works. I can talk and words are properly recognized.
Now if I plug in the headphones, both the original Apple and other bluetooth headsets, every time I call Speech.startrecording, the headphones disconnect and i can not use the microphone ...
if I exit the app, the headphones come back immediately to connect, then to disconnect again when I return in !!!!!
I've also tried to uninstall the app several times, thinking of modified certificates, but this does not solve the problem either.
Can someone help me?

Thanks so much! bye Bye
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
I've also tried to uninstall the app several times, thinking of modified certificates, but this does not solve the problem either.
Such issues are never related to the certificates.

Try:

Add this code:
B4X:
#If OBJC
#import <AVFoundation/AVFoundation.h>
- (void) setAudioSession {
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayAndRecord error: nil];
[[AVAudioSession sharedInstance] setMode:AVAudioSessionModeDefault error: nil];
}
#end if

Run this after you call StopRecording:
B4X:
Dim no As NativeObject = Me
no.RunMethod("setAudioSession", Null)
 
Upvote 0

HuZz

Member
Licensed User
i mean headphones results disconnected... i hear no audio from headphones and i cannot use mic.
i just tried now playing spotify, then opened my app. music stops and headphones icon in status bar disappear. then is no more possible to hear anything o use the mic.
 
Upvote 0

HuZz

Member
Licensed User
I decided to start from the scratch, to be sure i made everything right, so i opened Erel's example provided with the iSpeechLibrary.
Even running this little app i struggle the same problem.
It's quite unuseful for me to have a Speech Recognition library which can't be used with headphones... and i'm really stuck because i don't know how to solve it...

if it can be useful for anybody, i get back this exception raised by Speech_result:
<B4IEXceptionWrapper: Error Domain=kAFAssistantErrorDomain Code=203 "Retry" UserInfo={NSLocalizedDescription=Retry, NSUnderlyingError=0x1c4254760 {Error Domain=SiriSpeechErrorDomain Code=1 "(null)"}}>
 
Last edited:
Upvote 0

HuZz

Member
Licensed User
Thanks Erel for your answer and sorry for bothering you... Is it possible that is problem is somehow related to using TTS togheter with SpeechRecognition?
I'm not sure about it, but it seems all these problems are born after i tried to use TTS in my app.
Now, even if i've don't use it anymore in the app, i'm facing the problems i've already talked of...
Last thing i can try is to format my iphone and see if something change... or look for another device to test... or delete this project i'm working on :(
 
Upvote 0

HuZz

Member
Licensed User
As you can see from the 2 videos (in one while using speech example as it is, in the other while using my app), on top-right of the screen is possible to notice the headphones icon disappearing after calling startRecording...

I tried to restore settings from iphone settings menu, but nothing changed.
i also noticed that after the icon have disappeared, volume toastmessage doesn't show when changing volume..
i need to close the app, and immediately i get back headphones icon on the screen and volume controls notifications.
 
Upvote 0

HuZz

Member
Licensed User
yes... the only difference is obviously there's no headphone icon in status bar... it's like something is activated toghether with startrecording call and takes priority over all other task and commands.
 
Upvote 0

HuZz

Member
Licensed User
I've an updated to my problem... i have not formatted the phone yet, but i was trying some other solutions...
I noticed that, after startrecording sub call (which cause headphones to disconnect), if i disconnect and then connect again wired headphones, everything works fine...
Is there a way to enable/disable headphones via software ?
 
Upvote 0
Top