Menu

Cannot listen 000000000.raw using Android Media Player

Help
2017-01-23
2017-03-07
  • JohnyProgrammer

    JohnyProgrammer - 2017-01-23

    I cannot listen to the file 000000000.raw on Android Media Player and what music player you are use to listen to .raw?

     
    • Nickolay V. Shmyrev

      You have to download audio to desktop and you can use audacity.

       
  • JohnyProgrammer

    JohnyProgrammer - 2017-01-25

    Thanks for your quick reply Nickolay.
    What is the sound format of the RAW file when recording the sound using an Android tablet with pocketsphinx? Is it possible to write Android Code to re-play it using Android Media directly or turn it into listenable sound format?

     
  • JohnyProgrammer

    JohnyProgrammer - 2017-01-25

    awesome, thanks

     
  • JohnyProgrammer

    JohnyProgrammer - 2017-01-27

    Does the attached raw find sound correct to you? It is too fast for me. What should I do to slow it down? One of my program requirement is speech recognition & record audio at the same time.
    Thanks

     
    • Nickolay V. Shmyrev

      Does the attached raw find sound correct to you?

      Yes

      It is too fast for me. What should I do to slow it down?

      Set proper sample rate

       
  • JohnyProgrammer

    JohnyProgrammer - 2017-01-30

    great, it is perfect, thanks

     
  • JohnyProgrammer

    JohnyProgrammer - 2017-03-03

    I have 2 questions:
    1 Is there any way that I can use both phonemes lm and static lm at the same time on android?
    2 Using pocketsphinx on android, can I play a raw audio fie to have the hypothesis instead of using the micro phone?

    My objective is to cooperate different models in order to evaluate a speech.
    Thanks.

     
  • JohnyProgrammer

    JohnyProgrammer - 2017-03-07

    I will try it . Thanks a lot.

     
  • JohnyProgrammer

    JohnyProgrammer - 2017-03-07

    I follow the link above and when I run the program, it fails at the line
    Config c= Decoder.defaultConfig();

    Config c = Decoder.defaultConfig();
    c.setString("-hmm", new File(assetsDir, "en-us-ptm").getCanonicalPath()); c.setString("-lm", new File(assetsDir, "4767.lm").getCanonicalPath());
    c.setString("-dict", new File(assetsDir, "4767.dic").getCanonicalPath());
    Decoder d = new Decoder(c);
    

    Error Message:

    E/art: No implementation found for long edu.cmu.pocketsphinx.PocketSphinxJNI.Decoder_defaultConfig() (tried Java_edu_cmu_pocketsphinx_PocketSphinxJNI_Decoder_1defaultConfig and Java_edu_cmu_pocketsphinx_PocketSphinxJNI_Decoder_1defaultConfig__)
    E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #1
                      Process: edu.cmu.sphinx.pocketsphinx, PID: 4598
                      java.lang.RuntimeException: An error occurred while executing doInBackground()
                          at android.os.AsyncTask$3.done(AsyncTask.java:318)
                          at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:354)
                          at java.util.concurrent.FutureTask.setException(FutureTask.java:223)
                          at java.util.concurrent.FutureTask.run(FutureTask.java:242)
                          at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:243)
                          at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
                          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
                          at java.lang.Thread.run(Thread.java:761)
                       Caused by: java.lang.UnsatisfiedLinkError: No implementation found for long edu.cmu.pocketsphinx.PocketSphinxJNI.Decoder_defaultConfig() (tried Java_edu_cmu_pocketsphinx_PocketSphinxJNI_Decoder_1defaultConfig and Java_edu_cmu_pocketsphinx_PocketSphinxJNI_Decoder_1defaultConfig__)
                          at edu.cmu.pocketsphinx.PocketSphinxJNI.Decoder_defaultConfig(Native Method)
                          at edu.cmu.pocketsphinx.Decoder.defaultConfig(Decoder.java:77)
                          at edu.cmu.pocketsphinx.demo.PocketSphinxActivity.setupRecognizerWithWav(PocketSphinxActivity.java:754)
                          at edu.cmu.pocketsphinx.demo.PocketSphinxActivity.access$100(PocketSphinxActivity.java:91)
                          at edu.cmu.pocketsphinx.demo.PocketSphinxActivity$1.doInBackground(PocketSphinxActivity.java:632)
                          at edu.cmu.pocketsphinx.demo.PocketSphinxActivity$1.doInBackground(PocketSphinxActivity.java:625)
                          at android.os.AsyncTask$2.call(AsyncTask.java:304)
                          at java.util.concurrent.FutureTask.run(FutureTask.java:237)
                          at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:243) 
                          at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133) 
                          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607) 
                          at java.lang.Thread.run(Thread.java:761) 
    

    What did I do wrong? Thanks

     
    • Nickolay V. Shmyrev

      You didn't load the jni library:

      static {
          System.loadLibrary("pocketsphinx_jni");
      }
      
       
  • JohnyProgrammer

    JohnyProgrammer - 2017-03-07

    It works great!!! Thanks!!!

     
  • JohnyProgrammer

    JohnyProgrammer - 2017-03-09

    Hi Nickolay,
    Is there a way to include <SIL> +SPN+... in hypothesis using Language model?
    Thanks

     

    Last edit: JohnyProgrammer 2017-03-09
    • Nickolay V. Shmyrev

      You can interate over segments and collect words, they should include fillers.

       
  • JohnyProgrammer

    JohnyProgrammer - 2017-03-10

    My bad , It works great!!! Many thanks

     

    Last edit: JohnyProgrammer 2017-03-10
  • JohnyProgrammer

    JohnyProgrammer - 2017-03-10

    Hi Nickolay,
    following https://github.com/cmusphinx/pocketsphinx-android
    I got

    External Native Build Issues
    Build command failed.
    Error while executing '/Users/tnguyen/Library/Android/sdk/cmake/3.6.3155560/bin/cmake' with arguments {-H/Users/tnguyen/Documents/myon/pocketsphinxSourceCode/pocketsphinx-android -B/Users/tnguyen/Documents/myon/pocketsphinxSourceCode/pocketsphinx-android/.externalNativeBuild/cmake/release/armeabi-v7a -GAndroid Gradle - Ninja -DANDROID_ABI=armeabi-v7a -DANDROID_NDK=/Users/tnguyen/Library/Android/sdk/ndk-bundle -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=/Users/tnguyen/Documents/myon/pocketsphinxSourceCode/pocketsphinx-android/.externalNativeBuild/cmake/release/obj/armeabi-v7a -DCMAKE_BUILD_TYPE=Release -DCMAKE_MAKE_PROGRAM=/Users/tnguyen/Library/Android/sdk/cmake/3.6.3155560/bin/ninja -DCMAKE_TOOLCHAIN_FILE=/Users/tnguyen/Library/Android/sdk/ndk-bundle/build/cmake/android.toolchain.cmake -DANDROID_NATIVE_API_LEVEL=14}
    -- Configuring done
    -- Generating done
    -- Build files have been written to: /Users/tnguyen/Documents/myon/pocketsphinxSourceCode/pocketsphinx-android/.externalNativeBuild/cmake/release/armeabi-v7a
    CMake Error at CMakeLists.txt:106 (add_library):
      Cannot find source file:
        build/generated-src/cpp/pocketsphinx_wrap.c
      Tried extensions .c .C .c++ .cc .cpp .cxx .m .M .mm .h .hh .h++ .hm .hpp
      .hxx .in .txx
    CMake Error: CMake can not determine linker language for target: pocketsphinx_jni
    Build command failed.
    Error while executing '/Users/tnguyen/Library/Android/sdk/cmake/3.6.3155560/bin/cmake' with arguments {-H/Users/tnguyen/Documents/myon/pocketsphinxSourceCode/pocketsphinx-android -B/Users/tnguyen/Documents/myon/pocketsphinxSourceCode/pocketsphinx-android/.externalNativeBuild/cmake/debug/armeabi-v7a -GAndroid Gradle - Ninja -DANDROID_ABI=armeabi-v7a -DANDROID_NDK=/Users/tnguyen/Library/Android/sdk/ndk-bundle -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=/Users/tnguyen/Documents/myon/pocketsphinxSourceCode/pocketsphinx-android/.externalNativeBuild/cmake/debug/obj/armeabi-v7a -DCMAKE_BUILD_TYPE=Debug -DCMAKE_MAKE_PROGRAM=/Users/tnguyen/Library/Android/sdk/cmake/3.6.3155560/bin/ninja -DCMAKE_TOOLCHAIN_FILE=/Users/tnguyen/Library/Android/sdk/ndk-bundle/build/cmake/android.toolchain.cmake -DANDROID_NATIVE_API_LEVEL=14}
    -- Configuring done
    -- Generating done
    -- Build files have been written to: /Users/tnguyen/Documents/myon/pocketsphinxSourceCode/pocketsphinx-android/.externalNativeBuild/cmake/debug/armeabi-v7a
    CMake Error at CMakeLists.txt:106 (add_library):
      Cannot find source file:
        build/generated-src/cpp/pocketsphinx_wrap.c
      Tried extensions .c .C .c++ .cc .cpp .cxx .m .M .mm .h .hh .h++ .hm .hpp
      .hxx .in .txx
    CMake Error: CMake can not determine linker language for target: pocketsphinx_jni
    

    What am I missing? Thanks

     

    Last edit: JohnyProgrammer 2017-03-10
    • Nickolay V. Shmyrev

      You have some problem with swig it seems, make sure that swig is installed and try to run the gradle swig command manually.

       
  • JohnyProgrammer

    JohnyProgrammer - 2017-03-22

    Thanks, It is working on gradle swig command manually.

     for (Segment seg : d.seg()) {
                System.out.println(seg.getStartFrame());
                System.out.println(seg.getWord());
                System.out.println(seg.getEndFrame());
            }
    

    Can I confim that each frame is 10ms? Thanks.

     
    • Nickolay V. Shmyrev

      Can I confim that each frame is 10ms? Thanks.

      This is correct.

       
  • JohnyProgrammer

    JohnyProgrammer - 2017-05-18

    Hi Nickolay,
    My co-worker on iOS is struggling in assess a recorded files. He uses pocketsphinx directly a not OpenEar and has achieved the realtime speech recognition. Do you have equivalent code bellow in Objective-C?
    Thanks.

    Config c = Decoder.defaultConfig();
    c.setString("-hmm", "../../model/en-us/en-us");
    c.setString("-lm", "../../model/en-us/en-us.lm.dmp");
    c.setString("-dict", "../../model/en-us/cmudict-en-us.dict");
    Decoder d = new Decoder(c);
    
    URL testwav = new URL("file:../../test/data/goforward.wav");
    FileInputStream stream = new FileInputStream(new File(testwav)));
    
    d.startUtt();
    byte[] b = new byte[4096];
    try {
        int nbytes;
        while ((nbytes = stream.read(b)) >= 0) {
            ByteBuffer bb = ByteBuffer.wrap(b, 0, nbytes);
    
            // Not needed on desktop but required on android
            bb.order(ByteOrder.LITTLE_ENDIAN);
    
            short[] s = new short[nbytes/2];
            bb.asShortBuffer().get(s);
            d.processRaw(s, nbytes/2, false, false);
        }
    } catch (IOException e) {
        fail("Error when reading goforward.wav" + e.getMessage());
    }
    d.endUtt();
    System.out.println(d.hyp().getHypstr());
    for (Segment seg : d.seg()) {
        System.out.println(seg.getWord());
    }
    
     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.