你好世界。语音识别
当我说“Hello World”时,如何使该程序显示简单的“Hello World”消息?我想把这个程序制作成一个语音识别应用程序,将我所说的话显示到运行 android 2.1 或更高版本的手机屏幕上。
到目前为止,这就是我所拥有的:
// **** SpeechRecognition.java *****
package com.SpeechRecognition.CMPE4373;
import android.app.Activity;
import android.os.Bundle;
import android.widget.*;
import android.os.Handler;
import android.speech.*;
import android.inputmethodservice.*;
public class SpeechRecognition extends Activity {
/* Declaring variables */
private static final String TAG = "VoiceRecognition";
private static final int VOICE_RECOGNITION_REQUEST_CODE = 1234;
private ListView mList;
private Handler mHandler;
private Spinner mSupportedLanguageView;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mHandler = new Handler();
}
}
<!-- layout/main.xml -->
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello" />
</LinearLayout>
<!-- AndroidManifest.xml -->
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.SpeechRecognition.CMPE4373"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="14" />
<application
android:icon="@drawable/ic_launcher2"
android:label="@string/app_name" >
<activity
android:label="@string/app_name"
android:name=".SpeechRecognition" >
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
How can I make this program display a simple Hello World message when I say Hello World? I want to make this program into a speech recognition application that displays what I say onto the screen of cell phone running android 2.1 or later.
so far this is what I have:
// **** SpeechRecognition.java *****
package com.SpeechRecognition.CMPE4373;
import android.app.Activity;
import android.os.Bundle;
import android.widget.*;
import android.os.Handler;
import android.speech.*;
import android.inputmethodservice.*;
public class SpeechRecognition extends Activity {
/* Declaring variables */
private static final String TAG = "VoiceRecognition";
private static final int VOICE_RECOGNITION_REQUEST_CODE = 1234;
private ListView mList;
private Handler mHandler;
private Spinner mSupportedLanguageView;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mHandler = new Handler();
}
}
<!-- layout/main.xml -->
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello" />
</LinearLayout>
<!-- AndroidManifest.xml -->
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.SpeechRecognition.CMPE4373"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="14" />
<application
android:icon="@drawable/ic_launcher2"
android:label="@string/app_name" >
<activity
android:label="@string/app_name"
android:name=".SpeechRecognition" >
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这正是,您正在寻找什么。
您已经将其包含在 Android-Sdk 内的 api-samples 中
This is exactly, what you are searching for.
You have it already in your api-samples inside the Android-Sdk
或者试试这个:
https://github.com/gmilette/Say-the-Magic-词-
Or try this:
https://github.com/gmilette/Say-the-Magic-Word-