Make get_speech_timestamps backward compatible with the previous usage (#259)

This commit is contained in:
Guillaume Klein
2023-05-24 15:49:36 +02:00
committed by GitHub
parent c99feb22dc
commit 4db549b800

View File

@@ -40,19 +40,22 @@ class VadOptions(NamedTuple):
def get_speech_timestamps( def get_speech_timestamps(
audio: np.ndarray, vad_options: Optional[VadOptions] = None audio: np.ndarray,
vad_options: Optional[VadOptions] = None,
**kwargs,
) -> List[dict]: ) -> List[dict]:
"""This method is used for splitting long audios into speech chunks using silero VAD. """This method is used for splitting long audios into speech chunks using silero VAD.
Args: Args:
audio: One dimensional float array. audio: One dimensional float array.
vad_options: Options for VAD processing. vad_options: Options for VAD processing.
kwargs: VAD options passed as keyword arguments for backward compatibility.
Returns: Returns:
List of dicts containing begin and end samples of each speech chunk. List of dicts containing begin and end samples of each speech chunk.
""" """
if vad_options is None: if vad_options is None:
vad_options = VadOptions() vad_options = VadOptions(**kwargs)
threshold = vad_options.threshold threshold = vad_options.threshold
min_speech_duration_ms = vad_options.min_speech_duration_ms min_speech_duration_ms = vad_options.min_speech_duration_ms