• Jacek Jarmulak

"Hello World" Example

Updated: Apr 3

In this post we show in three steps what is needed to run your first transcription using Voicegain API.

We assume that you already signed up for Voicegain account and logged into the portal.


Step 1: Create new Context

Main reason to create new Context is to establish new authentication realm. Access to each Context can be separately controlled, so it is easy to disable access to certain Context without affecting other Contexts.

Contexts are also used for specifying default ASR settings.

You can create a new Context from the Context Dash



Step 2: Generate Authentication token

Voicegain APIs use JWT (JSON Web Tokens) to identify and authenticate the account making the request. In order to make API requests you need to generate a JWT which can easily be done from the portal.



Step 3: Run the curl command

Below is the complete input and output from curl command that submits a Web API request to Voicegain Synchronous Speech-to-Text API https://api.voicegain.ai/v1/asr/transcribe


$ curl -i -H 'Content-Type: application/json' \
> -H 'Accept: application/json' \
> -H "Authorization: Bearer  eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJodHRwczovL2FwaS52b2ljZWdhaW4uYWkvdjEiLCJzdWIiOiIwMTdkYTYzMy1iZTgwLTRhMjQtOWI2Yi03NTkzYzRhZjZhMjgifQ.8Vi9K4Or0sFPbieMusA6MHFRvojlQof1WazsClJFFeI" \
> -d '{"audio" : {"source" : {"fromUrl" : {"url" : "https://f002.backblazeb2.com/file/voicegain-cdn/499632__iceofdoom__hello-is-anyone-out-there-curious-male-16kHz-mono.wav" }}}}' \
> https://api.voicegain.ai/v1/asr/transcribe
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   385    0   213  100   172     34     28  0:00:06  0:00:06 --:--:--    57HTTP/2 200
server: openresty
date: Thu, 19 Mar 2020 22:42:24 GMT
content-type: application/json;charset=UTF-8
vary: Accept-Encoding
strict-transport-security: max-age=15724800; includeSubDomains

{"session":{"sessionId":"0-0k7zcawfu003b9ug37u1x26pbjp8"},"result":{"status":"MATCH","lastEvent":"RECOGNITION-COMPLETE","alternatives":[{"utterance":"hello is any one out there","confidence":0.8323419690132141}]}}


In this case, the audio to be transcribed was retrieved from a URL. Audio can alternatively also be submitted in-line (within request).


For asynchronous transcription requests it is also possible to stream the audio, e.g. via websocket. You can see some of Voicegain API documentation at: https://www.voicegain.ai/api


21 views