gpt4 book ai didi

java - 使用 SpeechRecognizer 获取已识别数据的转录

转载 作者:行者123 更新时间:2023-12-02 09:54:37 26 4
gpt4 key购买 nike

我使用 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 翻译中实现:

或者,如有必要,请使用不同的方法。

我该怎么做?提前致谢。问候...

最佳答案

SpeechReocgnizer API 仅提供“文本”(我猜是正常的正字法文本),以及可选的置信度分数,请参阅:https://developer.android.com/reference/android/speech/RecognitionListener.html#onResults(android.os.Bundle)

关于java - 使用 SpeechRecognizer 获取已识别数据的转录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56089608/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com