Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ assignees: ""

- **Package Name**: (e.g., speechmatics-rt, speechmatics-batch, speechmatics-voice)
- **Package Version**: (e.g., 1.0.0)
- **Python Version**: (e.g., 3.9, 3.10, 3.11, 3.12, 3.13)
- **Python Version**: (e.g., 3.10, 3.11, 3.12, 3.13, 3.14)
- **Operating System**: (e.g., Windows 10, macOS 12, Ubuntu 20.04)

**Describe the bug**
Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/question.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ assignees: ""

- **Package Name**: (e.g., speechmatics-rt, speechmatics-batch, speechmatics-voice)
- **Package Version**: (e.g., 1.0.0)
- **Python Version**: (e.g., 3.9, 3.10, 3.11, 3.12, 3.13)
- **Python Version**: (e.g., 3.10, 3.11, 3.12, 3.13, 3.14)
- **Operating System**: (e.g., Windows 10, macOS 12, Ubuntu 20.04)

**Specific question**
Expand Down
2 changes: 1 addition & 1 deletion .github/RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,5 +184,5 @@ No manual secrets are required as the workflows use OIDC for PyPI authentication

Both packages are tested against:

- Python versions: 3.9, 3.10, 3.11, 3.12, 3.13
- Python versions: 3.10, 3.11, 3.12, 3.13, 3.14
- Operating system: Ubuntu (latest)
4 changes: 2 additions & 2 deletions .github/workflows/release-agent-stt.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ jobs:
echo "Extracted version: $VERSION"

test-agent-stt:
runs-on: ubuntu-24.04
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release-batch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ jobs:
echo "Extracted version: $VERSION"

test-batch:
runs-on: ubuntu-24.04
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release-flow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ jobs:
echo "Extracted version: $VERSION"

test-flow:
runs-on: ubuntu-24.04
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release-rt.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ jobs:
echo "Extracted version: $VERSION"

test-rt:
runs-on: ubuntu-24.04
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release-tts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ jobs:
echo "Extracted version: $VERSION"

test-tts:
runs-on: ubuntu-24.04
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release-voice.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ jobs:
echo "Extracted version: $VERSION"

test-voice:
runs-on: ubuntu-24.04
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
Expand Down
20 changes: 10 additions & 10 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ permissions:
jobs:
test-rt:
name: Test RT SDK
runs-on: ubuntu-24.04
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
Expand All @@ -33,11 +33,11 @@ jobs:

test-batch:
name: Test Batch SDK
runs-on: ubuntu-24.04
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
Expand All @@ -54,11 +54,11 @@ jobs:

test-agent-stt:
name: Test Agent STT SDK
runs-on: ubuntu-24.04
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
Expand All @@ -75,11 +75,11 @@ jobs:

test-voice:
name: Test Voice Agent SDK
runs-on: ubuntu-24.04
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
Expand All @@ -96,11 +96,11 @@ jobs:

test-tts:
name: Test TTS SDK
runs-on: ubuntu-24.04
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ repos:
- id: black
name: black
files: ^sdk/.*/speechmatics/
args: [--line-length=120, --target-version=py39]
args: [--line-length=120, --target-version=py310]

- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.1.9
Expand Down
3 changes: 1 addition & 2 deletions examples/agent_stt/realtime_file/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import asyncio
import time
import wave
from typing import Optional

from speechmatics.agent_stt import DEFAULT_CHUNK_SIZE
from speechmatics.agent_stt import SUPPORTED_SAMPLE_RATES
Expand Down Expand Up @@ -69,7 +68,7 @@ def start(self) -> None:
def elapsed(self) -> float:
return time.monotonic() - self._started_at

