2016-07-03 6 views
-1

私はアンドロイドが新しく、音声コマンドを取得するために使用できるアプリを作成する必要があるプロジェクトを行う必要があります。ユーザーの声を録音し、オーディオとして保存する必要がありますファイルをテキストに変換するか、オーディオファイルを保存せずに直接テキストファイルに変換するだけです。アンドロイドで音声をテキストに変換する

これは私がこれまで行われてきたもので、

public class VoiceRecognitionDemo extends Activity{ 

private static final int REQUEST_CODE = 1234; 
private ListView wordsList; 

/** 
* Called with the activity is first created. 
*/ 
@Override 
public void onCreate(Bundle savedInstanceState) 
{ 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.voice_recog); 

    Button speakButton = (Button) findViewById(R.id.speakButton); 

    wordsList = (ListView) findViewById(R.id.list); 

    // Disable button if no recognition service is present 
    PackageManager pm = getPackageManager(); 
    List<ResolveInfo> activities = pm.queryIntentActivities(
      new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH), 0); 
    if (activities.size() == 0) 
    { 
     speakButton.setEnabled(false); 
     speakButton.setText("Recognizer not present"); 
    } 
} 

/** 
* Handle the action of the button being clicked 
*/ 
public void speakButtonClicked(View v) 
{ 
    startVoiceRecognitionActivity(); 
} 

/** 
* Fire an intent to start the voice recognition activity. 
*/ 
private void startVoiceRecognitionActivity() 
{ 
    Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH); 
    intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, 
      RecognizerIntent.LANGUAGE_MODEL_FREE_FORM); 
    intent.putExtra(RecognizerIntent.EXTRA_PROMPT, "Voice recognition Demo..."); 
    startActivityForResult(intent, REQUEST_CODE); 
} 

/** 
* Handle the results from the voice recognition activity. 
*/ 
@Override 
protected void onActivityResult(int requestCode, int resultCode, Intent data) 
{ 
    if (requestCode == REQUEST_CODE && resultCode == RESULT_OK) 
    { 
     // Populate the wordsList with the String values the recognition engine thought it heard 
     ArrayList<String> matches = data.getStringArrayListExtra(
       RecognizerIntent.EXTRA_RESULTS); 
     wordsList.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, 
       matches)); 
    } 
    super.onActivityResult(requestCode, resultCode, data); 
} 

}

私がアクションをトリガーするために特定のキーワードを抽出するために、この配列をソートする必要があります。 どのようにして特定の行動を起こすのですか(例 - フレーズで電話をかけたり、話しかけたりします)?

+1

SiriまたはGoogle Voiceを構築することは、物事の難しい側面に少しあるかもしれません。 – ifly6

+0

私は知っている:( しかし、そのことは私がしなければならない、soooはそれらのように進歩していない。しかし非常に単純なもの – Vishwa

+0

ここから始めることができます - 音声チュートリアル:http://www.androidhive.info/2014/07/android-speech-to-text-tutorial/ – MorZa

答えて

0

Nuance SDKを使用すると、音声によるテキストを認識できます。 40以上の言語をサポートするクロスプラットフォームSDKです。このSDKは無料ではありませんが、30日間有効なテストキーを使用できます。

オーディオファイルまたはストリームをニュアンスサーバーに送信できます。これに応答して、テキスト文字列を取得します。次に、キーワードやコマンドを取得する独自のロジックを実現することができます。

+0

私はニュアンスを確認しましたが、少し難しかったです。私はGoogle独自のプリビルドをアンドロイドで使用できますか?ご参考までに助けてください – Vishwa

+0

私はニュアンスだけを使用しましたが、検索私はあなたの問題の2つの興味深い答えを見つけた:[first](http://stackoverflow.com/questions/4975443/is-there-a-way-to-use-the-speechrecognizer-api-directly-for-speech-入力)と[秒](http:// stack overflow.com/questions/4559930/speechrecognizer-causes-anr-i-need-help-with-android-speech-api)。私は自分でコードをテストする時間がありませんが、それは単純に見えますし、あなたはその方法でネイティブのGoogleのスピークの認識を使用できることを願っています。 – MatWay

+0

あなたのhelp.iのための多くのおかげで彼らに試してみましょう:) と私はすべてのhelp.thanksの問題を取得する場合は戻ってくる – Vishwa

関連する問題