Python 在google云语音api中使用增强模型
我正在尝试使用谷歌语音API上的增强模型,如:Python 在google云语音api中使用增强模型,python,python-3.x,google-cloud-speech,Python,Python 3.x,Google Cloud Speech,我正在尝试使用谷歌语音API上的增强模型,如: gcs_uri="gs://mybucket/averylongaudiofile.ogg" client = speech.SpeechClient() audio = types.RecognitionAudio(uri=gcs_uri) config = types.RecognitionConfig( encoding=enums.RecognitionConfig.AudioEncoding.OGG_OPUS,
gcs_uri="gs://mybucket/averylongaudiofile.ogg"
client = speech.SpeechClient()
audio = types.RecognitionAudio(uri=gcs_uri)
config = types.RecognitionConfig(
encoding=enums.RecognitionConfig.AudioEncoding.OGG_OPUS,
language_code='en-US',
sample_rate_hertz=48000,
use_enhanced=True,
model='phone_call',
enable_word_time_offsets=True,
enable_automatic_punctuation=True)
operation = client.long_running_recognize(config, audio)
我已经在项目的“云语音API”设置中启用了数据记录,以便能够使用增强模型
当我运行它时,它抛出以下错误:
Traceback (most recent call last): File "./transcribe.py", line 126, in <module>
enable_automatic_punctuation=True) ValueError: Protocol message RecognitionConfig has no "use_enhanced" field.
Traceback(最近一次调用last):文件“/transcribe.py”,第126行,在
启用\u自动\u标点符号=True)值错误:协议消息识别配置没有“使用增强”字段。
有什么建议吗?您可以在中的识别配置类型中使用“use\u enhanced”
为了能够运行您的示例,您只需将已有的导入修改为以下内容:
import google.cloud.speech_v1p1beta1 as speech
gcs_uri="gs://mybucket/averylongaudiofile.ogg"
client = speech.SpeechClient()
audio = speech.types.RecognitionAudio(uri=gcs_uri)
config = speech.types.RecognitionConfig(
encoding=speech.enums.RecognitionConfig.AudioEncoding.OGG_OPUS,
language_code='en-US',
sample_rate_hertz=48000,
use_enhanced=True,
model='phone_call',
enable_word_time_offsets=True,
enable_automatic_punctuation=True)
operation = client.long_running_recognize(config, audio)