Python library and CLI for Speechmatics
Project description
speechmatics-python
![License](https://pypi-camo.freetls.fastly.net/8ede485ee1830ab55be8e2afd1d1af1291ab13b5/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d79656c6c6f772e737667)
Python client library and CLI for Speechmatics Realtime ASR v2 API.
Getting started
To install from source:
$ git clone https://github.com/speechmatics/speechmatics-python
$ cd speechmatics-python && python setup.py install
or with pip:
$ pip install -e git+https://github.com/speechmatics/speechmatics-python#egg=speechmatics-python
This can be added to requirements.txt
like so (eg. v0.0.11):
git+https://github.com/speechmatics/speechmatics-python@0.0.11#egg=speechmatics-python
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.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9126b17282889d21bc1cef195069d7fc0e319051d4e0d3fa176c32b4f4df04b2 |
|
MD5 | 44f6251e443b68f3e2716fe2f37ed73a |
|
BLAKE2b-256 | 825f1ee8de2f4a54f040dc24d4cc4b47f4da104906de5eecf6b669b76104eff0 |
Hashes for speechmatics_python-1.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8a7e4194c16bed718bf064a49fae8a798f68be82f113874823d61b78953aa0ab |
|
MD5 | fffb59bc03abd92b5c6722d6c440d516 |
|
BLAKE2b-256 | 0ab579b4969f553bba9046d87d5c829524ea6e3af2f358dd9629fee8d389dc3f |