An example of server an API with Express, using the Google Cloud Speech-to-text API to transcribe audio.
You can test the API with Postman, and call the API with form-data
body and the following params.
audio
: An audio file withwav/linear
format, and the sample rate is44100
.
transcription
: Text transcriptionconfidence
: Confidence score
First, to install the dependices run:
yarn install
Then, export the credentials for the Google Cloud Platform on CLI:
export GOOGLE_APPLICATION_CREDENTIALS=<path to the json file>
Then, build and run the server:
yarn build
yarn start
Create a file called .env on the root directory and add the following to change the port and sample rate.
PORT=<port>
SAMPLE_RATE=<sample rate>