在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 教程/ Android/ 語音識別
多分辨率適配常用目錄
Android 開發(fā)環(huán)境(Eclipse+ADT+Android 5.0)
Android 原型設計工具探索
Makefile 快速入門
Android Studio的NDK開發(fā)
人臉檢測-靜態(tài)
getprop 與 dumpsys 命令
Maven 編譯開源二維碼掃描項目 zxing
畫布 Canvas
組合控件
Linux 下的模擬器硬件加速
讀取 Excel
android.hardware.camera2 使用指南
橫豎屏切換
Ubuntu 下切換 JDK 版本
拍照和錄像 with Camera
文本與布局
按鈕控制 ViewPager 的左右翻頁
用 TableLayout 偽裝表格顯示數(shù)據(jù)
Preference Activity 使用詳解
模擬器如何重啟?試試 Genymotion!
獲得屏幕物理尺寸、密度及分辨率
語音識別
了解 native activity
Android Studio 導入第三方類庫、jar 包和 so 庫
啟動另一個 App/apk 中的 Activity
APK 簽名
兩個開源的圖表/報表控件
android studio 導出 jar 包(Module)并獲得手機信息
圖片的 Base64 編解碼
混淆與反編譯
Android Studio 和 Gradle
Android 5.1 SDK 下載與配置
persistableMode 與 Activity 的持久化
adb 取出安裝在手機中的 apk
Android Studio 中的源代碼管理
Handler 使用中可能引發(fā)的內(nèi)存泄漏

語音識別

Google 的語音識別是有目共睹的,所以 Android 上面也是沾了大光了,用起來簡單至極。

過程如下:

1、啟動語音識別 Activity

2、這里處理語音(傳到 google 服務器處理)

3、結(jié)果以 Acitivity 的結(jié)果返回(onActivityResult)

主要用到的類為 android.speech.RecognizerIntent

下面的例子參考了 API Demo。

    package com.linc;  

    import java.util.ArrayList;  
    import java.util.List;  

    import android.app.Activity;  
    import android.content.Intent;  
    import android.content.pm.PackageManager;  
    import android.content.pm.ResolveInfo;  
    import android.os.Bundle;  
    import android.speech.RecognizerIntent;  
    import android.view.View;  
    import android.view.View.OnClickListener;  
    import android.widget.Button;  
    import android.widget.TextView;  

    public class VoiceRecognitionDemoActivity extends Activity {  
        private static final String TAG = "VoiceRecognition";  
        private static final int VOICE_RECOGNITION_REQUEST_CODE = 1234;  

        private TextView textView;  
        private Button button;  
        @Override  
        public void onCreate(Bundle savedInstanceState) {  
            super.onCreate(savedInstanceState);  
            setContentView(R.layout.main);  

            initWidget();  

            // Check to see if a recognition activity is present  
            PackageManager pm = getPackageManager();  
            List<ResolveInfo> activities = pm.queryIntentActivities(  
                    new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH), 0);  
            if (activities.size() != 0) {  
                button.setOnClickListener(new OnClickListener() {  
                    @Override  
                    public void onClick(View v) {  
                        startVoiceRecognitionActivity();  
                    }  
                });  
            } else {  
                button.setEnabled(false);  
                button.setText("Recognizer not present");  
            }  
        }  

        private void initWidget()  
        {  
            textView = (TextView)findViewById(R.id.tv);  
            button = (Button)findViewById(R.id.btn);  
        }  

        /** 
         * Fire an intent to start the speech recognition activity. 
         */  
        private void startVoiceRecognitionActivity() {  
            Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);  

            // Display an hint to the user about what he should say.  
            intent.putExtra(RecognizerIntent.EXTRA_PROMPT, "請說標準普通話");//注意不要硬編碼  

            // Given an hint to the recognizer about what the user is going to say  
            intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,  
                    RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);  

            // Specify how many results you want to receive. The results will be sorted  
            // where the first result is the one with   higher confidence.  
            intent.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS, 5);//通常情況下,第一個結(jié)果是最準確的。  

            startActivityForResult(intent, VOICE_RECOGNITION_REQUEST_CODE);  
        }  

        @Override  
        protected void onActivityResult(int requestCode, int resultCode, Intent data) {  
            if (requestCode == VOICE_RECOGNITION_REQUEST_CODE && resultCode == RESULT_OK) {  
                // Fill the list view with the strings the recognizer thought it could have heard  
                ArrayList<String> matches = data.getStringArrayListExtra(  
                        RecognizerIntent.EXTRA_RESULTS);  
                StringBuilder stringBuilder = new StringBuilder();  
                int Size = matches.size();   
                for(int i=0;i<Size;++i)  
                {  
                    stringBuilder.append(matches.get(i));  
                    stringBuilder.append("\n");  
                }  
                textView.setText(stringBuilder);  
            }  

            super.onActivityResult(requestCode, resultCode, data);  
       }  
    }  

結(jié)論:

在 wifi(家里的,1兆帶寬)狀態(tài)下,識別速度飛快。

語音包是買手機時預裝好的。

識別率很高。中文、英文、數(shù)字都能很好的識別。

用手機的 gprs,效果不盡如人意。幾次識別都用了30秒左右的時間,體驗很糟。