Error: 5 NOT_FOUND: Requested entity was not found on LongRunningRecognize

拟墨画扇 提交于 2019-12-08 04:54:44

问题


I'm trying to transcribe an audio file with the node.js client Google Speech to Text and Google Cloud Function. Unfortunately I get this error :

Error: 5 NOT_FOUND: Requested entity was not found

I supposed it comes from authentification problem, but i am not sure.

First, I tried without credentials assuming that GCF will use ADC (Application Default Credentials). After, I added client_email et private_key from service account to SpeechClient options param, but it didn't work. I added projectId and keyFilename... not better.

Maybe it isn't the good way... I have no idea !

Here is my code. Thanks for your help.

const audioFilename = 'gs://' + outputBucket.name + '/' + event.data.name;

const request = {
  "config": {
      "enableWordTimeOffsets": false, 
      "languageCode": "fr-FR",
      "encoding":"FLAC"
  }, 
  "audio": {
      "uri": audioFilename
  }
}
const options = {
  credentials :{
    projectId: 'xxxxxx',
    keyFilename: './xxxxx.json',
    client_email:'xxxx@xxxxx',
    private_key:'xxxxxxxxx'
  }
};
const client = new speech.SpeechClient(options);
client
  .longRunningRecognize(request)
  .then(data => {
    const response = data[0];
    const operation = response;
    operation.on('progress', (metadata, apiResponse) => {
      console.log(JSON.stringify(metadata))
    });
    // Get a Promise representation of the final result of the job
    return operation.promise();
  })
  .then(data => {
    const [response] = data[0];
    const content = response.results
      .map(result => result.alternatives[0].transcript)
      .join('\n');
    console.log(`Transcription: ${content}`);
    resolve(content);
  })
  .catch(err => {
    reject(err);
  });

来源:https://stackoverflow.com/questions/53086098/error-5-not-found-requested-entity-was-not-found-on-longrunningrecognize

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!