Reputation: 172
I have included the Google Speech API in Cloud Functions. I want to get the word level confidence score, so I set 'enableWordConfidence' to true. For some reason, the response doesn't return a confidence score on a word level.
I have tried de-DE and en-US as languageCode, but both didn't work. Here is the official documentation from Google, but copying that code and running it in the cloud functions also didn't return the word level confidence. https://cloud.google.com/speech-to-text/docs/word-confidence
Here is the code:
const filePath = `gs://PATH_TO_AUDIO.flac`
const audio = {
uri: filePath,
};
const config = {
encoding: 'FLAC',
sampleRateHertz: 16000,
languageCode: languageCode,
enableSpeakerDiarization: true,
enableWordConfidence: true,
useEnhanced: true,
enableWordTimeOffsets: true,
enableAutomaticPunctuation: true,
};
if(languageCode == 'en-US') {
config.model = 'video'
}
const request = {
audio: audio,
config: config,
};
const client = new speech.SpeechClient();
return client
.longRunningRecognize(request)
.then(data => {
const operation = data[0];
return operation.promise();
}).then(data => {
const response = data[0];
if(response.results) {
return storeSegmentInMeeting(response.results, noteId);
} else {
return null;
}
}).catch(err => {
return console.error('ERROR:', err);
});
I expect to get the confidence score for every word, so any ideas?
Upvotes: 0
Views: 515
Reputation: 1236
Ok so this probably won't work unless you switch to "V1P1BETA" version of the library. It has more features, including word-level confidence. I suggest you try that.
I can't tell if you're already doing that, so I'm sharing this just in case.
You need:
const speech = require('@google-cloud/speech').v1p1beta1;
Upvotes: 2