iOS Question Problem with B4i speechrecogniton and TTS

rboeck

Well-Known Member
Licensed User
Today i tried to use a combination of both technologies; when i first started the app, TTS was working. When i used speechrecognition, all further TTS outputs were surpressed, but i didnt get any error.
My speaker was also not muted, other apps worked just fine. Any ideas?
 

rboeck

Well-Known Member
Licensed User
I made a sample, but now i can see a crash by running Speech.Startrecording(True); maybe this is a step to the solution.
New version of sample included - code corrected, but problem exists further.
Speak button works for me, as long i dont use 'start recording'.
 

Attachments

Last edited:

JanPRO

Well-Known Member
Licensed User
Hi,

there are two big mistakes in your code:
The Speech & ActivityIndicator objects were not initilaized.
Change this and check whether the SetLanguage method of Speech returns true or false.

Jan
 

JanPRO

Well-Known Member
Licensed User
Hi,

as Erel already guess, there is a problem with the audio session setting. You need to change the category of the shared audio session before using TTS/STT:

B4X:
'When using TTS use SetCategory(False)
Sub SetCategory(Record As Boolean)
    Dim NaObj As NativeObject = Me
    NaObj.RunMethod("setCategory:",Array(Record))
  
    #If OBJC
    -(void)setCategory:(BOOL)B{
        AVAudioSession* AS = [AVAudioSession sharedInstance];
        if (B){
            [AS setCategory:AVAudioSessionCategoryRecord error:nil];
            [AS setMode:AVAudioSessionModeMeasurement error:nil];
            [AS setActive:true withOptions:AVAudioSessionSetActiveOptionNotifyOthersOnDeactivation error:nil];
        }else{
            [AS setCategory:AVAudioSessionCategoryPlayback error:nil];
            [AS setMode:AVAudioSessionModeDefault error:nil];
        }
    }
    #End If
End Sub
Attached you can find the modified example.

Jan
 

Attachments

Last edited:
Top