gpt4 book ai didi

google-cloud-platform - SpeechContext 没有 "boost"字段

转载 作者:行者123 更新时间:2023-12-04 15:43:36 24 4
gpt4 key购买 nike

我正在使用 google cloud api 进行语音转文本,我想添加一些上下文短语。根据谷歌文档,语音上下文也有一个我无法设置的增强字段。

我更改了导入的 speech_v1p1beta1 而不是 speech_v1 并编码如下:

    config = speech.RecognitionConfig(
encoding=speech.RecognitionConfig.AudioEncoding.LINEAR16,

sample_rate_hertz=8000,
language_code=first_lang,
#alternative_language_codes=[second_lang],
audio_channel_count=1,
enable_separate_recognition_per_channel=False,
#metadata=metadata,
max_alternatives=5,
# enable_word_confidence=True,

speech_contexts=[{'phrases':['sfs'],'boost':15}]


# speech_contexts=[speech.SpeechContext(
# phrases=['life insurance'],boost=15
# )
# ]
)

我收到以下错误:

  File "convert-wav-beta.py", line 165, in <module>
transcript , confidence = google_transcribe(audio_file_name)
File "convert-wav-beta.py", line 106, in google_transcribe
speech_contexts=[{'phrases':['sfs'],'boost':15}]
File "/env/lib/python3.5/site-packages/google/protobuf/internal/python_message.py", line 528, in init
copy.add(**val)
File "/env/lib/python3.5/site-packages/google/protobuf/internal/containers.py", line 376, in add
new_element = self._message_descriptor._concrete_class(**kwargs)
File "/env/lib/python3.5/site-packages/google/protobuf/internal/python_message.py", line 509, in init
field = _GetFieldByName(message_descriptor, field_name)
File "/env/lib/python3.5/site-packages/google/protobuf/internal/python_message.py", line 573, in _GetFieldByName
(message_descriptor.name, field_name))
ValueError: Protocol message SpeechContext has no "boost" field.```

最佳答案

我通过更新系统中的 beta 库解决了这个问题。我通过从 google 的 github 代码复制代码来做到这一点。

关于google-cloud-platform - SpeechContext 没有 "boost"字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56838483/

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