From 84ed5d428890c00df7d7431e0c51e50bed05b754 Mon Sep 17 00:00:00 2001 From: "Nickolay V. Shmyrev" Date: Thu, 17 Apr 2025 11:47:48 +0300 Subject: [PATCH] Expose dither in python API (#2127) --- sherpa-onnx/python/sherpa_onnx/offline_recognizer.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/sherpa-onnx/python/sherpa_onnx/offline_recognizer.py b/sherpa-onnx/python/sherpa_onnx/offline_recognizer.py index 69bb3ef8..50572366 100644 --- a/sherpa-onnx/python/sherpa_onnx/offline_recognizer.py +++ b/sherpa-onnx/python/sherpa_onnx/offline_recognizer.py @@ -49,6 +49,7 @@ class OfflineRecognizer(object): 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 = "", @@ -89,6 +90,11 @@ class OfflineRecognizer(object): 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: @@ -142,6 +148,7 @@ class OfflineRecognizer(object): feat_config = FeatureExtractorConfig( sampling_rate=sample_rate, feature_dim=feature_dim, + dither=dither, ) if len(hotwords_file) > 0 and decoding_method != "modified_beam_search":