Tuesday, 25 April 2017

How to access file in google storage and sync with google speech

I'm playing around with google's cloud speech api. According to its documents I should be able to use an asynchronous request to access a file stored directly in google storage - https://cloud.google.com/speech/docs/async-recognize

I'm basically implementing this code:

const Speech = require('@google-cloud/speech');
const speech = Speech({
   projectId: process.env.PROJECTID, credentials: 
   JSON Key});
const gcsUri = 'gs://my-bucket/audio.raw';


const request = {
  encoding: 'LINEAR16',
  sampleRateHertz: 16000,
  languageCode: 'en-US'
};

speech.startRecognition(gcsUri, request)
  .then((results) => {
    const operation = results[0];
    // Get a Promise represention of the final result of the job
    return operation.promise();
  })
  .then((results) => {
    const transcription = results[0];
    console.log(`Transcription: ${transcription}`);
  })
  .catch((err) => {
    console.error('ERROR:', err);
  });

...but I'm getting the following error --> 'Error: Requested entity was not found.'

I'm guessing this has something to do with access rights, but I can't figure out what to change. I thought since i'm including my project ID and json key file this should be sufficient.

Any help would be much appreciated!



via user3621334

No comments:

Post a Comment