Speechmatics Real-Time API Client
Project description
Speechmatics Real-Time API Client
Async Python client for the Speechmatics Real-Time API.
Features
- Async-first design with synchronous wrappers for compatibility
- Comprehensive error handling with detailed error messages
- Type hints throughout for excellent IDE support and code safety
- Environment variable support for secure credential management
- Event-driven architecture for real-time transcript processing
- Simple connection management with clear error reporting
Installation
pip install speechmatics-rt
Quick Start
import asyncio
from speechmatics.rt import AsyncClient, ServerMessageType
async def main():
# Create a client using environment variable SPEECHMATICS_API_KEY
async with AsyncClient() as client:
# Register event handlers
@client.on(ServerMessageType.ADD_TRANSCRIPT)
def handle_final_transcript(msg):
print(f"Final: {msg['metadata']['transcript']}")
# Transcribe audio file
with open("audio.wav", "rb") as audio_file:
await client.transcribe(audio_file)
# Run the async function
asyncio.run(main())
Logging
The client supports logging with job id tracing for debugging. To increase logging verbosity, set DEBUG level in your example code:
import logging
import sys
logging.basicConfig(
level=logging.DEBUG,
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
handlers=[
logging.StreamHandler(sys.stdout)
]
)
Environment Variables
The client supports the following environment variables:
SPEECHMATICS_API_KEY: Your Speechmatics API keySPEECHMATICS_RT_URL: Custom API endpoint URL (optional)
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
speechmatics_rt-0.1.0.tar.gz
(19.7 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file speechmatics_rt-0.1.0.tar.gz.
File metadata
- Download URL: speechmatics_rt-0.1.0.tar.gz
- Upload date:
- Size: 19.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
802f7442ec154b193029aa4be26cbab6b2286db7617c1a20a2bcda90a6d92b76
|
|
| MD5 |
9f476027ce4cd9414bb73f1c0fc02c35
|
|
| BLAKE2b-256 |
5ee6aa89c5ec702a2042ac93195ab1416615945be729792f404eaa7c176a1a46
|
File details
Details for the file speechmatics_rt-0.1.0-py3-none-any.whl.
File metadata
- Download URL: speechmatics_rt-0.1.0-py3-none-any.whl
- Upload date:
- Size: 21.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8b54d2d84d85f2802b934b92ef3c1010ee1df104faeecaa8f5c9a48698beeab2
|
|
| MD5 |
fa1a0fb828eadc10b39d755803a85889
|
|
| BLAKE2b-256 |
bc3286967fed0c7e7e875758597d598ecf67fee09c01dcc4908885ed269f0daf
|