问题
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