Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds support for configuring volume filtering #91

Merged
merged 4 commits into from
Mar 19, 2024
Merged
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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.14.4] - 2024-03-04

## Added

- Support for volume_threshold audio filtering in transcription config

## [1.14.3] - 2024-02-29

## Fixed
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.14.3
1.14.4
5 changes: 5 additions & 0 deletions speechmatics/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,11 @@ def get_transcription_config(
]:
config[option] = True if args.get(option) else config.get(option)

if args.get("volume_threshold") is not None:
config["audio_filtering_config"] = {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can't this be a property in the top level dict?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean audio_filtering_config should be a top level property of the whole thing, or that volume_threshold should be a property in transcription_config?

If the first, then I think audio filtering is a transcription option (and unlike a standalone option configuring a speech capability)

If the second, it's because it follows the related openapi-spec MR and audio_filtering_config is open for extension, even though it only has one setting at the moment - the analogy is with ``speaker_diarization_config`.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolving since the openapi-specifications change is merged.

"volume_threshold": args.get("volume_threshold")
}

if args.get("ctrl"):
LOGGER.warning(f"Using internal dev control command: {args['ctrl']}")
config["ctrl"] = json.loads(args["ctrl"])
Expand Down
7 changes: 7 additions & 0 deletions speechmatics/cli_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,13 @@ def get_arg_parser():
default=None,
help="Language (ISO 639-1 code, e.g. en, fr, de).",
)
config_parser.add_argument(
"--volume-threshold",
dest="volume_threshold",
type=float,
default=None,
help=("Filter out quiet audio which falls below this threshold (0.0-100.0)"),
)
config_parser.add_argument(
"--operating-point",
choices=["standard", "enhanced"],
Expand Down
3 changes: 3 additions & 0 deletions speechmatics/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@ def asdict(self) -> Dict[Any, Any]:
enable_entities: bool = None
"""Indicates if inverse text normalization entity output is enabled."""

audio_filtering_config: dict = None
"""Configuration for limiting the transcription of quiet audio."""


@dataclass
class RTSpeakerDiarizationConfig:
Expand Down
5 changes: 5 additions & 0 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,10 @@
"detect_chapters": True,
},
),
(
["batch", "transcribe", "--volume-threshold", "3.1"],
{"volume_threshold": 3.1},
),
],
)
def test_cli_arg_parse_with_file(args, values):
Expand All @@ -332,6 +336,7 @@ def test_cli_arg_parse_with_file(args, values):
actual_values = vars(cli.parse_args(args=test_args))

for key, val in values.items():
assert key in actual_values, f"Expected {key} in {actual_values}"
assert actual_values[key] == val, f"Expected {actual_values} to match {values}"


Expand Down
Loading