speechmatics-rt 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- speechmatics_rt-0.1.0/PKG-INFO +103 -0
- speechmatics_rt-0.1.0/README.md +65 -0
- speechmatics_rt-0.1.0/pyproject.toml +58 -0
- speechmatics_rt-0.1.0/setup.cfg +4 -0
- speechmatics_rt-0.1.0/speechmatics/__init__.py +0 -0
- speechmatics_rt-0.1.0/speechmatics/rt/__init__.py +51 -0
- speechmatics_rt-0.1.0/speechmatics/rt/_async_client.py +542 -0
- speechmatics_rt-0.1.0/speechmatics/rt/_events.py +152 -0
- speechmatics_rt-0.1.0/speechmatics/rt/_exceptions.py +63 -0
- speechmatics_rt-0.1.0/speechmatics/rt/_helpers.py +80 -0
- speechmatics_rt-0.1.0/speechmatics/rt/_logging.py +49 -0
- speechmatics_rt-0.1.0/speechmatics/rt/_models.py +551 -0
- speechmatics_rt-0.1.0/speechmatics/rt/_transport.py +377 -0
- speechmatics_rt-0.1.0/speechmatics_rt.egg-info/PKG-INFO +103 -0
- speechmatics_rt-0.1.0/speechmatics_rt.egg-info/SOURCES.txt +16 -0
- speechmatics_rt-0.1.0/speechmatics_rt.egg-info/dependency_links.txt +1 -0
- speechmatics_rt-0.1.0/speechmatics_rt.egg-info/requires.txt +16 -0
- speechmatics_rt-0.1.0/speechmatics_rt.egg-info/top_level.txt +2 -0
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: speechmatics-rt
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Speechmatics Real-Time API Client
|
|
5
|
+
Author-email: Speechmatics <support@speechmatics.com>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: homepage, https://github.com/speechmatics/speechmatics-python-sdk
|
|
8
|
+
Project-URL: documentation, https://docs.speechmatics.com/
|
|
9
|
+
Project-URL: repository, https://github.com/speechmatics/speechmatics-python-sdk
|
|
10
|
+
Project-URL: issues, https://github.com/speechmatics/speechmatics-python-sdk/issues
|
|
11
|
+
Keywords: speechmatics,speech-to-text,real-time,transcription,websocket
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Operating System :: OS Independent
|
|
20
|
+
Classifier: Topic :: Multimedia :: Sound/Audio :: Speech
|
|
21
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
22
|
+
Requires-Python: >=3.9
|
|
23
|
+
Description-Content-Type: text/markdown
|
|
24
|
+
Requires-Dist: websockets>=10.0
|
|
25
|
+
Requires-Dist: structlog
|
|
26
|
+
Provides-Extra: jwt
|
|
27
|
+
Requires-Dist: aiohttp; extra == "jwt"
|
|
28
|
+
Provides-Extra: dev
|
|
29
|
+
Requires-Dist: black; extra == "dev"
|
|
30
|
+
Requires-Dist: ruff; extra == "dev"
|
|
31
|
+
Requires-Dist: mypy; extra == "dev"
|
|
32
|
+
Requires-Dist: pre-commit; extra == "dev"
|
|
33
|
+
Requires-Dist: pytest; extra == "dev"
|
|
34
|
+
Requires-Dist: pytest-asyncio; extra == "dev"
|
|
35
|
+
Requires-Dist: pytest-cov; extra == "dev"
|
|
36
|
+
Requires-Dist: pytest-mock; extra == "dev"
|
|
37
|
+
Requires-Dist: build; extra == "dev"
|
|
38
|
+
|
|
39
|
+
# Speechmatics Real-Time API Client
|
|
40
|
+
|
|
41
|
+
Async Python client for the Speechmatics Real-Time API.
|
|
42
|
+
|
|
43
|
+
## Features
|
|
44
|
+
|
|
45
|
+
- **Async-first design** with synchronous wrappers for compatibility
|
|
46
|
+
- **Comprehensive error handling** with detailed error messages
|
|
47
|
+
- **Type hints throughout** for excellent IDE support and code safety
|
|
48
|
+
- **Environment variable support** for secure credential management
|
|
49
|
+
- **Event-driven architecture** for real-time transcript processing
|
|
50
|
+
- **Simple connection management** with clear error reporting
|
|
51
|
+
|
|
52
|
+
## Installation
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
pip install speechmatics-rt
|
|
56
|
+
|
|
57
|
+
```
|
|
58
|
+
## Quick Start
|
|
59
|
+
|
|
60
|
+
```python
|
|
61
|
+
import asyncio
|
|
62
|
+
from speechmatics.rt import AsyncClient, ServerMessageType
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
async def main():
|
|
66
|
+
# Create a client using environment variable SPEECHMATICS_API_KEY
|
|
67
|
+
async with AsyncClient() as client:
|
|
68
|
+
# Register event handlers
|
|
69
|
+
@client.on(ServerMessageType.ADD_TRANSCRIPT)
|
|
70
|
+
def handle_final_transcript(msg):
|
|
71
|
+
print(f"Final: {msg['metadata']['transcript']}")
|
|
72
|
+
|
|
73
|
+
# Transcribe audio file
|
|
74
|
+
with open("audio.wav", "rb") as audio_file:
|
|
75
|
+
await client.transcribe(audio_file)
|
|
76
|
+
|
|
77
|
+
# Run the async function
|
|
78
|
+
asyncio.run(main())
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## Logging
|
|
82
|
+
|
|
83
|
+
The client supports logging with job id tracing for debugging. To increase logging verbosity, set `DEBUG` level in your example code:
|
|
84
|
+
|
|
85
|
+
```python
|
|
86
|
+
import logging
|
|
87
|
+
import sys
|
|
88
|
+
|
|
89
|
+
logging.basicConfig(
|
|
90
|
+
level=logging.DEBUG,
|
|
91
|
+
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
|
|
92
|
+
handlers=[
|
|
93
|
+
logging.StreamHandler(sys.stdout)
|
|
94
|
+
]
|
|
95
|
+
)
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### Environment Variables
|
|
99
|
+
|
|
100
|
+
The client supports the following environment variables:
|
|
101
|
+
|
|
102
|
+
- `SPEECHMATICS_API_KEY`: Your Speechmatics API key
|
|
103
|
+
- `SPEECHMATICS_RT_URL`: Custom API endpoint URL (optional)
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# Speechmatics Real-Time API Client
|
|
2
|
+
|
|
3
|
+
Async Python client for the Speechmatics Real-Time API.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Async-first design** with synchronous wrappers for compatibility
|
|
8
|
+
- **Comprehensive error handling** with detailed error messages
|
|
9
|
+
- **Type hints throughout** for excellent IDE support and code safety
|
|
10
|
+
- **Environment variable support** for secure credential management
|
|
11
|
+
- **Event-driven architecture** for real-time transcript processing
|
|
12
|
+
- **Simple connection management** with clear error reporting
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
pip install speechmatics-rt
|
|
18
|
+
|
|
19
|
+
```
|
|
20
|
+
## Quick Start
|
|
21
|
+
|
|
22
|
+
```python
|
|
23
|
+
import asyncio
|
|
24
|
+
from speechmatics.rt import AsyncClient, ServerMessageType
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
async def main():
|
|
28
|
+
# Create a client using environment variable SPEECHMATICS_API_KEY
|
|
29
|
+
async with AsyncClient() as client:
|
|
30
|
+
# Register event handlers
|
|
31
|
+
@client.on(ServerMessageType.ADD_TRANSCRIPT)
|
|
32
|
+
def handle_final_transcript(msg):
|
|
33
|
+
print(f"Final: {msg['metadata']['transcript']}")
|
|
34
|
+
|
|
35
|
+
# Transcribe audio file
|
|
36
|
+
with open("audio.wav", "rb") as audio_file:
|
|
37
|
+
await client.transcribe(audio_file)
|
|
38
|
+
|
|
39
|
+
# Run the async function
|
|
40
|
+
asyncio.run(main())
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Logging
|
|
44
|
+
|
|
45
|
+
The client supports logging with job id tracing for debugging. To increase logging verbosity, set `DEBUG` level in your example code:
|
|
46
|
+
|
|
47
|
+
```python
|
|
48
|
+
import logging
|
|
49
|
+
import sys
|
|
50
|
+
|
|
51
|
+
logging.basicConfig(
|
|
52
|
+
level=logging.DEBUG,
|
|
53
|
+
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
|
|
54
|
+
handlers=[
|
|
55
|
+
logging.StreamHandler(sys.stdout)
|
|
56
|
+
]
|
|
57
|
+
)
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### Environment Variables
|
|
61
|
+
|
|
62
|
+
The client supports the following environment variables:
|
|
63
|
+
|
|
64
|
+
- `SPEECHMATICS_API_KEY`: Your Speechmatics API key
|
|
65
|
+
- `SPEECHMATICS_RT_URL`: Custom API endpoint URL (optional)
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0.0"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "speechmatics-rt"
|
|
7
|
+
dynamic = ["version"]
|
|
8
|
+
description = "Speechmatics Real-Time API Client"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
authors = [{ name = "Speechmatics", email = "support@speechmatics.com" }]
|
|
11
|
+
license = "MIT"
|
|
12
|
+
requires-python = ">=3.9"
|
|
13
|
+
dependencies = ["websockets>=10.0", "structlog"]
|
|
14
|
+
classifiers = [
|
|
15
|
+
"Development Status :: 4 - Beta",
|
|
16
|
+
"Intended Audience :: Developers",
|
|
17
|
+
"Programming Language :: Python :: 3",
|
|
18
|
+
"Programming Language :: Python :: 3.9",
|
|
19
|
+
"Programming Language :: Python :: 3.10",
|
|
20
|
+
"Programming Language :: Python :: 3.11",
|
|
21
|
+
"Programming Language :: Python :: 3.12",
|
|
22
|
+
"Operating System :: OS Independent",
|
|
23
|
+
"Topic :: Multimedia :: Sound/Audio :: Speech",
|
|
24
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
25
|
+
]
|
|
26
|
+
keywords = [
|
|
27
|
+
"speechmatics",
|
|
28
|
+
"speech-to-text",
|
|
29
|
+
"real-time",
|
|
30
|
+
"transcription",
|
|
31
|
+
"websocket",
|
|
32
|
+
]
|
|
33
|
+
|
|
34
|
+
[project.optional-dependencies]
|
|
35
|
+
jwt = ["aiohttp"]
|
|
36
|
+
dev = [
|
|
37
|
+
"black",
|
|
38
|
+
"ruff",
|
|
39
|
+
"mypy",
|
|
40
|
+
"pre-commit",
|
|
41
|
+
"pytest",
|
|
42
|
+
"pytest-asyncio",
|
|
43
|
+
"pytest-cov",
|
|
44
|
+
"pytest-mock",
|
|
45
|
+
"build",
|
|
46
|
+
]
|
|
47
|
+
|
|
48
|
+
[project.urls]
|
|
49
|
+
homepage = "https://github.com/speechmatics/speechmatics-python-sdk"
|
|
50
|
+
documentation = "https://docs.speechmatics.com/"
|
|
51
|
+
repository = "https://github.com/speechmatics/speechmatics-python-sdk"
|
|
52
|
+
issues = "https://github.com/speechmatics/speechmatics-python-sdk/issues"
|
|
53
|
+
|
|
54
|
+
[tool.setuptools.dynamic]
|
|
55
|
+
version = { attr = "speechmatics.rt.__version__" }
|
|
56
|
+
|
|
57
|
+
[tool.setuptools.packages.find]
|
|
58
|
+
where = ["."]
|
|
File without changes
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
__version__ = "0.1.0"
|
|
2
|
+
|
|
3
|
+
from ._async_client import AsyncClient
|
|
4
|
+
from ._events import EventEmitter
|
|
5
|
+
from ._exceptions import AudioError
|
|
6
|
+
from ._exceptions import AuthenticationError
|
|
7
|
+
from ._exceptions import ConfigurationError
|
|
8
|
+
from ._exceptions import ConnectionError
|
|
9
|
+
from ._exceptions import EndOfTranscriptError
|
|
10
|
+
from ._exceptions import ForceEndSession
|
|
11
|
+
from ._exceptions import SessionError
|
|
12
|
+
from ._exceptions import TimeoutError
|
|
13
|
+
from ._exceptions import TranscriptionError
|
|
14
|
+
from ._exceptions import TransportError
|
|
15
|
+
from ._models import AudioEncoding
|
|
16
|
+
from ._models import AudioEventsConfig
|
|
17
|
+
from ._models import AudioFormat
|
|
18
|
+
from ._models import ClientMessageType
|
|
19
|
+
from ._models import ConnectionConfig
|
|
20
|
+
from ._models import OperatingPoint
|
|
21
|
+
from ._models import ServerMessageType
|
|
22
|
+
from ._models import SessionInfo
|
|
23
|
+
from ._models import TranscriptionConfig
|
|
24
|
+
from ._models import TranscriptResult
|
|
25
|
+
from ._models import TranslationConfig
|
|
26
|
+
|
|
27
|
+
__all__ = [
|
|
28
|
+
"AsyncClient",
|
|
29
|
+
"EventEmitter",
|
|
30
|
+
"AudioFormat",
|
|
31
|
+
"AudioEventsConfig",
|
|
32
|
+
"TranscriptionConfig",
|
|
33
|
+
"TranslationConfig",
|
|
34
|
+
"ConnectionConfig",
|
|
35
|
+
"SessionInfo",
|
|
36
|
+
"TranscriptResult",
|
|
37
|
+
"AudioEncoding",
|
|
38
|
+
"ClientMessageType",
|
|
39
|
+
"ServerMessageType",
|
|
40
|
+
"OperatingPoint",
|
|
41
|
+
"ConfigurationError",
|
|
42
|
+
"AuthenticationError",
|
|
43
|
+
"ConnectionError",
|
|
44
|
+
"TransportError",
|
|
45
|
+
"TranscriptionError",
|
|
46
|
+
"AudioError",
|
|
47
|
+
"SessionError",
|
|
48
|
+
"TimeoutError",
|
|
49
|
+
"EndOfTranscriptError",
|
|
50
|
+
"ForceEndSession",
|
|
51
|
+
]
|