你好世界。语音识别

发布于 2024-12-15 15:12:16 字数 2233 浏览 0 评论 0原文

当我说“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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

你的笑 2024-12-22 15:12:16

正是,您正在寻找什么。
您已经将其包含在 Android-Sdk 内的 api-samples 中

This is exactly, what you are searching for.
You have it already in your api-samples inside the Android-Sdk

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文