Speech-to-Text Demo is a Node.js script to convert speech into text using Cloud Speech-to-Text.
$ GOOGLE_APPLICATION_CREDENTIALS=./serviceAccount.json node index.js -e 'FLAC' -u 'gs://cloud-samples-tests/speech/brooklyn.flac'
$ GOOGLE_APPLICATION_CREDENTIALS=./serviceAccount.json ts-node index.ts -e 'FLAC' -u 'gs://cloud-samples-tests/speech/brooklyn.flac'
serviceAccount.json
is a path of a JSON file that contains your GCP service account key. -e
and -u
are required options. -e
points to an encoding of an audio file. -u
points to a URI of an audio file, which should be a Google Cloud Storage URI.
Available options are as below:
Option | Option (short name) |
Required | Default | |
---|---|---|---|---|
--encoding |
-e |
✅ | Encoding of an audio file | |
--uri |
-u |
✅ | URI of an audio file | |
--languageCode |
-l |
en-US |
Language code of an audio file | |
--sampleRateHertz |
-s |
16000 |
Sample rate in Hertz of an audio file |