成人免费xxxxx在线视频软件_久久精品久久久_亚洲国产精品久久久_天天色天天色_亚洲人成一区_欧美一级欧美三级在线观看

Android輕松實(shí)現(xiàn)語音識(shí)別

移動(dòng)開發(fā) Android
iphone好像永遠(yuǎn)都在和Android相比較,本文是Android系統(tǒng)的語音識(shí)別。

蘋果的iphone 有語音識(shí)別用的是Google 的技術(shù),做為Google 力推的Android 自然會(huì)將其核心技術(shù)往Android 系統(tǒng)里面植入,并結(jié)合google 的云端技術(shù)將其發(fā)揚(yáng)光大。

所以Google Voice Recognition在Android 的實(shí)現(xiàn)就變得極其輕松。

[[31167]]

語音識(shí)別,借助于云端技術(shù)可以識(shí)別用戶的語音輸入,包括語音控制等技術(shù),下面我們將利用Google 提供的Api 實(shí)現(xiàn)這一功能。

功能點(diǎn)為:通過用戶語音將用戶輸入的語音識(shí)別出來,并打印在列表上。

功能界面如下:

用戶通過點(diǎn)擊speak按鈕顯示界面:

用戶說完話后,將提交到云端搜索:

在云端搜索完成后,返回打印數(shù)據(jù):

 

#p#

完整的代碼如下:

  1. /*   
  2.  * Copyright (C) 2008 The Android Open Source Project  
  3.  *  
  4.  * Licensed under the Apache License, Version 2.0 (the "License");  
  5.  * you may not use this file except in compliance with the License.  
  6.  * You may obtain a copy of the License at  
  7.  *  
  8.  *      http://www.apache.org/licenses/LICENSE-2.0  
  9.  *  
  10.  * Unless required by applicable law or agreed to in writing, software  
  11.  * distributed under the License is distributed on an "AS IS" BASIS,  
  12.  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  
  13.  * See the License for the specific language governing permissions and  
  14.  * limitations under the License.  
  15.  */  
  16. package com.example.android.apis.app;  
  17. import com.example.android.apis.R;  
  18. import android.app.Activity;  
  19. import android.content.Intent;  
  20. import android.content.pm.PackageManager;  
  21. import android.content.pm.ResolveInfo;  
  22. import android.os.Bundle;  
  23. import android.speech.RecognizerIntent;  
  24. import android.view.View;  
  25. import android.view.View.OnClickListener;  
  26. import android.widget.ArrayAdapter;  
  27. import android.widget.Button;  
  28. import android.widget.ListView;  
  29. import java.util.ArrayList;  
  30. import java.util.List;  
  31. /**  
  32.  * Sample code that invokes the speech recognition intent API.  
  33.  */  
  34. public class VoiceRecognition extends Activity implements OnClickListener {     
  35.     private static final int VOICE_RECOGNITION_REQUEST_CODE = 1234;  
  36.       
  37.     private ListView mList;  
  38.  
  39.     /**  
  40.      * Called with the activity is first created.  
  41.      */  
  42.     @Override  
  43.     public void onCreate(Bundle savedInstanceState) {  
  44.         super.onCreate(savedInstanceState);  
  45.  
  46.         // Inflate our UI from its XML layout description.  
  47.         setContentView(R.layout.voice_recognition);  
  48.  
  49.         // Get display items for later interaction  
  50.         Button speakButton = (Button) findViewById(R.id.btn_speak);  
  51.           
  52.         mList = (ListView) findViewById(R.id.list);  
  53.  
  54.         // Check to see if a recognition activity is present  
  55.         PackageManager pm = getPackageManager();  
  56.         List<ResolveInfo> activities = pm.queryIntentActivities(  
  57.                 new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH), 0);  
  58.         if (activities.size() != 0) {  
  59.             speakButton.setOnClickListener(this);  
  60.         } else {  
  61.             speakButton.setEnabled(false);  
  62.             speakButton.setText("Recognizer not present");  
  63.         }  
  64.     }  
  65.     /**  
  66.      * Handle the click on the start recognition button.  
  67.      */  
  68.     public void onClick(View v) {  
  69.         if (v.getId() == R.id.btn_speak) {  
  70.             startVoiceRecognitionActivity();  
  71.         }  
  72.     }  
  73.     /**  
  74.      * Fire an intent to start the speech recognition activity.  
  75.      */  
  76.     private void startVoiceRecognitionActivity() {  
  77.         Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);  
  78.         intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,  
  79.                 RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);  
  80.         intent.putExtra(RecognizerIntent.EXTRA_PROMPT, "Speech recognition demo");  
  81.         startActivityForResult(intent, VOICE_RECOGNITION_REQUEST_CODE);  
  82.     }  
  83.     /**  
  84.      * Handle the results from the recognition activity.  
  85.      */  
  86.     @Override  
  87.     protected void onActivityResult(int requestCode, int resultCode, Intent data) {  
  88.         if (requestCode == VOICE_RECOGNITION_REQUEST_CODE && resultCode == RESULT_OK) {  
  89.             // Fill the list view with the strings the recognizer thought it could have heard  
  90.             ArrayList<String> matches = data.getStringArrayListExtra(  
  91.                     RecognizerIntent.EXTRA_RESULTS);  
  92.             mList.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1,  
  93.                     matches));  
  94.         }  
  95.         super.onActivityResult(requestCode, resultCode, data);  
  96.     }  

