pocketsphinx android,pocketsphinx-android

这个项目是Pocketsphinx的一个封装器,提供了高级接口来识别麦克风输入。插件生成

你需要 SWIG,Gradle和 Android NDK来为Android构建一个可以发布的pocketsphinx文件。 最好使用最新版本。

你需要检查 sphinxbase。pocketsphinx和 pocketsphinx-android并把它们放在同一文件夹中。Root folder

_pocketsphinx

_sphinxbase

_pocketsphinx-android

旧版本可能与最新 pocketsphinx-android不兼容,因此你需要确保使用最新版本。 你可以使用以下命令从仓库中签出:git clone https://github.com/cmusphinx/sphinxbase

git clone https://github.com/cmusphinx/pocketsphinx

git clone https://github.com/cmusphinx/pocketsphinx-android

export POCKETSPHINX_HOME=`pwd`/pocketsphinx

export SPINXBASE_HOME=`pwd`/sphinxbase

签出后,需要更新项目 root 中的文件'本地。属性'并定义以下属性:sdk.dir - Android SDK的路径

ndk.dir - Android NDK路径

例如:sdk.dir=/Users/User/Library/Android/sdk

ndk.dir=/Users/User/Library/Android/sdk/ndk-bundle

一切就绪后,运行 ./gradlew build。 它将在构建/输出中创建 pocketsphinx-android-5prealpha-release.aar 和 pocketsphinx-android-5prealpha-debug.aar。使用库

将 bintray Maven 添加到存储库allprojects {

repositories {

maven {

url"https://dl.bintray.com"

}

jcenter()

google()

}

}

将 pocketsphinx-android 添加到依赖项dependencies {

implementation 'edu.cmu.pocketsphinx.android:pocketsphinx-android:5prealpha@aar'

}本地使用库

库作为android归档AAR分发。 你可以像通常使用 Android Studio 或者直接在gradle中将它添加到项目中dependencies {

compile (name:'pocketsphinx-android-debug', ext:'aar')

}

repositories {

flatDir {

dirs 'libs'

}

}

有关使用情况的详细信息,请参阅wiki页面:

可以实现录音,有效率超过百分之九十九 package edu.cmu.pocketsphinx.demo; import java.util.Date; import android.app.Activity; import android.app.ProgressDialog; import android.content.Intent; import android.os.Bundle; import android.view.LayoutInflater; import android.view.MotionEvent; import android.view.View; import android.view.View.OnTouchListener; import android.widget.Button; import android.widget.EditText; import android.widget.TextView; public class PocketSphinxIntent extends Activity implements OnTouchListener, RecognitionListener { static { System.loadLibrary("pocketsphinx_jni"); } public static final String EXTRA_RESULTS = "PockectSphinxExtraResults"; /** * Recognizer task, which runs in a worker thread. */ RecognizerTask rec; /** * Thread in which the recognizer task runs. */ Thread rec_thread; /** * Time at which current recognition started. */ Date start_date; /** * Number of seconds of speech. */ float speech_dur; /** * Are we listening? */ boolean listening; /** * Progress dialog for final recognition. */ ProgressDialog rec_dialog; /** * Performance counter view. */ TextView performance_text; /** * Editable text view. */ EditText edit_text; Intent intent; /** * Respond to touch events on the Speak button. * * This allows the Speak button to function as a "push and hold" button, by * triggering the start of recognition when it is first pushed, and the end * of recognition when it is released. * * @param v * View on which this event is called * @param event * Event that was triggered. */ public boolean onTouch(View v, MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: start_date = new Date(); this.listening = true; this.rec.start(); break; case MotionEvent.ACTION_UP: Date end_date = new Date();
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值