def log(self, tag: str, text: str, *, audio_time: Optional[float] = None, record: bool = False) -> None:
def log(self, tag: str, text: str, *, audio_time: float | None = None, record: bool = False) -> None:
lag = ""
if audio_time is not None:
behind = self.elapsed - audio_time
Expand Down
11 changes: 3 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ extraPaths = ["sdk/agent_stt", "sdk/batch", "sdk/flow", "sdk/rt", "sdk/tts", "sd

[tool.black]
line-length = 120
target-version = ['py39']
target-version = ['py310']
include = '\.pyi?$'
extend-exclude = '''
/(
Expand All @@ -22,7 +22,7 @@ extend-exclude = '''

[tool.ruff]
line-length = 120
target-version = "py39"
target-version = "py310"

[tool.ruff.lint]
select = [
Expand All @@ -40,24 +40,19 @@ ignore = [
"B008", # do not perform function calls in argument defaults
"E203", # whitespace before ':'
"N818", # Exception name should end with Error - we have ForceEndSession by design
"UP007", # Use X | Y for type annotations - we support Python 3.9
"B904", # Within except clause, raise exceptions with raise ... from err
"SIM105", # Use contextlib.suppress - keep explicit for clarity
"SIM108", # Use ternary operator - keep explicit for readability
"SIM117", # Use single with statement - keep nested for clarity
"E501", # Line too long - handled by black
]

[tool.ruff.lint.pyupgrade]
# Preserve types, even if a file imports `from __future__ import annotations`.
keep-runtime-typing = true

[tool.ruff.lint.isort]
known-first-party = ["speechmatics"]
force-single-line = true

[tool.mypy]
python_version = "3.9"
python_version = "3.10"
explicit_package_bases = true
namespace_packages = true
warn_return_any = true
Expand Down
5 changes: 3 additions & 2 deletions sdk/agent_stt/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,17 @@ description = "Speechmatics Agent STT Python client for agent transcription"
readme = "README.md"
authors = [{ name = "Speechmatics", email = "support@speechmatics.com" }]
license = "MIT"
requires-python = ">=3.9"
requires-python = ">=3.10"
dependencies = ["speechmatics-rt>=1.1.1"]
classifiers = [
"Development Status :: 4 - Beta",
"Intended Audience :: Developers",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
"Operating System :: OS Independent",
"Topic :: Multimedia :: Sound/Audio :: Speech",
"Topic :: Software Development :: Libraries :: Python Modules",
Expand Down
51 changes: 25 additions & 26 deletions sdk/agent_stt/speechmatics/agent_stt/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import time
from typing import Any
from typing import BinaryIO
from typing import Optional

from speechmatics.rt import AsyncClient as RTAsyncClient
from speechmatics.rt import AudioEncoding
Expand Down Expand Up @@ -90,15 +89,15 @@ class AgentSttAsyncClient(RTAsyncClient):

def __init__(
self,
auth: Optional[AuthBase] = None,
auth: AuthBase | None = None,
*,
api_key: Optional[str] = None,
url: Optional[str] = None,
app: Optional[str] = None,
transcription_config: Optional[RTTranscriptionConfig] = None,
turn_config: Optional[TurnConfig] = None,
audio_format: Optional[AudioFormat] = None,
conn_config: Optional[ConnectionConfig] = None,
api_key: str | None = None,
url: str | None = None,
app: str | None = None,
transcription_config: RTTranscriptionConfig | None = None,
turn_config: TurnConfig | None = None,
audio_format: AudioFormat | None = None,
conn_config: ConnectionConfig | None = None,
record_events: bool = True,
) -> None:
super().__init__(
Expand All @@ -125,8 +124,8 @@ def __init__(

self._is_connected = False
self._is_ready_for_audio = False
self._session_error: Optional[str] = None
self._finalize_sent_at: Optional[float] = None
self._session_error: str | None = None
self._finalize_sent_at: float | None = None
self._last_finalize_latency = 0.0

self._register_handlers()
Expand All @@ -144,7 +143,7 @@ def _register_handlers(self) -> None:
# Session lifecycle
# ==========================================================================

async def connect(self, ws_headers: Optional[dict] = None) -> None:
async def connect(self, ws_headers: dict | None = None) -> None:
"""
Open the session and wait until the service is ready for audio.

Expand Down Expand Up @@ -220,10 +219,10 @@ async def __aexit__(self, *args: Any) -> None:
async def start_session(
self,
*,
transcription_config: Optional[RTTranscriptionConfig] = None,
turn_config: Optional[TurnConfig] = None,
audio_format: Optional[AudioFormat] = None,
ws_headers: Optional[dict] = None,
transcription_config: RTTranscriptionConfig | None = None,
turn_config: TurnConfig | None = None,
audio_format: AudioFormat | None = None,
ws_headers: dict | None = None,
) -> None:
"""
Start the session, defaulting to the configs this client was built with.
Expand Down Expand Up @@ -283,7 +282,7 @@ async def send_audio(self, payload: bytes) -> None:
self._logger.warning("Error sending audio: %s", e)
self._is_ready_for_audio = False

def finalize(self, *, timestamp: Optional[float] | object = _UNSET) -> None:
def finalize(self, *, timestamp: float | None | object = _UNSET) -> None:
"""
Close the current turn now, from a synchronous context.

Expand All @@ -310,7 +309,7 @@ def finalize(self, *, timestamp: Optional[float] | object = _UNSET) -> None:
return
loop.create_task(self._send_force_end_of_utterance(resolved))

async def force_end_of_utterance(self, *, timestamp: Optional[float] | object = _UNSET) -> None:
async def force_end_of_utterance(self, *, timestamp: float | None | object = _UNSET) -> None:
"""
Close the current turn now, awaiting the send.

Expand All @@ -326,7 +325,7 @@ async def force_end_of_utterance(self, *, timestamp: Optional[float] | object =
resolved = self.audio_seconds_sent if timestamp is _UNSET else timestamp
await self._send_force_end_of_utterance(resolved)

async def _send_force_end_of_utterance(self, timestamp: Optional[float] | object) -> None:
async def _send_force_end_of_utterance(self, timestamp: float | None | object) -> None:
"""Send ForceEndOfUtterance, including the timestamp unless it is None."""
message: dict[str, Any] = {"message": ClientMessageType.FORCE_END_OF_UTTERANCE}
if timestamp is not None:
Expand All @@ -343,11 +342,11 @@ async def transcribe(
self,
source: BinaryIO,
*,
transcription_config: Optional[RTTranscriptionConfig] = None,
turn_config: Optional[TurnConfig] = None,
audio_format: Optional[AudioFormat] = None,
ws_headers: Optional[dict] = None,
timeout: Optional[float] = None,
transcription_config: RTTranscriptionConfig | None = None,
turn_config: TurnConfig | None = None,
audio_format: AudioFormat | None = None,
ws_headers: dict | None = None,
timeout: float | None = None,
) -> None:
"""
Stream an audio source to the end, then close the session.
Expand Down Expand Up @@ -415,7 +414,7 @@ def segments(self) -> list[Segment]:
return self._transcript.segments

@property
def partial_segment(self) -> Optional[Segment]:
def partial_segment(self) -> Segment | None:
"""The segment currently being built, or None when there is nothing in flight."""
return self._transcript.partial

Expand Down Expand Up @@ -445,7 +444,7 @@ def is_ready_for_audio(self) -> bool:
return self._is_ready_for_audio

@property
def session_error(self) -> Optional[str]:
def session_error(self) -> str | None:
"""The reason the service gave for ending the session, or None while it is healthy."""
return self._session_error

Expand Down
Loading
Loading