Skip to content

Commit fd1fbe9

Browse files
author
James Walker
committed
Merge branch 'master' into hotfix/multichannel_version_increment
2 parents 9531b85 + c432330 commit fd1fbe9

29 files changed

Lines changed: 676 additions & 104 deletions

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
python-version: ${{ matrix.python-version }}
2323

2424
- name: Install dependencies
25-
run: pip3 install -r requirements.txt -r requirements-dev.txt
25+
run: pip3 install -r requirements.txt -r requirements-dev.txt -r requirements-metrics.txt
2626

2727
- name: Lint
2828
run: make lint

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ target/
8787
# pyenv
8888
.python-version
8989
venv
90+
.venv
9091

9192
# pipenv
9293
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.

CHANGELOG.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,41 @@ All notable changes to this project will be documented in this file.
44

55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
## [4.0.1] - 2025-04-30
8+
9+
### Added
10+
11+
- Support RT Multichannel and channel DZ
12+
13+
## [4.0.0] - 2025-05-20
14+
15+
### Changed
16+
17+
BREAKING CHANGE: Metrics functionality now requires explicit installation
18+
19+
Previously, all metrics dependencies (pyannote, pandas, jiwer, etc.) were
20+
installed by default. This change moves them to an optional '[metrics]' extra
21+
to reduce the default installation footprint.
22+
23+
- Move metrics dependencies to requirements-metrics.txt
24+
- Configure extras_require in setup.py for optional installation
25+
- Add graceful error handling in CLI when dependencies are missing
26+
27+
## [3.0.6] - 2025-05-20
28+
29+
### Added
30+
31+
- Support end-of-utterance messages (DEL-24982)
32+
33+
## [3.0.5] - 2025-05-15
34+
35+
- cli: fix some config options not being set when defined in a config file: `topic_detection_config` and `speaker_diarization_config`
736

837
## [3.0.4] - 2025-04-16
938

1039
- Support for new parameters `prefer_current_speaker` and `speaker_sensitivity` in Speaker Diarization
1140

41+
1242
## [3.0.3] - 2025-03-03
1343

1444
### Added

Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ lint:
99
black --check --diff $(SOURCES)
1010
ruff $(SOURCES)
1111

