Android Example Offline Continuous Speech Recognition

Discussion in 'Tutorials & Examples' started by stevel05, Jul 15, 2014.

  1. stevel05

    stevel05 Expert Licensed User

    This is a proof of concept port of CMU PocketSphinx for Android demo app.

    It's written in B4a using JavaObject to access the PocketSphinx library.

    There is a wealth of information on the website : http://cmusphinx.sourceforge.net/ on tailoring the dictionaries, grammar and models.

    If you want to control simple tasks or games with a few keywords, it doesn't look like it would be too difficult to implement. I'll let you know in a few weeks when I have integrated it into a current project.

    I've used B4a 3.82, so if you're using an older version you will have to change some of the JavaObject calls relating to the array definitions i.e. change them to Array As Object(..) instead of Array(...)

    In line with recommendations from CMU the setup copies the files from the assets directory to the apps default directory if it's not there, or the MD5 ID has changed. This is done in a thread in a separate class that has the #ExcludeFormDebugger: True directive, so you should be able to debug the rest of the app.



    Download and unzip the library file and copy it to your additional libraries folder.

    The project is located on my Google Drive as, with the dictionaries, it is too large (about 10 MB) to upload to the forum you can download it here : SpeechRecognizerContinuous


    It's a bit confusing to download if you haven't done it before (as I just found out), click on the file, then there will be a download icon somewhere at the top middle of the screen.

    The copyright.txt file contains the original copyright notice from the demo app.


    Have fun, and let me know how you get on with it.
     

    Attached Files:

    Last edited: Jul 16, 2014
  2. brelto85

    brelto85 Active Member Licensed User

    OMG!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
     
  3. brelto85

    brelto85 Active Member Licensed User

    i try it immediately!!
     
  4. bparent

    bparent Member Licensed User

    This can be big. Look forward to your results from integrating this into your project.
     
  5. stevel05

    stevel05 Expert Licensed User

    Yes, unfortunately the language choice is a bit limited, but you can always create your own, if you have the time.
     
  6. petr4ppc

    petr4ppc Active Member Licensed User

    Dear friend,

    I am trying your example with version B4A 3.50
    I change Array() to ArrayAsObject
    If I run the App I get black screen and if I say something (for example "wakeup") - nothing happen

    I found after short time that the mistakes are because of my version of B4A.

    Thank you
    p4ppc
     
    Last edited: Aug 12, 2014
  7. aaronk

    aaronk Well-Known Member Licensed User

    I am running your demo, and when I run the app is says to say "Computer" but nothing happens. (doing this in debug mode)

    If I run it in release mode, it comes up saying:
    "An Error has occurred in Sub: java.lang.RuntimeException: Thread.Start : Sub configurerecognizer not found! Continue?"

    I have copied the attached libarary to my libararys directory. (C:\Program Files\Anywhere Software\Basic4android\Libraries)
    And I am running the code from your Google Drive

    Am I doing something wrong ?
     
  8. stevel05

    stevel05 Expert Licensed User

    When you open the project you should see three modules, Main, SetupRecognizer and SpeechRecognizer. The ConfigureRecognizer sub is in SetupRecognizer. Do you see the three Modules and the Sub?
     
  9. petr4ppc

    petr4ppc Active Member Licensed User

    steveI05 and dear friends,

    If I run app, everything is OK, then if I stop the app (pause mode of app) and then I run app again, the voice recognition is not running.....

    How can I run again the recognition if the app is starting again (wakeup-resume)? Here is not function START or something else....

    how can I start voice recognition again, please?

    Thank you very much
    Best regards
    p4ppc
     
    Last edited: Aug 25, 2014
  10. stp

    stp Member Licensed User

    Sub Globals
    Dim pw As PhoneWakeState
    End Sub

    Sub Activity_Resume
    pw.KeepAlive(True)
    End Sub

    Sub Activity_Pause (UserClosed As Boolean)
    If UserClosed Then
    pw.ReleaseKeepAlive
    ' release if user closes the app
    End If
    End Sub



    on pause you can use pw.KeepAlive(True)
     
  11. petr4ppc

    petr4ppc Active Member Licensed User

    Dear FRIENDS, STP

    thank you very much...
    I think, that here are not troubles with going to sleep...

    In Sub Activity_Pause (in STEVI05 program) is this code:
    Code:
    SR.Stop
    this code stopped the voice recognition when the app is in PAUSE mode
    how can I start voice recognition again - from Sub Activity_Resume, please?

    I hope, that it is not bad or dumb question

    Please ,help me,
    Thank you very much
    p4ppc
     
    Last edited: Aug 28, 2014
  12. petr4ppc

    petr4ppc Active Member Licensed User

    Please, friends,

    do you have some tips?
    Or is it dumb question form my side? = how can I start voice recognition again - from Sub Activity_Resume, please?

    i can stop voice recognition with this: SR.Stop
    How can I start it again?

    Thank you
    p4ppc
     
  13. stevel05

    stevel05 Expert Licensed User

    I've been away so haven't responded sooner, I'll take a look at it this evening.
     
  14. petr4ppc

    petr4ppc Active Member Licensed User

    Thank you very much stevel05....
     
  15. petr4ppc

    petr4ppc Active Member Licensed User

    steveI05 -

    Have you some new informations, please?
    Can you help us, please?

    Thank you
    p4ppc
     
  16. David Hawkins

    David Hawkins Member Licensed User

    Hi I am getting this error when trying to run your project. The Sub is there.

    java.lang.RuntimeException: Thread.Start : Sub configurerecognizer not found!

    Regards

    David
     
  17. Erel

    Erel Administrator Staff Member Licensed User

    Are you running it in obfuscation mode?
     
  18. David Hawkins

    David Hawkins Member Licensed User

  19. David Hawkins

    David Hawkins Member Licensed User

    now working in release mode fine, thank you.
     
  20. lemonisdead

    lemonisdead Well-Known Member Licensed User

    Doesn't work for me too even in release mode and obfuscated. I have seen that at line 17 of SetupRecognizer, the initialize is written initialise and I am provided with an error

    [​IMG]

    and it generates an error while executed on KitKat 4.4.4 (Nexus 5)

     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice