I have viewed the other questions and answers related to this issue, but in a context = different from mine. I adapted this code from the Google and only changed audio file encoding type, sampling rate and language code. Again, this file is coming directly from Google, so it can't be that I have introduced weird stuff. I have also downloaded the appropriate @google-cloud/speech require needed line 1. Given all this, can someone tell me why this is throwing the error shown in the title of this message related to "await" being valid in async functions?
// Imports the Google Cloud client library
const speech = require('@google-cloud/speech');
// Creates a client
const client = new speech.SpeechClient();
/**
* TODO(developer): Uncomment the following lines before running the sample.
*/
const gcsUri = 'gs://legrandtimonier_de/mac_test.flac';
const encoding = 'FLAC';
const sampleRateHertz = 44100;
const languageCode = 'de-DE';
const config = {
encoding: encoding,
sampleRateHertz: sampleRateHertz,
languageCode: languageCode,
};
const audio = {
uri: gcsUri,
};
const request = {
config: config,
audio: audio,
};
// Detects speech in the audio file. This creates a recognition job that you
// can wait for now, or get its result later.
const [operation] = await client.longRunningRecognize(request);
//const [operation] = client.longRunningRecognize(request);
// Get a Promise representation of the final result of the job
const [response] = await operation.promise();
const [response] = operation.promise();
const transcription = response.results
.map(result => result.alternatives[0].transcript)
.join('\n');
console.log(`Transcription: ${transcription}`);