speechmatics-voice 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.
@@ -0,0 +1,140 @@
1
+ Metadata-Version: 2.4
2
+ Name: speechmatics-voice
3
+ Version: 0.1.0
4
+ Summary: Speechmatics Voice Agent Python client for Real-Time API
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,conversational-ai,voice,agents,websocket,real-time,pipecat,livekit
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
+ Provides-Extra: dev
26
+ Requires-Dist: black; extra == "dev"
27
+ Requires-Dist: ruff; extra == "dev"
28
+ Requires-Dist: mypy; extra == "dev"
29
+ Requires-Dist: pre-commit; extra == "dev"
30
+ Requires-Dist: pytest; extra == "dev"
31
+ Requires-Dist: pytest-asyncio; extra == "dev"
32
+ Requires-Dist: pytest-cov; extra == "dev"
33
+ Requires-Dist: pytest-mock; extra == "dev"
34
+ Requires-Dist: build; extra == "dev"
35
+
36
+ # Voice Agent Python client for Speechmatics Real-Time API
37
+
38
+ [![License](https://img.shields.io/badge/license-MIT-yellow.svg)](https://github.com/speechmatics/speechmatics-python-voice/blob/master/LICENSE)
39
+
40
+ An SDK for working with the Speechmatics Real-Time API optimised for use in voice agents or transcription services.
41
+
42
+ This uses the Python Real-Time API to process the transcription results from the STT engine and combine them into manageable segments of audio. Taking advantage of speaker diarization, the transcription is grouped into individual speakers, with advanced options to focus on and/or ignore specific speakers.
43
+
44
+ See [OVERVIEW.md](OVERVIEW.md) for more information.
45
+
46
+ ## Installation
47
+
48
+ ```bash
49
+ pip install speechmatics-voice
50
+ ```
51
+
52
+ ## Requirements
53
+
54
+ You must have a valid Speechmatics API key to use this SDK. You can get one from the [Speechmatics Console](https://console.speechmatics.com).
55
+
56
+ Store this as `SPEECHMATICS_API_KEY` environment variable in your `.env` file or use `export SPEECHMATICS_API_KEY="your_api_key_here"` in your terminal.
57
+
58
+ ## Quick Start
59
+
60
+ Below is a basic example of how to use the SDK to transcribe audio from a microphone.
61
+
62
+ ```python
63
+ import asyncio
64
+ from speechmatics.rt import Microphone
65
+ from speechmatics.voice import (
66
+ VoiceAgentClient,
67
+ VoiceAgentConfig,
68
+ EndOfUtteranceMode,
69
+ AgentServerMessageType,
70
+ SpeakerSegment,
71
+ )
72
+
73
+ async def main():
74
+ # Configure the voice agent
75
+ config = VoiceAgentConfig(
76
+ end_of_utterance_silence_trigger=0.5,
77
+ enable_diarization=True,
78
+ end_of_utterance_mode=EndOfUtteranceMode.ADAPTIVE,
79
+ )
80
+
81
+ # Initialize microphone
82
+ mic = Microphone(
83
+ sample_rate=16000,
84
+ chunk_size=160,
85
+ )
86
+
87
+ if not mic.start():
88
+ print("Microphone not available")
89
+ return
90
+
91
+ # Create client and register event handlers
92
+ async with VoiceAgentClient(config=config) as client:
93
+
94
+ # Handle interim transcription segments
95
+ @client.on(AgentServerMessageType.ADD_INTERIM_SEGMENTS)
96
+ def handle_interim_segments(message):
97
+ segments: list[SpeakerSegment] = message["segments"]
98
+ for segment in segments:
99
+ print(f"Speaker {segment.speaker_id}: {segment.text}")
100
+
101
+ # Handle finalized transcription segments
102
+ @client.on(AgentServerMessageType.ADD_SEGMENTS)
103
+ def handle_final_segments(message):
104
+ segments: list[SpeakerSegment] = message["segments"]
105
+ for segment in segments:
106
+ print(f"Speaker {segment.speaker_id}: {segment.text}")
107
+
108
+ # Handle user started speaking event
109
+ @client.on(AgentServerMessageType.USER_SPEECH_STARTED)
110
+ def handle_speech_started(message):
111
+ print("User started speaking")
112
+
113
+ # Handle user stopped speaking event
114
+ @client.on(AgentServerMessageType.USER_SPEECH_ENDED)
115
+ def handle_speech_ended(message):
116
+ print("User stopped speaking")
117
+
118
+ # Connect and start processing audio
119
+ await client.connect()
120
+
121
+ while True:
122
+ frame = await mic.read(160)
123
+ await client.send_audio(frame)
124
+
125
+ if __name__ == "__main__":
126
+ asyncio.run(main())
127
+ ```
128
+
129
+ ## Examples
130
+
131
+ The `examples/` directory contains practical demonstrations of the Voice Agent SDK. See the README in the `examples/voice` directory for more information.
132
+
133
+ ## Documentation
134
+
135
+ - **SDK Overview**: See [OVERVIEW.md](OVERVIEW.md) for comprehensive API documentation
136
+ - **Speechmatics API**: https://docs.speechmatics.com
137
+
138
+ ## License
139
+
140
+ [MIT](LICENSE)
@@ -0,0 +1,105 @@
1
+ # Voice Agent Python client for Speechmatics Real-Time API
2
+
3
+ [![License](https://img.shields.io/badge/license-MIT-yellow.svg)](https://github.com/speechmatics/speechmatics-python-voice/blob/master/LICENSE)
4
+
5
+ An SDK for working with the Speechmatics Real-Time API optimised for use in voice agents or transcription services.
6
+
7
+ This uses the Python Real-Time API to process the transcription results from the STT engine and combine them into manageable segments of audio. Taking advantage of speaker diarization, the transcription is grouped into individual speakers, with advanced options to focus on and/or ignore specific speakers.
8
+
9
+ See [OVERVIEW.md](OVERVIEW.md) for more information.
10
+
11
+ ## Installation
12
+
13
+ ```bash
14
+ pip install speechmatics-voice
15
+ ```
16
+
17
+ ## Requirements
18
+
19
+ You must have a valid Speechmatics API key to use this SDK. You can get one from the [Speechmatics Console](https://console.speechmatics.com).
20
+
21
+ Store this as `SPEECHMATICS_API_KEY` environment variable in your `.env` file or use `export SPEECHMATICS_API_KEY="your_api_key_here"` in your terminal.
22
+
23
+ ## Quick Start
24
+
25
+ Below is a basic example of how to use the SDK to transcribe audio from a microphone.
26
+
27
+ ```python
28
+ import asyncio
29
+ from speechmatics.rt import Microphone
30
+ from speechmatics.voice import (
31
+ VoiceAgentClient,
32
+ VoiceAgentConfig,
33
+ EndOfUtteranceMode,
34
+ AgentServerMessageType,
35
+ SpeakerSegment,
36
+ )
37
+
38
+ async def main():
39
+ # Configure the voice agent
40
+ config = VoiceAgentConfig(
41
+ end_of_utterance_silence_trigger=0.5,
42
+ enable_diarization=True,
43
+ end_of_utterance_mode=EndOfUtteranceMode.ADAPTIVE,
44
+ )
45
+
46
+ # Initialize microphone
47
+ mic = Microphone(
48
+ sample_rate=16000,
49
+ chunk_size=160,
50
+ )
51
+
52
+ if not mic.start():
53
+ print("Microphone not available")
54
+ return
55
+
56
+ # Create client and register event handlers
57
+ async with VoiceAgentClient(config=config) as client:
58
+
59
+ # Handle interim transcription segments
60
+ @client.on(AgentServerMessageType.ADD_INTERIM_SEGMENTS)
61
+ def handle_interim_segments(message):
62
+ segments: list[SpeakerSegment] = message["segments"]
63
+ for segment in segments:
64
+ print(f"Speaker {segment.speaker_id}: {segment.text}")
65
+
66
+ # Handle finalized transcription segments
67
+ @client.on(AgentServerMessageType.ADD_SEGMENTS)
68
+ def handle_final_segments(message):
69
+ segments: list[SpeakerSegment] = message["segments"]
70
+ for segment in segments:
71
+ print(f"Speaker {segment.speaker_id}: {segment.text}")
72
+
73
+ # Handle user started speaking event
74
+ @client.on(AgentServerMessageType.USER_SPEECH_STARTED)
75
+ def handle_speech_started(message):
76
+ print("User started speaking")
77
+
78
+ # Handle user stopped speaking event
79
+ @client.on(AgentServerMessageType.USER_SPEECH_ENDED)
80
+ def handle_speech_ended(message):
81
+ print("User stopped speaking")
82
+
83
+ # Connect and start processing audio
84
+ await client.connect()
85
+
86
+ while True:
87
+ frame = await mic.read(160)
88
+ await client.send_audio(frame)
89
+
90
+ if __name__ == "__main__":
91
+ asyncio.run(main())
92
+ ```
93
+
94
+ ## Examples
95
+
96
+ The `examples/` directory contains practical demonstrations of the Voice Agent SDK. See the README in the `examples/voice` directory for more information.
97
+
98
+ ## Documentation
99
+
100
+ - **SDK Overview**: See [OVERVIEW.md](OVERVIEW.md) for comprehensive API documentation
101
+ - **Speechmatics API**: https://docs.speechmatics.com
102
+
103
+ ## License
104
+
105
+ [MIT](LICENSE)
@@ -0,0 +1,67 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "speechmatics-voice"
7
+ dynamic = ["version"]
8
+ description = "Speechmatics Voice Agent Python client for Real-Time API"
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"]
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
+ "conversational-ai",
29
+ "voice",
30
+ "agents",
31
+ "websocket",
32
+ "real-time",
33
+ "pipecat",
34
+ "livekit"
35
+ ]
36
+
37
+ [project.optional-dependencies]
38
+ dev = [
39
+ "black",
40
+ "ruff",
41
+ "mypy",
42
+ "pre-commit",
43
+ "pytest",
44
+ "pytest-asyncio",
45
+ "pytest-cov",
46
+ "pytest-mock",
47
+ "build",
48
+ ]
49
+
50
+ [project.urls]
51
+ homepage = "https://github.com/speechmatics/speechmatics-python-sdk"
52
+ documentation = "https://docs.speechmatics.com/"
53
+ repository = "https://github.com/speechmatics/speechmatics-python-sdk"
54
+ issues = "https://github.com/speechmatics/speechmatics-python-sdk/issues"
55
+
56
+ [tool.setuptools.dynamic]
57
+ version = { attr = "speechmatics.voice.__version__" }
58
+
59
+ [tool.setuptools.package-data]
60
+ "speechmatics.voice" = ["py.typed"]
61
+
62
+ [tool.setuptools.packages.find]
63
+ where = ["."]
64
+
65
+ [[tool.mypy.overrides]]
66
+ module = ["speechmatics.rt.*"]
67
+ ignore_missing_imports = true
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1 @@
1
+ __path__ = __import__("pkgutil").extend_path(__path__, __name__)
@@ -0,0 +1,59 @@
1
+ #
2
+ # Copyright (c) 2025, Speechmatics / Cantab Research Ltd
3
+ #
4
+
5
+
6
+ """Voice Agents SDK.
7
+
8
+ A comprehensive set of utility classes tailored for Voice Agents and
9
+ using the Speechmatics Python Real-Time SDK, including the processing of
10
+ partial and final transcription from the STT engine into accumulated
11
+ transcriptions with flags to indicate changes between messages, etc.
12
+ """
13
+
14
+ __version__ = "0.1.0"
15
+
16
+ from speechmatics.rt import AudioEncoding
17
+ from speechmatics.rt import AudioFormat
18
+ from speechmatics.rt import OperatingPoint
19
+
20
+ from ._client import VoiceAgentClient
21
+ from ._models import AdditionalVocabEntry
22
+ from ._models import AgentClientMessageType
23
+ from ._models import AgentServerMessageType
24
+ from ._models import AnnotationFlags
25
+ from ._models import AnnotationResult
26
+ from ._models import DiarizationFocusMode
27
+ from ._models import DiarizationKnownSpeaker
28
+ from ._models import DiarizationSpeakerConfig
29
+ from ._models import EndOfUtteranceMode
30
+ from ._models import SpeakerSegment
31
+ from ._models import SpeakerVADStatus
32
+ from ._models import SpeechFragment
33
+ from ._models import VoiceAgentConfig
34
+
35
+ __all__ = [
36
+ # SDK
37
+ "__version__",
38
+ # Conversation config
39
+ "VoiceAgentConfig",
40
+ "EndOfUtteranceMode",
41
+ "DiarizationSpeakerConfig",
42
+ "DiarizationFocusMode",
43
+ "AdditionalVocabEntry",
44
+ "DiarizationKnownSpeaker",
45
+ "AudioEncoding",
46
+ "AudioFormat",
47
+ "OperatingPoint",
48
+ # Transcription models
49
+ "AnnotationFlags",
50
+ "AnnotationResult",
51
+ "SpeakerSegment",
52
+ "SpeechFragment",
53
+ # Events
54
+ "SpeakerVADStatus",
55
+ # Client
56
+ "VoiceAgentClient",
57
+ "AgentClientMessageType",
58
+ "AgentServerMessageType",
59
+ ]