2011-11-14 3 views
0

Comment puis-je faire en sorte que ce programme affiche un simple message Hello World quand je dis Hello World? Je veux faire de ce programme dans une application de reconnaissance vocale qui affiche ce que je dis sur l'écran du téléphone portable fonctionnant Android 2.1 ou plus tard.Bonjour, Monde. Reconnaissance vocale

c'est jusqu'à présent ce que j'ai:

// **** 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> 

Répondre

0

This est exactement ce que vous recherchez. Vous l'avez déjà dans vos échantillons api-INSIDE Android-sdk

+0

Savez-vous quelles lignes de code que je dois créer un champ de texte qui affiche « Bonjour tout le monde "quand je parle sur le microphone en utilisant le même code ci-dessus? – user1046106