Python library and CLI for Speechmatics
Project description
speechmatics-python
Python client library and CLI for Speechmatics Realtime ASR v2 API.
Getting started
To install from PyPI:
$ pip install speechmatics-python
To install from source:
$ git clone https://github.com/speechmatics/speechmatics-python
$ cd speechmatics-python && python setup.py install
Requirements
- Python 3.7+
Example command-line usage
-
A normal real time session using a .wav file as the input audio
# Point URL to the local instance of Speechmatics $ URL=ws://realtimeappliance.yourcompany:9000/v2 $ speechmatics transcribe --url $URL --lang en --ssl-mode none example_audio.wav
-
Show the messages that are going over the websocket connection
$ speechmatics -v transcribe --url $URL --lang en --ssl-mode none example_audio.wav
-
The CLI also accepts an audio stream on standard input; transcribe the piped input audio
$ cat example_audio.wav | speechmatics transcribe --ssl-mode none --url $URL --lang en -
-
Pipe audio directly from the microphone (example uses MacOS with ffmpeg)
List available input devices with
$ ffmpeg -f avfoundation -list_devices true -i ""
There needs to be at least one available microphone attached to your computer. The command below gets the microphone input and pipes it to the transcriber. You may need to change the sample rate to match the sample rate that your machine records at. You may also need to replace
:default
with something like:0
or:1
if you want to use a specific microphone.$ ffmpeg -loglevel quiet -f avfoundation -i ":default" -f f32le -acodec pcm_f32le -ar 44100 - \ > | speechmatics transcribe --ssl-mode none --url $URL --raw pcm_f32le --sample-rate 44100 --lang en -
-
Transcribe in real-time with partials (example uses Ubuntu with ALSA). In this mode, the transcription engine produces words instantly, which may get updated as additional context becomes available.
List available input devices with
$ cat /proc/asound/cards
Record microphone audio and pipe to transcriber.
$ ffmpeg -loglevel quiet -f alsa -i hw:0 -f f32le -acodec pcm_f32le -ar 44100 - \ | speechmatics transcribe --ssl-mode none --url $URL --enable-partials --raw pcm_f32le --sample-rate 44100 --lang en -
API documentation
Please see https://speechmatics.github.io/speechmatics-python/.
Testing
To install development dependencies and run tests
$ pip install -r requirements-dev.txt
$ make test
Support
If you have any issues with this library or encounter any bugs then please get in touch with us at support@speechmatics.com.
License: MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for speechmatics-python-1.0.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 38a73b1dfcddcbe41204da54ec398ffd14fb246c87fae9c7f0afd572e53490be |
|
MD5 | 73ef8515dafc245a7874da279c7fc170 |
|
BLAKE2b-256 | 14cf606af2a02486b1e60521216bfe17e8bcfcd05131a009d327dbc9bf1ce6c3 |
Hashes for speechmatics_python-1.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e984cea8d37d914affb73772b0f8eef2dd09ad29f6f17bd1f9f58fd62201821a |
|
MD5 | d81e67b95bcb5555dc8916e616c9b55f |
|
BLAKE2b-256 | b3c92d567ba002abf3d2cefa40d616d93e3b0406a6bb4141b32a305365f82908 |