Quickstart#
1. Create Soniox Account#
Create a free Soniox Account to obtain an API key. The API key gives you free access to Soniox API services. You can find your API key under API Keys tab for a given project in Soniox Console.
Soniox Account is free of charge and does not require credit card information. You get 300 minutes of free speech recognition AI services through Soniox API. If you require additional free usage, contact us, and we will assign you additional free minutes.
2. Download Examples#
Clone our soniox_examples GitHub repository with all the code examples and test audio files. We will refer to these examples and audio files throughout our how-to guides.
git clone https://github.com/soniox/soniox_examples.git
Enter the directory containing examples for your programming language.
cd soniox_examples/python
cd soniox_examples/node
cd soniox_examples/csharp
We provide a Javascript client library that enables you to integrate with Soniox API service directly from your web application.
See Web Library section for more information.
We provide a WebSocket-based API for Soniox Speech Service.
Please refer to the WebSocket section for more information.
We provide a gRPC-based API for Soniox Speech Service.
Please refer to the gRPC section for more information.
3. Install Client Library#
Choose any of our available client libraries to ease the integration of Soniox API into your application.
Requirements: Python 3.7 or higher.
The Soniox Python client library is published on PyPI: soniox.
Create and activate venv
python3 -m venv venv
source venv/bin/activate
Install packages
python3 -m pip install -U pip
python3 -m pip install -U setuptools wheel
python3 -m pip install -U soniox
Requirements: Node.js v14 or higher.
The Soniox Node client library is published on npm: @soniox/soniox-node.
Install packages
npm install @soniox/soniox-node
Requirements: .NET 6 or newer.
The Soniox C# client library is published on NuGet: Soniox.Client.
There is no additional setup needed to run the examples. To use the library in your project, add package
references to the .csproj
file like in the examples:
<PackageReference Include="Google.Protobuf" Version="3.22.1" />
<PackageReference Include="Soniox.Client" Version="1.1.0" />
4. Authenticate#
To authenticate your requests, you have to specify the API key. You can find your API key under API Keys tab for a given project in Soniox Console.
You can set the API key using the SONIOX_API_KEY
environment variable, which will be automatically
used by the client library.
export SONIOX_API_KEY=<YOUR_API_KEY>
In your application, you can alternatively specify the API key in code when initializing
the SpeechClient
, as shown below.
from soniox.speech_service import Client
with SpeechClient(api_key="<YOUR-API-KEY>") as client:
...
const { SpeechClient } = require("@soniox/soniox-node");
const speechClient = new SpeechClient({ api_key: "<YOUR-API-KEY>" });
using var client = new SpeechClient(apiKey: "<YOUR-API-KEY>");
5. Transcribe#
This example will transcribe a short audio file and print out the recognized words.
Run:
python3 transcribe_file_short.py
Output
Text: He was two years out from the East and had not yet forgotten to be homesick at times
Tokens:
'He' 317 60
' ' 617 0
'was' 617 60
' ' 857 0
'two' 857 60
...
Run
node transcribe_file_short.js
Output
Text: He was two years out from the East and had not yet forgotten to be homesick at times
Tokens:
'He' 317 60
' ' 617 0
'was' 617 60
' ' 857 0
'two' 857 60
...
Run
cd TranscribeFileShort
dotnet run
Output
Text: He was two years out from the East and had not yet forgotten to be homesick at times
Tokens:
'He' 317 60
' ' 617 0
'was' 617 60
' ' 857 0
'two' 857 60
...