Android Example Offline Continuous Speech Recognition

youjunjer

Member
Licensed User
Longtime User
dear stevel05
I have try your code by thread:
https://www.b4x.com/android/forum/threads/offline-continuous-speech-recognition.42898/
But the event alwayse do Case "onBeginningOfSpeech" and Case "onEndOfSpeech".No any recognition text output?
Is there any more information about this API?

That I want to make a machine like "echo", it will wake up on a special word like "computer" or "master".
And then I can use google Speech Recognition api to make some voice command.
 

stevel05

Expert
Licensed User
Longtime User
This was done 4 years ago, I'm sure Pocket sphinx has moved on since then, the latest info can be found here http://cmusphinx.sourceforge.net/. I'm afraid I haven't used it since the original post so haven't kept up to date with improvements.
 

Sargasso

New Member
Licensed User
Longtime User
Hi!
Im using the latest B4A (7.80) and Android 7+.
And I was searching for "exactly this". An offline (or online) Speech recognition for an app. For me Im going to use it as... Say a word or number and the app check if its correct! So I dont need to know so many words. (But hopefully in many languages. )

So the question: What do you think about this? Or do anyone have something else that's newer and better for 2018?
(I was thinking about starting a new thread but I saw that you have wrote in this thread today so..)

THanks for any idea!
 

DonManfred

Expert
Licensed User
Longtime User
I was thinking about starting a new thread
From the forum Guidelines...

 

petr4ppc

Well-Known Member
Licensed User
Longtime User
Dear stevel05,

After some time I saw your answer (your update of Cont.Speech.Rec.). Thank you so much for this.
I am trying your project and I get:
"An error has occured in Sub:setuprecognizer ResumableSub.ConfigureRecognizerresume(java line: 101) _keyphrase not found" Continue? Yes-no

If I click on YES, I see only white screen and then nothing happen (I am trying to say : computer, etc)..

I am trying it with Android 11, Manifest editor: targetsdkversion:29 (or 30)
android.jar, SDK=30

Please very much, do you know where I am doing mistake?
Best regards and thank you very much,
p4ppc
 

stevel05

Expert
Licensed User
Longtime User
Sorry, this is not an error I am familiar with, and don't have an android 11 device to test it on. Does anyone recognise the error?
 

petr4ppc

Well-Known Member
Licensed User
Longtime User
Thank you for answer stevel05. For certain I am sending full error (android sdk 30):

and android sdk 28(here I have not installed all components I think):

All errors are detected here:
B4X:
    mRecognizer = Setup.RunMethodJO("defaultSetup",Null) _
    .RunMethodJO("setAcousticModel",Array(JavaFile(ModelsDir,"hmm/en-us-semi"))) _
    .RunMethodJO("setDictionary",Array(JavaFile(ModelsDir,"dict/cmu07a.dic"))) _    
    .RunMethodJO("setKeywordThreshold",Array(Val)) _
    .Runmethod("getRecognizer",Null)
    Log ("cr4")
    'Create Keyword-activation search
   
    Dim ModuleJO As JavaObject = mModule
    Log ("cr41 ***** here")
    mRecognizer.RunMethod("addKeyphraseSearch",Array(ModuleJO.GetField("_kws_search"), ModuleJO.GetField("_keyphrase")))
    Log ("cr5 *****")
    'Create Grammar based searches
    mRecognizer.RunMethod("addGrammarSearch",Array(ModuleJO.GetField("_menu_search"),JavaFile(ModelsDir,"grammar/menu.gram")))
    mRecognizer.RunMethod("addGrammarSearch",Array(ModuleJO.GetField("_digits_search"),JavaFile(ModelsDir,"grammar/digits.gram")))
    mRecognizer.RunMethod("addNgramSearch",Array(ModuleJO.GetField("_forecast_search"),JavaFile(ModelsDir,"lm/weather.dmp")))
I am using Android 11, tested with Android SDK 28 and 30, B4A 10.70
Best regards
p4ppc
 
Last edited:

stevel05

Expert
Licensed User
Longtime User
OK it looks like you are running in obsfuscated mode, you could try changing the references to KEYPHRASE to KEY_PHRASE, including the JavaObject call in the SetupRecognizer module:

B4X:
mRecognizer.RunMethod("addKeyphraseSearch",Array(ModuleJO.GetField("_kws_search"), ModuleJO.GetField("_key_phrase")))
 

petr4ppc

Well-Known Member
Licensed User
Longtime User

Dear Stevel05, thank you very much for your advice. In release mode is everything ok, as you wrote.
Best regards
p4ppc
 

Beja

Expert
Licensed User
Longtime User
Hi Steve,

I tried the example but couldn't have it running.. (unfortunately stopped....)
This is the logs:

SpeechRecognizer - 49: Not all code paths return a value. (warning #2)
File 'cmu07a.dic' is not used. (warning #15)
File 'digits.gram' is not used. (warning #15)
File 'feat.params' is not used. (warning #15)
File 'mdef' is not used. (warning #15)
File 'means' is not used. (warning #15)
File 'menu.gram' is not used. (warning #15)
File 'noisedict' is not used. (warning #15)
File 'readme' is not used. (warning #15)
File 'sendump' is not used. (warning #15)
File 'transition_matrices' is not used. (warning #15)
File 'variances' is not used. (warning #15)
File 'weather.dmp' is not used. (warning #15)
Library 'Reflection' is not used. (warning #32)

I set the mic permission.
Any meaning appreciated
 

stevel05

Expert
Licensed User
Longtime User
Updated link to project on Google drive in first post due to their change in security.
 

stevel05

Expert
Licensed User
Longtime User
Sorry @Beja, I missed your post, did you get it running?
 

stevel05

Expert
Licensed User
Longtime User
I have updated the link to my google drive as it was blocked due to a security update and I had a request for it. Please note that this is a very old project if it works for you then great, but I will not be able to support it.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…