如何仅从 Microsoft 语音服务中识别的对象中获取文本部分
How can I get only text part out of recognised object in Microsoft Speech Service
以下是我从 Microsoft Azure 语音 SDK 的文件中进行语音识别的输出。我想知道如何从这个输出中只提取 'text' 部分而不是完整的部分。
SpeechRecognitionEventArgs(session_id=e28f6907838640e191f214035d69f5e0, result=SpeechRecognitionResult(result_id=c27fa5b36bcd466f8162ca3c6ce5f935, text="Hello good morning, my name is Arihant. How may I help you?", reason=ResultReason.RecognizedSpeech))
CANCELED SpeechRecognitionCanceledEventArgs(session_id=e28f6907838640e191f214035d69f5e0, result=SpeechRecognitionResult(result_id=5681af6a81994a76a11b7e94307c7c2e, text="", reason=ResultReason.Canceled))
CLOSING on SessionEventArgs(session_id=e28f6907838640e191f214035d69f5e0)
如果这是您正在使用的以下代码:
speech_recognizer.recognized.connect(lambda evt: print('RECOGNIZED: {}'.format(evt)))
您只能使用 evt.result
获取文本
以下是我从 Microsoft Azure 语音 SDK 的文件中进行语音识别的输出。我想知道如何从这个输出中只提取 'text' 部分而不是完整的部分。
SpeechRecognitionEventArgs(session_id=e28f6907838640e191f214035d69f5e0, result=SpeechRecognitionResult(result_id=c27fa5b36bcd466f8162ca3c6ce5f935, text="Hello good morning, my name is Arihant. How may I help you?", reason=ResultReason.RecognizedSpeech))
CANCELED SpeechRecognitionCanceledEventArgs(session_id=e28f6907838640e191f214035d69f5e0, result=SpeechRecognitionResult(result_id=5681af6a81994a76a11b7e94307c7c2e, text="", reason=ResultReason.Canceled))
CLOSING on SessionEventArgs(session_id=e28f6907838640e191f214035d69f5e0)
如果这是您正在使用的以下代码:
speech_recognizer.recognized.connect(lambda evt: print('RECOGNIZED: {}'.format(evt)))
您只能使用 evt.result