资源简介

百度语音识别Android SDK版本的demo, 语音语义的使用都有完整的demo

资源截图

代码片段和文件信息


package com.baidu.android.voicedemo;

import com.baidu.voicerecognition.android.Candidate;
import com.baidu.voicerecognition.android.VoiceRecognitionClient;
import com.baidu.voicerecognition.android.VoiceRecognitionClient.VoiceClientStatusChangeListener;
import com.baidu.voicerecognition.android.VoiceRecognitionConfig;

import android.os.Handler;
import android.support.v4.app.FragmentActivity;
import android.widget.EditText;
import android.widget.Toast;

import java.util.List;

/**
 * 使用底层API方式识别Demo,开发者可以定义UI交互
 * 
 * @author yangliang02
 */
public class ApiDemoActivity extends FragmentActivity {
    private ControlPanelFragment mControlPanel;

    private VoiceRecognitionClient mASREngine;

    /** 正在识别中 */
    private boolean isRecognition = false;

    /** 音量更新间隔 */
    private static final int POWER_UPDATE_INTERVAL = 100;

    /** 识别回调接口 */
    private MyVoiceRecogListener mListener = new MyVoiceRecogListener();

    /** 主线程Handler */
    private Handler mHandler;

    /**
     * 结果展示
     */
    private EditText mResult = null;

    /**
     * 音量更新任务
     */
    private Runnable mUpdateVolume = new Runnable() {
        public void run() {
            if (isRecognition) {
                long vol = mASREngine.getCurrentDBLevelMeter();
                mControlPanel.volumeChange((int) vol);
                mHandler.removeCallbacks(mUpdateVolume);
                mHandler.postDelayed(mUpdateVolume POWER_UPDATE_INTERVAL);
            }
        }
    };

