Android开发语音转文字,在Android上语音转文字

小编典典

如果您不想使用RecognizerIntent进行语音识别,则仍然可以使用SpeechRecognizer该类来进行语音识别。但是,使用该类比使用意图要难一些。最后一点,我强烈建议让用户知道他何时被记录,否则,当他最终发现时,他可能会非常适应。

Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);

intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,

RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);

intent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE,

"com.domain.app");

SpeechRecognizer recognizer = SpeechRecognizer

.createSpeechRecognizer(this.getApplicationContext());

RecognitionListener listener = new RecognitionListener() {

@Override

public void onResults(Bundle results) {

ArrayList voiceResults = results

.getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION);

if (voiceResults == null) {

System.out.println("N

你可能感兴趣的:(Android开发语音转文字)