我正在使用 python3 通过提供的 python 包(google-speech)使用 Google 语音转文本转录音频文件。
有一个选项可以定义用于转录的自定义短语,如文档中所述: https: //cloud.google.com/speech-to-text/docs/speech-adaptation
出于测试目的,我使用一个包含文本的小音频文件:
[..] 在本次讲座中,我们将讨论 Burrows Wheeler 变换和 FM 索引 [..]
我将给出以下短语来查看效果,例如,如果我希望使用正确的符号来识别特定名称。在此示例中,我想将burrows更改为barrows:
config = speech.RecognitionConfig(dict(
encoding=speech.RecognitionConfig.AudioEncoding.ENCODING_UNSPECIFIED,
sample_rate_hertz=24000,
language_code="en-US",
enable_word_time_offsets=True,
speech_contexts=[
speech.SpeechContext(dict(
phrases=["barrows", "barrows wheeler", "barrows wheeler transform"]
))
]
))
Run Code Online (Sandbox Code Playgroud)
不幸的是,这似乎没有任何效果,因为输出仍然与没有上下文短语时相同。
我是否使用了错误的短语,或者它有如此高的信心,以至于它听到的单词确实是洞穴,所以它会忽略我的短语?
PS:我还尝试使用speech_v1p1beta1.AdaptationClient
andspeech_v1p1beta1.SpeechAdaptation
而不是将短语放入配置中,但这只会给我一个内部服务器错误,而不会提供有关出现问题的其他信息。https://cloud.google.com/speech-to-text/docs/adaptation
python speech-to-text google-speech-api google-speech-to-text-api hint-phrases