Skip to content

Error: Audio 'content' cannot be longer than 1 min. For long audio, use the 'uri' parameter to specify a file. #232

Description

@loretoparisi

I get this error for audio samples longer than 60seconds:

Error: Audio 'content' cannot be longer than 1 min. For long audio, use the 'uri' parameter to specify a file.

How to specify the uri parameter in the node cli?

Activity

  1. jmdobry commented on Oct 11, 2016

    @jmdobry
    Member

    You basically need to tell it to use a file you've uploaded to Google Cloud Storage.

    node recognize.js sync gs://your-bucket-name/your-file-name
    

    or

    node recognize.js async gs://your-bucket-name/your-file-name
    

    Keep in mind the sample assumes LINEAR16 encoding and a sampleRate of 16000. You need to modify those options if your file differs.

  2. loretoparisi commented on Oct 12, 2016

    @loretoparisi
    Author

    @jmdobry I have tried as you said and the call seems to reply with the same error

    $ node recognize.js async "https://..."
    
    { Error: Audio 'content' cannot be longer than 1 min. For long audio, use the 'uri' parameter to specify a file.
        at /Volumes/MacHDD2/Projects/MusiXmatch/AI/nodejs-docs-samples/speech/node_modules/grpc/src/node/src/client.js:417:17 code: 400, metadata: Metadata { _internal_repr: {} } }
    /Volumes/MacHDD2/Projects/MusiXmatch/AI/nodejs-docs-samples/utils/index.js:44
          throw err;
          ^
    
    Error: Audio 'content' cannot be longer than 1 min. For long audio, use the 'uri' parameter to specify a file.
        at /Volumes/MacHDD2/Projects/nodejs-docs-samples/speech/node_modules/grpc/src/node/src/client.js:417:17
    

    So I have tried in this way using my CDN and a WAVE file 16K

    $ cat syn-request.json 
    {
            "config": {
                        "encoding": "WAVE",
                            "sampleRate": 16000,
                                "languageCode": "en-US"
                                },
                                "audio": {
                                            "uri": "https: //..."
    

    and

    $ export GCLOUD_PROJECT=my-project-id
    $ gcloud beta auth application-default login
    $ GCLOUD_ACCESSTOKEN=`echo gcloud auth print-access-token`
    

    to have an access token and then

    $ curl -s -k -H "Content-Type: application/json" -H "Authorization: Bearer $GCLOUD_ACCESSTOKEN" https://speech.googleapis.com/v1beta1/speech:syncrecognize -d @sync-request.json
    

    but I get

    {
      "error": {
        "code": 403,
        "message": "Google Cloud Speech API has not been used in project google.com:cloudsdktool before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/speech.googleapis.com/overview?project=google.com:cloudsdktool then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.",
        "status": "PERMISSION_DENIED",
        "details": [
          {
            "@type": "type.googleapis.com/google.rpc.Help",
            "links": [
              {
                "description": "Google developers console API activation",
                "url": "https://console.developers.google.com/apis/api/speech.googleapis.com/overview?project=google.com:cloudsdktool"
              }
            ]
          }
        ]
      }
    }
    

    This error seems to be the same as referred in googleapis/google-cloud-ruby#706

  3. jmdobry commented on Oct 12, 2016

    @jmdobry
    Member

    uri only works with Google Cloud Storage URIs, e.g. gs://your-bucket-name/your-file-name.

    If you use https://yourcdn.com/your-file-name then the library is actually downloading the file and passing it to the Speech API as content, not as a uri.

    See the docs for Speech#recognize

  4. loretoparisi commented on Oct 12, 2016

    @loretoparisi
    Author

    @jmdobry Just to be clear, this means that passing a generic cdn uri will be limited to 1MB then?

  5. jmdobry commented on Oct 13, 2016

    @jmdobry
    Member

    1 minute, not 1 MB.

  6. loretoparisi commented on Oct 13, 2016

    @loretoparisi
    Author

    @jmdobry yes sorry 1 minutes of pcm audio.

  7. jmdobry commented on Nov 7, 2016

    @jmdobry
    Member

    Yep

  8. added a commit that references this issue on Nov 3, 2022
  9. added a commit that references this issue on Nov 8, 2022
  10. added a commit that references this issue on Nov 9, 2022
  11. added a commit that references this issue on Nov 11, 2022
  12. added a commit that references this issue on Nov 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    🚨This issue needs some love.triage meI really want to be triaged.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions