Android App Offline Chinese Speech Recognition PocketSphinx (Free~)

This article focuses on the application of Chinese speech recognition

Table of contents

foreword

1. Well-known demos that are not recommended

1. Official demo PocketSphinx 

(https://github.com/cmusphinx/pocketsphinx-android-demo)

2. Crystalyf's demo

(Android PocketSphinx offline speech recognition integration summary_Crystal_xing's blog-CSDN blog_pocketsphinx recognition rate)

2. Recommended demo

1. eson-yunfei demo

(GitHub - eson-yunfei/PocketSphinxDemo: PocketSphinx Android version usage example)

2. Edit entry

3. Code usage:

4. Effect demonstration:

Summarize


foreword

       In view of the sudden whim of the stingy boss, he wanted to try to add a voice control function without spending money, thinking that it would cost money to buy electronic hardware and make molds, and the software would not cost money. So I have been searching on Baidu for the voice recognition function. IFLYTEK, the voice leader, needs to charge a fee. I was struggling to find how to find a demo to deal with the boss. I finally found the magical PocketSphinx in the morning  .

1. Well-known demos that are not recommended

1. Official demo  PocketSphinx 

(https://github.com/cmusphinx/pocketsphinx-android-demo)

      Reason for not recommending: Our purpose is to recognize Mandarin Chinese. Unfortunately, the official Android demo has a drawback. Using Chinese as a keyword will cause an error and crash. The reason is probably that Chinese has more bytes than English.

        If you have the ability, you can download the source code yourself, then modify the number of bytes, and recompile.

2. Crystalyf 's demo

( Android PocketSphinx offline speech recognition integration summary_Crystal_xing's blog-CSDN blog_pocketsphinx recognition rate )

      Reason for not recommending: The demo is downloaded and can be run on a mobile phone, and can be recognized in Mandarin. However, due to the problem of the Android version, an error will be reported when the so file is imported into your own project. The targetSdk must be below 23. The solution is to reduce the version or recompile the source code

        (Thank you very much for the blog post of this great god, with detailed information, let me know that this library is available).

2. Recommended demo

1.  eson-yunfei demo

( GitHub - eson-yunfei/PocketSphinxDemo: PocketSphinx Android version usage example )

        Thanks to this great god, let me see the dawn. After testing, it can run on a higher version of Android. You only need to put the corresponding files and codes in your own project, as shown in the picture below. My project

Among them, build.gradle remember to add the import of jni:

    defaultConfig {
     .....
        ndk {
            abiFilters "armeabi", "armeabi-v7a"
        }
    }

    dependencies {

    .......
    implementation(fileTree(dir: 'libs', include: ['*.jar']))
    implementation files('libs/pocketsphinx-android-5prealpha-nolib.jar')
    }
ant.importBuild 'assets.xml'
preBuild.dependsOn(list, checksum)
clean.dependsOn(clean_assets)

2. Edit entry

       For details on how to edit entries, please refer to https://www.jianshu.com/p/4310ae932fdd

        1. Download the pronunciation table of Mandarin (note that the demo uses the version without phonetic symbols, that is, the old version)

        下载 CMU Sphinx - Browse /Acoustic and Language Models/Archive/Mandarin at SourceForge.net

的zh_broadcastnews_utf8.dic

         2. Change the entry file in your own project that has been transplanted

       Change voice.dic and zh_test.gram

        According to the original format, compare the pinyin in the file downloaded in the previous step, such as in my project

​ 

3. Code usage:

        Call startRecord() of the PocketSphinxUtil class to start the voice, stopRecord ends, and the interface returns a string array after the end

4. Effect demonstration:

When I say "Hello, Zhang San", there is a return value after the end


Summarize

       The offline speech recognition, after testing, is not very accurate, and when there are many people, it can recognize other words.

        But it’s free, highly integrated, easy to use, and can recognize both Chinese and English, so what bicycle do you need?

        If you want to recognize Mandarin Chinese, you can use the method in this article, only English is required, and the latest official version is best.

        Willing to spend money to suggest using mainstream Xunfei or Baidu services is the kingly way.
 

Guess you like

Origin blog.csdn.net/qq_15260099/article/details/127032874