12+
.PHONY: lint-fix
13+
lint-fix:
14+
black $(SOURCES)
15+
ruff --fix $(SOURCES)
16+
1217
.PHONY: format
1318
format:
1419
black $(SOURCES)

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ To install from PyPI:
99
```bash
1010
pip install speechmatics-python
1111
```
12+
13+
To use the sm-metrics tool for diarization features and speaker identification metrics, install with the optional dependencies:
14+
```bash
15+
pip install speechmatics-python[metrics]
16+
```
1217
To install from source:
1318
```bash
1419
git clone https://github.com/speechmatics/speechmatics-python

asr_metrics/cli.py

Lines changed: 53 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,74 @@
11
"""Entrypoint for SM metrics"""
2+
23
import argparse
4+
import sys
5+
6+
try:
7+
import asr_metrics.wer.__main__ as wer_metrics
8+
9+
WER_AVAILABLE = True
10+
except ImportError:
11+
WER_AVAILABLE = False
12+
13+
try:
14+
import asr_metrics.diarization.sm_diarization_metrics.cookbook as diarization_metrics
315

4-
import asr_metrics.diarization.sm_diarization_metrics.cookbook as diarization_metrics
5-
import asr_metrics.wer.__main__ as wer_metrics
16+
DIARIZATION_AVAILABLE = True
17+
except ImportError:
18+
DIARIZATION_AVAILABLE = False
619

720

821
def main():
9-
parser = argparse.ArgumentParser(description="Your CLI description")
22+
parser = argparse.ArgumentParser(
23+
description="Speechmatics metrics tool for WER and diarization"
24+
)
1025

1126
# Create subparsers
1227
subparsers = parser.add_subparsers(
1328
dest="mode", help="Metrics mode. Choose from 'wer' or 'diarization'"
1429
)
15-
subparsers.required = True # Make sure a subparser id always provided
30+
subparsers.required = True # Make sure a subparser is always provided
1631

17-
wer_parser = subparsers.add_parser("wer", help="Entrypoint for WER metrics")
18-
wer_metrics.get_wer_args(wer_parser)
32+
if WER_AVAILABLE:
33+
wer_parser = subparsers.add_parser("wer", help="Entrypoint for WER metrics")
34+
wer_metrics.get_wer_args(wer_parser)
35+
else:
36+
wer_parser = subparsers.add_parser(
37+
"wer", help="Entrypoint for WER metrics (requires additional dependencies)"
38+
)
1939

20-
diarization_parser = subparsers.add_parser(
21-
"diarization", help="Entrypoint for diarization metrics"
22-
)
23-
diarization_metrics.get_diarization_args(diarization_parser)
40+
if DIARIZATION_AVAILABLE:
41+
diarization_parser = subparsers.add_parser(
42+
"diarization", help="Entrypoint for diarization metrics"
43+
)
44+
diarization_metrics.get_diarization_args(diarization_parser)
45+
else:
46+
diarization_parser = subparsers.add_parser(
47+
"diarization",
48+
help="Entrypoint for diarization metrics (requires pyannote dependencies)",
49+
)
50+
diarization_parser.add_argument(
51+
"--help-install",
52+
action="store_true",
53+
help="Show instructions for installing diarization dependencies",
54+
)
2455

2556
args = parser.parse_args()
2657

2758
if args.mode == "wer":
28-
wer_metrics.main(args)
59+
if WER_AVAILABLE:
60+
wer_metrics.main(args)
61+
else:
62+
print("Error: WER metrics require additional dependencies.")
63+
print("Please install them with: pip install speechmatics-python[metrics]")
64+
sys.exit(1)
2965
elif args.mode == "diarization":
30-
diarization_metrics.main(args)
66+
if DIARIZATION_AVAILABLE:
67+
diarization_metrics.main(args)
68+
else:
69+
print("Error: Diarization metrics require additional dependencies.")
70+
print("Please install them with: pip install speechmatics-python[metrics]")
71+
sys.exit(1)
3172
else:
3273
print("Unsupported mode. Please use 'wer' or 'diarization'")
3374

asr_metrics/wer/__main__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
Simple script to run WER analysis using Whisper normalisers
33
Prints results to terminal
44
"""
5+
56
import difflib
67
import json
78
from pathlib import Path

asr_metrics/wer/normalizers/basic.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,19 @@ def remove_symbols_and_diacritics(self, s: str, keep=""):
5050
and drop any diacritics (category 'Mn' and some manual mappings)
5151
"""
5252
return "".join(
53-
c
54-
if c in keep
55-
else self.additional_diacritics[c]
56-
if c in self.additional_diacritics
57-
else ""
58-
if unicodedata.category(c) == "Mn"
59-
else " "
60-
if unicodedata.category(c)[0] in "MSP"
61-
else c
53+
(
54+
c
55+
if c in keep
56+
else (
57+
self.additional_diacritics[c]
58+
if c in self.additional_diacritics
59+
else (
60+
""
61+
if unicodedata.category(c) == "Mn"
62+
else " " if unicodedata.category(c)[0] in "MSP" else c
63+
)
64+
)
65+
)
6266
for c in unicodedata.normalize("NFKD", s)
6367
)
6468

examples/notification_flow/batch_transcription_client.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""
22
Client module which calls the Speechmatics API
33
"""
4+
45
import sqlite3
56

67
from speechmatics.batch_client import BatchClient

examples/notification_flow/cronjob.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
44
Async fallback checking in case of webhook failure is a common pattern in production systems
55
"""
6+
67
import sqlite3
78

89
from speechmatics.batch_client import BatchClient

0 commit comments

Comments
 (0)