Google Cloud Speech-to-Text API を使って音声を文字に起こそうと思い、ここ(https://cloud.google.com/speech-to-text/docs/quickstart-client-libraries?hl=ja)を参考にしましたが、エラーがでました。
python
1import io 2import os 3 4# Imports the Google Cloud client library 5from google.cloud import speech 6from google.cloud.speech import enums 7from google.cloud.speech import types 8 9# Instantiates a client 10client = speech.SpeechClient() 11 12# The name of the audio file to transcribe 13file_name = "C:\Users\kouta\Downloads\imu_m17.wav" 14 15# Loads the audio into memory 16with io.open(file_name, 'rb') as audio_file: 17 content = audio_file.read() 18 audio = types.RecognitionAudio(content=content) 19 20config = types.RecognitionConfig( 21 encoding=enums.RecognitionConfig.AudioEncoding.LINEAR16, 22 sample_rate_hertz=16000, 23 language_code='en-US') 24 25# Detects speech in the audio file 26response = client.recognize(config, audio) 27 28for result in response.results: 29 print('Transcript: {}'.format(result.alternatives[0].transcript))
<エラー内容>
TypeError: ('Not a package:', 'google.cloud.speech')
解決法を教えてください
あなたの回答
tips
プレビュー