Skip to content

Expose dither in python API #2127

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

Merged
merged 1 commit into from
Apr 17, 2025
Merged
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
7 changes: 7 additions & 0 deletions sherpa-onnx/python/sherpa_onnx/offline_recognizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ def from_transducer(
num_threads: int = 1,
sample_rate: int = 16000,
feature_dim: int = 80,
dither: float = 0.0,
decoding_method: str = "greedy_search",
max_active_paths: int = 4,
hotwords_file: str = "",
Expand Down Expand Up @@ -89,6 +90,11 @@ def from_transducer(
Sample rate of the training data used to train the model.
feature_dim:
Dimension of the feature used to train the model.
dither:
Dithering constant (0.0 means no dither).
By default the audio samples are in range [-1,+1],
so dithering constant 0.00003 is a good value,
equivalent to the default 1.0 from kaldi
decoding_method:
Valid values: greedy_search, modified_beam_search.
max_active_paths:
Expand Down Expand Up @@ -142,6 +148,7 @@ def from_transducer(
feat_config = FeatureExtractorConfig(
sampling_rate=sample_rate,
feature_dim=feature_dim,
dither=dither,
)

if len(hotwords_file) > 0 and decoding_method != "modified_beam_search":
Expand Down
Loading