我正在将一个.opus音频文件传递给google的语音到文本api进行转录.我使用以下配置:
enums.RecognitionConfig.AudioEncoding.OGG_OPUS
我得到了以下错误:
google.api_core.exceptions.GoogleAPICallError: None Unable to recognize speech, possible error in encoding or channel config. Please correct the config and retry the request.
我尝试过其他编码,如FLAC和LINEAR16,没有作为输出。
opus音频文件需要额外的配置字段吗?配置文件应该是什么样的呢?
发布于 2020-08-06 14:05:48
在浏览了google提供的文档和几次尝试之后,我想出了解决我所得到的错误的方法。OGG_OPUS编码需要audio_channel_count的显式配置定义。在我的例子中,音频通道是2,我需要显式地定义它。此外,在多通道情况下,需要将enable_separate_recognition_per_channel设置为True。
对我起作用的配置是:
encoding = enums.RecognitionConfig.AudioEncoding.OGG_OPUS
config = {
"audio_channel_count": audio_channel_count,
"enable_separate_recognition_per_channel": enable_separate_recognition_per_channel,
"language_code": language_code,
"sample_rate_hertz": sample_rate_hertz,
"encoding": encoding
}
对于配置文件中的每个参数,我们使用正确的值是非常重要的。
https://stackoverflow.com/questions/63275156
复制