Android Question [B4XPages] xSpeechRecognizer not working (but working in Standard B4A)

Mike1970

Well-Known Member
Licensed User
Longtime User
hi everyone, i just converted a project from b4a standard to b4xpages.
everything seems to be working, except for the xSpeechRecognizer that in the Standard project works, and in the b4xpages version not.

When i click the button to start the listening this check fails:
B4X:
        If Obj_speech.IsRecognitionAvailable Then '<------------ here'
            'Turn it on
            Obj_speech.Start
              
            'Start listening
            Obj_speech.StartListening
            Sleep(50)
            SetState(False)

        Else
            MsgboxAsync("No Recognizer", "Error")
        End If


I think the problem is here
B4X:
Private Sub B4XPage_Created (Root1 As B4XView)
    ...
  
    Dim ok As Boolean = False
    Dim rp As RuntimePermissions
    Do While Not(ok)
        rp.CheckAndRequest(rp.PERMISSION_RECORD_AUDIO)
        Wait For Activity_PermissionResult (Permission As String, Result As Boolean)
        If Not(Result) Then
            Msgbox2Async("Devi acconsentire per poter fare il test", "Consenti l'accesso", "Ok", "", "", Null, False)
            Wait For Msgbox_Result (ResultMsg As Int)
        Else
            ok = True
        End If
    Loop
    'Obj_speech.Initialize(Me, "Event_obj_speech", 0, 0) '<----- Tried also like so
    Obj_speech.Initialize(B4XPages.GetNativeParent(Me), "Event_obj_speech", 0, 0) '<-------------------------- HERE
End Sub

The library is this:

Thanks in advance
 

Mike1970

Well-Known Member
Licensed User
Longtime User
The first thing that I noticed:
B4X:
Wait For Activity_PermissionResult (Permission As String, Result As Boolean)
should be:
B4X:
Wait For B4Xpage_PermissionResult (Permission As String, Result As Boolean)
Yes it was that :rolleyes:, despite in the settings the record audio authorization was enabled🤷‍♂️
 
Upvote 0
Top