【編輯推薦】

Android 廣播接收者

Android 目錄結(jié)構(gòu)分析

Android應(yīng)用程序開發(fā)環(huán)境的搭建

在Android應(yīng)用程序中使用Internet數(shù)據(jù)

責(zé)任編輯:zhaolei 來源: 網(wǎng)絡(luò)轉(zhuǎn)載
相關(guān)推薦

2012-07-10 13:29:30

Java

2015-12-07 14:39:18

微軟Windows 95語音識(shí)別

2012-07-25 13:23:32

ibmdw

2017-01-06 13:12:11

AndroidRecyclerVie懸浮條

2016-02-17 10:39:18

語音識(shí)別語音合成語音交互

2022-09-26 11:35:50

App開發(fā)技術(shù)框架Speech框架

2025-06-27 05:00:00

AI語音詐騙AI語音識(shí)別人工智能

2009-08-21 15:28:23

C#英文

2011-01-18 11:52:25

Linux語音識(shí)別

2021-05-06 11:18:23

人工智能語音識(shí)別

2009-07-21 15:28:06

Windows Emb

2021-05-06 11:13:06

人工智能語音識(shí)別

2021-12-24 10:34:11

鴻蒙HarmonyOS應(yīng)用

2022-12-01 07:03:22

語音識(shí)別人工智能技術(shù)

2017-02-27 21:37:49

2017-10-27 16:19:23

語音識(shí)別CNN

2019-10-12 17:42:33

2021-11-17 10:37:39

語音識(shí)別技術(shù)人工智能

2015-10-23 13:41:20

android源碼科大訊飛語音識(shí)別

2024-01-08 19:30:15

AI開源語音識(shí)別
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)

主站蜘蛛池模板: 狠狠操狠狠操 | 黑人精品欧美一区二区蜜桃 | 精品一区二区三区在线观看 | 精品影院 | 亚洲日本欧美日韩高观看 | 免费精品久久久久久中文字幕 | 国产精品一区二区在线 | 欧美日韩综合一区 | 精品久久久久久久久亚洲 | 一区二区在线 | 九九九视频在线观看 | 亚洲午夜精品在线观看 | 瑟瑟免费视频 | 色视频一区二区 | 91在线看| 久久免费福利 | 国产视频精品在线 | 狠狠综合久久av一区二区老牛 | 性福视频在线观看 | 丁香六月伊人 | 成人深夜福利网站 | 91精品久久久久久久久久入口 | 国产玖玖| 国产精品2| 欧美一区二区小视频 | 国精品一区 | 亚洲综合在线网 | 久久专区 | 岛国av免费观看 | 日韩一区二区三区四区五区 | 91超碰caoporn97人人 | 亚洲国产成人精品女人 | 日本免费小视频 | 日韩在线xx | 国产98色在线 | 日韩 | 日韩五月天 | 爱高潮www亚洲精品 中文字幕免费视频 | 日本中文字幕一区 | 国产精品成人在线播放 | 日韩精品视频在线观看一区二区三区 | 五月天婷婷久久 |