    protected void onCreate(android.os.Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.api_demo_activity);
        mResult = (EditText) findViewById(R.id.recognition_text);
        mASREngine = VoiceRecognitionClient.getInstance(this);
        mASREngine.setTokenApis(Constants.API_KEY Constants.SECRET_KEY);
        mHandler = new Handler();
        mControlPanel = (ControlPanelFragment) (getSupportFragmentManager()
                .findFragmentById(R.id.control_panel));
        mControlPanel.setOnEventListener(new ControlPanelFragment.OnEventListener() {

            @Override
            public boolean onstopListening() {
                mASREngine.speakFinish();
                return true;
            }

            @Override
            public boolean onstartListening() {
                mResult.setText(null);
                VoiceRecognitionConfig config = new VoiceRecognitionConfig();
                config.setProp(Config.CURRENT_PROP);
                config.setLanguage(Config.getCurrentLanguage());
                config.enableVoicePower(Config.SHOW_VOL); // 音量反馈。
                if (Config.PLAY_START_SOUND) {
                    config.enableBeginSoundEffect(R.raw.bdspeech_recognition_start); // 设置识别开始提示音
                }
                if (Config.PLAY_END_SOUND) {
                    config.enableEndSoundEffect(R.raw.bdspeech_speech_end); // 设置识别结束提示音
                }
                config.setSampleRate(VoiceRecognitionConf

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       9549  2014-05-07 17:58  Baidu-Voice-SDK-Android-1.4.1\doc\allclasses-frame.html

     文件       8469  2014-05-07 17:58  Baidu-Voice-SDK-Android-1.4.1\doc\allclasses-noframe.html

     文件      12293  2014-05-07 17:58  Baidu-Voice-SDK-Android-1.4.1\doc\com\baidu\voicerecognition\android\BufferThreadRecorder.html

     文件      11643  2014-05-07 17:58  Baidu-Voice-SDK-Android-1.4.1\doc\com\baidu\voicerecognition\android\Candidate.html

     文件       4541  2014-05-07 17:58  Baidu-Voice-SDK-Android-1.4.1\doc\com\baidu\voicerecognition\android\class-use\BufferThreadRecorder.html

     文件       4420  2014-05-07 17:58  Baidu-Voice-SDK-Android-1.4.1\doc\com\baidu\voicerecognition\android\class-use\Candidate.html

     文件       4387  2014-05-07 17:58  Baidu-Voice-SDK-Android-1.4.1\doc\com\baidu\voicerecognition\android\class-use\Config.html

     文件       4420  2014-05-07 17:58  Baidu-Voice-SDK-Android-1.4.1\doc\com\baidu\voicerecognition\android\class-use\CsvWriter.html

     文件       4497  2014-05-07 17:58  Baidu-Voice-SDK-Android-1.4.1\doc\com\baidu\voicerecognition\android\class-use\ExternalRecorder.html

     文件       6753  2014-05-07 17:58  Baidu-Voice-SDK-Android-1.4.1\doc\com\baidu\voicerecognition\android\class-use\LocationSyncManager.html

     文件       4464  2014-05-07 17:58  Baidu-Voice-SDK-Android-1.4.1\doc\com\baidu\voicerecognition\android\class-use\MockPcmRecord.html

     文件      11234  2014-05-07 17:58  Baidu-Voice-SDK-Android-1.4.1\doc\com\baidu\voicerecognition\android\class-use\NoProGuard.html

     文件       6700  2014-05-07 17:58  Baidu-Voice-SDK-Android-1.4.1\doc\com\baidu\voicerecognition\android\class-use\ResourceParameters.html

     文件       6470  2014-05-07 17:58  Baidu-Voice-SDK-Android-1.4.1\doc\com\baidu\voicerecognition\android\class-use\ThreadRecorder.html

     文件       6642  2014-05-07 17:58  Baidu-Voice-SDK-Android-1.4.1\doc\com\baidu\voicerecognition\android\class-use\TokenManager.html

     文件       4398  2014-05-07 17:58  Baidu-Voice-SDK-Android-1.4.1\doc\com\baidu\voicerecognition\android\class-use\Utility.html

     文件       6660  2014-05-07 17:58  Baidu-Voice-SDK-Android-1.4.1\doc\com\baidu\voicerecognition\android\class-use\VoiceDataStorage.html

     文件       8026  2014-05-07 17:58  Baidu-Voice-SDK-Android-1.4.1\doc\com\baidu\voicerecognition\android\class-use\VoiceRecognitionClient.html

     文件       7940  2014-05-07 17:58  Baidu-Voice-SDK-Android-1.4.1\doc\com\baidu\voicerecognition\android\class-use\VoiceRecognitionClient.VoiceClientStatusChangeListener.html

     文件       7401  2014-05-07 17:58  Baidu-Voice-SDK-Android-1.4.1\doc\com\baidu\voicerecognition\android\class-use\VoiceRecognitionConfig.html

     文件      15728  2014-05-07 17:58  Baidu-Voice-SDK-Android-1.4.1\doc\com\baidu\voicerecognition\android\Config.html

     文件      12554  2014-05-07 17:58  Baidu-Voice-SDK-Android-1.4.1\doc\com\baidu\voicerecognition\android\CsvWriter.html

     文件      13177  2014-05-07 17:58  Baidu-Voice-SDK-Android-1.4.1\doc\com\baidu\voicerecognition\android\ExternalRecorder.html

     文件       9082  2014-05-07 17:58  Baidu-Voice-SDK-Android-1.4.1\doc\com\baidu\voicerecognition\android\LocationSyncManager.html

     文件      12616  2014-05-07 17:58  Baidu-Voice-SDK-Android-1.4.1\doc\com\baidu\voicerecognition\android\MockPcmRecord.html

     文件       6967  2014-05-07 17:58  Baidu-Voice-SDK-Android-1.4.1\doc\com\baidu\voicerecognition\android\NoProGuard.html

     文件       3026  2014-05-07 17:58  Baidu-Voice-SDK-Android-1.4.1\doc\com\baidu\voicerecognition\android\package-frame.html

     文件      10506  2014-05-07 17:58  Baidu-Voice-SDK-Android-1.4.1\doc\com\baidu\voicerecognition\android\package-summary.html

     文件       9030  2014-05-07 17:58  Baidu-Voice-SDK-Android-1.4.1\doc\com\baidu\voicerecognition\android\package-tree.html

     文件       8954  2014-05-07 17:58  Baidu-Voice-SDK-Android-1.4.1\doc\com\baidu\voicerecognition\android\package-use.html

............此处省略332个文件信息

评论

共有 条评论