-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Description
In which file did you encounter the issue?
/home/bero/.local/lib/python3.5/site-packages/oauth2client/_helpers.py
/home/bero/.local/lib/python3.5/site-packages/googleapiclient/http.py
Did you change the file? If so, how?
No
Describe the issue
When i try to analyze a audio file with google speech api i get a error that the file is longer then 1min but the file is 30sec long. File in attachment and error message below.
This is my requerst code (part is path to the local audio file):
with open(part, 'rb') as speech:
# Base64 encode the binary audio file for inclusion in the request.
speech_content = base64.b64encode(speech.read())
#GOOGLE_APPLICATION_CREDENTIALS = self.googleApplicationCredentials
service = self.get_speech_service()
service_request = service.speech().asyncrecognize(
body={
'config': {
# There are a bunch of config options you can specify. See
# https://goo.gl/KPZn97 for the full list.
'encoding': 'LINEAR16', # raw 16-bit signed LE samples
'sampleRate': 16000, # 16 khz
# See http://g.co/cloud/speech/docs/languages for a list of
# supported languages.
'languageCode': language_code, # a BCP-47 language tag
},
'audio': {
'content': speech_content.decode('UTF-8')
}
}
)
Error message
Traceback (most recent call last):
File "test.py", line 5, in
analyze = Analyze('temp/33852851486977924039000.wav','en-us')
File "/home/bero/video-analyze/Analyze.py", line 39, in init
response = service_request.execute()
File "/home/bero/.local/lib/python3.5/site-packages/oauth2client/_helpers.py", line 133, in positional_wrapper
return wrapped(*args, **kwargs)
File "/home/bero/.local/lib/python3.5/site-packages/googleapiclient/http.py", line 838, in execute
raise HttpError(resp, content, uri=self.uri)
googleapiclient.errors.HttpError: <HttpError 400 when requesting https://speech.googleapis.com/v1beta1/speech:asyncrecognize?alt=json returned "Audio 'content' cannot be longer than 1 min. For long audio, use the 'uri' parameter to specify a file.">