「音声からテキストへ」機能を実装するために SpeechRecognizer を使用し、彼女の作業の結果はテキスト データです。
Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,
RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, Locale.US.toString());
intent.putExtra("android.speech.extra.EXTRA_ADDITIONAL_LANGUAGES", new String[]{});
SpeechRecognizer recognizer = SpeechRecognizer.createSpeechRecognizer(getApplicationContext());
recognizer.setRecognitionListener(new RecognitionListener() {
@Override
public void onReadyForSpeech(Bundle params) {}
@Override
public void onBeginningOfSpeech() {}
@Override
public void onRmsChanged(float rmsdB) {}
@Override
public void onBufferReceived(byte[] buffer) {}
@Override
public void onEndOfSpeech() {}
@Override
public void onError(int error) {}
@Override
public void onPartialResults(Bundle partialResults) {}
@Override
public void onEvent(int eventType, Bundle params) {}
@Override
public void onResults(Bundle results) {
String result = null;
ArrayList<String> arrOfResults = results.getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION);
String command = arrOfResults.get(0);
}
});
recognizer.startListening(intent);
この方法を使用して、テキストの代わりに認識された音声の書き起こしを取得することは可能ですか?
たとえば、Google 翻訳では次のように実装されています。
または、必要に応じて、別のアプローチを使用します。
これどうやってするの?前もって感謝します。よろしく...