python - Google Speech to text Error Raspberry Pi - “模块对象没有属性 RecognitionAudio”
问题描述
我一直在关注谷歌 API 语音到文本转换的快速入门指南。
https://cloud.google.com/speech-to-text/docs/libraries
每当我尝试运行示例 python 脚本时,我都会收到一条错误消息,指出语音模块没有 RecognitionAudio 属性。我已按照教程运行 pip install --upgrade google-cloud-speech。还有什么可能是错的?
这是我正在运行的示例 python 代码。那些音频 = 语音.RecognitionAudio(uri=gcs_uri) 的错误
# Imports the Google Cloud client library
from google.cloud import speech
# Instantiates a client
client = speech.SpeechClient()
# The name of the audio file to transcribe
gcs_uri = "gs://cloud-samples-data/speech/brooklyn_bridge.raw"
audio = speech.RecognitionAudio(uri=gcs_uri)
config = speech.RecognitionConfig(
encoding=speech.RecognitionConfig.AudioEncoding.LINEAR16,
sample_rate_hertz=16000,
language_code="en-US",
)
# Detects speech in the audio file
response = client.recognize(config=config, audio=audio)
for result in response.results:
print("Transcript: {}".format(result.alternatives[0].transcript))
解决方案
推荐阅读
- java - 求地图到地图转换的优化建议
- reactjs - 在地图中间过滤>0时如何避免显示错误
- c# - 为什么结合 Task.Run 和 plinq 这么慢?
- postman - 基于来自 arrayElement 的响应的 JSON 验证检查
- c# - 为什么单元测试 Assert.AreEqual() 方法不会在自定义类中选择我自己的 Equals() 方法
- jquery - Jquery UI Autocomplete Custom HTML (TypeError: t.item is undefined)
- react-native - 如何避免日期字符串之间的换行?[反应原生]
- android - Android Api (Okhttps) 未在 android 9(pie) 及更高版本中调用
- c# - 如何简化从excel到sqlite的查询?
- docker - docker-compose.yaml 什么时候重新解析?