GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Error for short audio file · Issue #801 · GoogleCloudPlatform/python-docs-samples

Error for short audio file #801

New issue
Copy link
New issue
Copy link
Closed
Closed
Error for short audio file#801
Copy link
Assignees
gguuss

Description

@bgrgicak
bgrgicak
opened on Feb 13, 2017
Issue body actions

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.">

33852851486977924039000.zip

Activity

  1. bgrgicak
    changed the title [-]Error for 30sec long audio file[/-] [+]Error for short audio file[/+] on Feb 13, 2017
  2. theacodes
    assigned
    gguuss
    on Feb 13, 2017
  3. theacodes commented on Feb 13, 2017

    @theacodes
    theacodes
    on Feb 13, 2017
    Contributor
    More actions

    @gguuss or @jerjou, any thoughts?

  4. gguuss commented on Feb 13, 2017

    @gguuss
    gguuss
    on Feb 13, 2017
    Contributor
    More actions

    I have seen the filesize get misinterpreted on certain formats. Are you sure you're using the right format? Can you encode the file as FLAC?

  5. jerjou commented on Feb 13, 2017

    @jerjou
    jerjou
    on Feb 13, 2017
    Contributor
    More actions

    Yeah - it looks like the file is encoded as WAVE instead of raw (though perhaps this doesn't matter so much - see below). It's correctly 16-bit little-endian at 16khz, but it's stereo, which isn't supported and explains why the api thinks it's twice as long as it is :-)

    I was able to get it to work after re-encoding it to 1 channel (sox 33852851486977924039000.wav foo.wav channels 1). Interestingly, the api doesn't seem to care about the WAVE container :-) (nor does aplay... TIL) It probably just interprets the header frames as audio samples, which become just noise for a short burst in the beginning..

  6. jerjou commented on Feb 13, 2017

    @jerjou
    jerjou
    on Feb 13, 2017
    Contributor
    More actions

    Closing for now - please reopen if this doesn't fix the issue!

  7. jerjou
    closed this as completedon Feb 13, 2017
  8. bgrgicak commented on Feb 14, 2017

    @bgrgicak
    bgrgicak
    on Feb 14, 2017
    Author
    More actions

    Converting the file to flac mono solved the issue. Thank you for your help!

  9. Linchin
    added a commit that references this issue on Aug 18, 2025

    chore(deps): update all dependencies (#801)

    b72202b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @gguuss
    gguuss

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.