Skip to content

@google-cloud/speech Operation not returning. #2408

@jackzampolin

Description

@jackzampolin

Environment details

  • OS: google-cloud-functions
  • Node.js version: ?
  • npm version: ?
  • google-cloud-node version: ?

Steps to reproduce

I'm trying to use the node.js speech api client to return text using google cloud functions. I have the following in my index.js:

// Get a reference to the Cloud Vision API component
const speech = require('@google-cloud/speech')();

/**
 * Background Cloud Function to be triggered by Cloud Storage.
 *
 * @param {object} event The Cloud Functions event.
 * @param {function} The callback function.
 */
exports.audio2text = function (event, callback) {
  const file = event.data;
  console.log(`uploaded file ${file.name}, beginning transcription...`)
  
  var config = {
    encoding: 'FLAC',
    languageCode: 'en-US',
    sampleRateHertz: 48000,
    verbose: true
  };
  
  speech.startRecognition(`gs://influx-audio-upload/${file.name}`, config)
    .then(function(data) {
      console.log("apiResponse: ", data[1])
      console.log("Operation started")
      data[0].on("error", (err) => {
        console.log("Operation err")
        console.log(err)
      }).on("complete", (results) => {
        console.log("Operation complete")
        results.forEach((element) =>{
          console.log(element.transcript)
        })
      })
    }).catch(err => {
      console.log("in error")
      console.log(err)
    })
  console.log("end of function")
  callback();
};

Uploading and transcribing shorter audio (~5m) works just fine, however when I try longer audio (~30m) the Operation never returns. I've tried defining the cloud function with a longer timeout (--timeout 9m) and I'm still not getting any returns. Am I on the right track or is this API not intended to function this way?

Metadata

Metadata

Labels

api: speechIssues related to the Speech-to-Text API.type: questionRequest for information or clarification. Not an issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions