Speech recognition 模块';google.cloud.speech_v1p1beta1.types';没有';识别音频&x27;成员
正在尝试运行示例代码,但我遇到此错误“ Env:python3x,linux,已安装并更新谷歌云库Speech recognition 模块';google.cloud.speech_v1p1beta1.types';没有';识别音频&x27;成员,speech-recognition,speech-to-text,google-speech-api,Speech Recognition,Speech To Text,Google Speech Api,正在尝试运行示例代码,但我遇到此错误“ Env:python3x,linux,已安装并更新谷歌云库 pip install --upgrade google-cloud-speech. 安装了以下 谷歌云(0.34.0) 谷歌云演讲(0.36.3) 不知道还有什么要查。如果你有什么建议就好了 import argparse import io def transcribe_file_with_enhanced_model(): """Transcribe the given a
pip install --upgrade google-cloud-speech.
安装了以下
- 谷歌云(0.34.0)
- 谷歌云演讲(0.36.3)
不知道还有什么要查。如果你有什么建议就好了
import argparse
import io
def transcribe_file_with_enhanced_model():
"""Transcribe the given audio file using an enhanced model."""
# [START speech_transcribe_enhanced_model_beta]
from google.cloud import speech_v1p1beta1 as speech
client = speech.SpeechClient()
speech_file = 'resources/commercial_mono.wav'
with io.open(speech_file, 'rb') as audio_file:
content = audio_file.read()
audio = speech.types.RecognitionAudio(content=content)
config = speech.types.RecognitionConfig(
encoding=speech.enums.RecognitionConfig.AudioEncoding.LINEAR16,
sample_rate_hertz=8000,
language_code='en-US',
# Enhanced models are only available to projects that
# opt in for audio data collection.
use_enhanced=True,
# A model must be specified to use enhanced model.
model='phone_call')
response = client.recognize(config, audio)
for i, result in enumerate(response.results):
alternative = result.alternatives[0]
print('-' * 20)
print('First alternative of result {}'.format(i))
print('Transcript: {}'.format(alternative.transcript))
# [END speech_transcribe_enhanced_model_beta]
使用
而不是
audio = speech.types.RecognitionAudio(content=content)
config = speech.types.RecognitionConfig(
encoding=speech.enums.RecognitionConfig.AudioEncoding.LINEAR16,
sample_rate_hertz=8000,
language_code='en-US',
use_enhanced=True,
model='phone_call')
我想你的版本是“google.cloud.speech_v1”
pip卸载谷歌云语音
pip安装谷歌云语音
我在“google.cloud.speech_v1.types”模块上看到了同样的错误
config = {
"language_code": language_code,
"sample_rate_hertz": sample_rate_hertz,
"encoding": encoding,
"use_enhanced": True,
"model": 'phone_call',
}
audio = {"uri": storage_uri}
audio = speech.types.RecognitionAudio(content=content)
config = speech.types.RecognitionConfig(
encoding=speech.enums.RecognitionConfig.AudioEncoding.LINEAR16,
sample_rate_hertz=8000,
language_code='en-US',
use_enhanced=True,
model='phone_call')