语音识别技术是在Android SDK1.5中才加入的(RecognizerIntent),这里我们简单的分析一下自带的api例子,其实它就是通过一个Intent的Action 动作来完成的。主要有以下两种模式: ACTION_RECOGNIZE_SPEECH:一般语音识别,在这种模式下我们可以捕捉到语音的处理后的文字列。
ACTION_WEB_SEARCH:网络搜索
该例子同样是使用ACTION_RECOGNIZE_SPEECH模式,我们需要实现onActivityResult方法,当语音识别结束之后的回调函数。
好了,废话不多说,看下面的代码,我加入了注释,重要的本来就不多几行。 Voicerecognition.java 代码
package com.example.android.apis.app;
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.ArrayAdapter;
import android.widget.Button;
import android.widget.ListView;
import java.util.ArrayList; import java.util.List; public class VoiceRecognition extends Activity implements OnClickListener { private static final int VOICE_RECOGNITION_REQUEST_CODE = 1234;
private ListView mList;
/**
* Called with the activity is first created.
*/
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.voice_recognition);
Button speakButton = (Button) findViewById(R.id.btn_speak);
mList = (ListView) findViewById(R.id.list);
// Check to see if a recognition activity is present
PackageManager pm = getPackageManager();
List activities = pm.queryIntentActivities(new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH), 0);
if (activities.size() != 0)
{
speakButton.setOnClickListener(this);
Android实现语音识别 苹果的iphone的语音识别功能使用的是Google的技术,做为Google力推的Android自然会将其核心技术植入到 Android系统里面,并结合google的云端技术将其...
Android语音识别的应用与开发_信息与通信_工程科技_专业资料。 实用第一 智慧密集 , .… . . ,… … .…… . , 第 四层 .Linux 内核 .Android核心 实用...
语音识别技术是在 Android SDK1.5 中才加入的(RecognizerIntent),这里我们简单的分析一下 自带的 api 例子, 其实它就是通过一个 Intent 的 Action 动作来完成的...
Android语音识别应用的研究与开发_互联网_IT/计算机_专业资料 暂无评价
(255, 255, 255);"> </SPAN> </SPAN>语音识别技术是在Android SDK1.5中才加入的(RecognizerIntent),...
IT 在线教育平台———麦子学院:http://www.maiziedu.com Android 作为 Google 主推的手机系统,当苹果都在使用其语音识技术时, android 自己也不例外,并将相关...
IPhone手机内置的Siri语音助手就是一个很好的例子。而鲜为人知的是其使用的语音识别技术来自于Google。而想而知,作为Google力推的Android自然被植入了最核心的语音...
苹果的 iphone 有语音识别用的是 Google 的技术,做为 Google 力推的 Android 自然 会将其核心技术往 Android 系统里面植入,并结合 google 的云端技术将其发扬...
基于android系统的电话 本语音识别软件设计 GF 目录 1 2 3 4 5 6 课题背景 Android简介 环境搭建 模拟器运行 作品展示 归纳总结 课题背景理解让机器听懂人类的...
热门文档