Search This Blog

Friday, October 6, 2017

Google Speech API

Great service from google to transcript sound into text.
an easy way to use curl command below.

open command shell (cmd on windows)
set your google  API_KEY

set API_KEY=xxxxxxxxxxxx-xxxxxxxxxx

request.json file should contains such data
{
  "config": {
      "encoding":"FLAC",
      "sampleRateHertz": 16000,
      "languageCode": "en-US",
      "enableWordTimeOffsets": false
  },
  "audio": {
      "uri":"gs://cloud-samples-tests/speech/brooklyn.flac"
  }
}
run the command to get response

curl -s -X POST -H "Content-Type: application/json" --data-binary @request.json "https://speech.googleapis.com/v1/speech:recognize?key=%API_KEY%"

for long file (above 1 minute )use such command
curl -s -X POST -H "Content-Type: application/json" --data-binary @request.json "https://speech.googleapis.com/v1/speech:longrunningrecognize?key=%API_KEY%"

you will get response such as
{
  "name": "9111777455024812345"
}

use the name value to get result of the long process

curl -s -X GET  "https://speech.googleapis.com/v1/operations/9111777455024812345?key=%API_KEY%"


more info :
https://cloud.google.com/speech/docs/getting-started
https://codelabs.developers.google.com/codelabs/cloud-speech-intro/index.html#0


No comments: