-
PocketSphinxAndroidDemo下载
资源介绍
可以实现录音,有效率超过百分之九十九
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();
- 上一篇: 微信小程序源码-仿Apple Music
- 下一篇: 搜狗标准词库词典,txt格式,不含词频