metadata:
tag: ''
categories:
- deep-learning
- audio
name: silero-vad
verbose: false
spec:
description: Silero VAD (Voice Activity Detection) functions.
build:
code_origin: ''
base_image: mlrun/mlrun
requirements:
- torch
- torchaudio
- tqdm
- onnxruntime
functionSourceCode: IyBDb3B5cmlnaHQgMjAyNCBJZ3VhemlvCiMKIyBMaWNlbnNlZCB1bmRlciB0aGUgQXBhY2hlIExpY2Vuc2UsIFZlcnNpb24gMi4wICh0aGUgIkxpY2Vuc2UiKTsKIyB5b3UgbWF5IG5vdCB1c2UgdGhpcyBmaWxlIGV4Y2VwdCBpbiBjb21wbGlhbmNlIHdpdGggdGhlIExpY2Vuc2UuCiMgWW91IG1heSBvYnRhaW4gYSBjb3B5IG9mIHRoZSBMaWNlbnNlIGF0CiMKIyAgIGh0dHA6Ly93d3cuYXBhY2hlLm9yZy9saWNlbnNlcy9MSUNFTlNFLTIuMAojCiMgVW5sZXNzIHJlcXVpcmVkIGJ5IGFwcGxpY2FibGUgbGF3IG9yIGFncmVlZCB0byBpbiB3cml0aW5nLCBzb2Z0d2FyZQojIGRpc3RyaWJ1dGVkIHVuZGVyIHRoZSBMaWNlbnNlIGlzIGRpc3RyaWJ1dGVkIG9uIGFuICJBUyBJUyIgQkFTSVMsCiMgV0lUSE9VVCBXQVJSQU5USUVTIE9SIENPTkRJVElPTlMgT0YgQU5ZIEtJTkQsIGVpdGhlciBleHByZXNzIG9yIGltcGxpZWQuCiMgU2VlIHRoZSBMaWNlbnNlIGZvciB0aGUgc3BlY2lmaWMgbGFuZ3VhZ2UgZ292ZXJuaW5nIHBlcm1pc3Npb25zIGFuZAojIGxpbWl0YXRpb25zIHVuZGVyIHRoZSBMaWNlbnNlLgppbXBvcnQgbG9nZ2luZwpmcm9tIG11bHRpcHJvY2Vzc2luZyBpbXBvcnQgUHJvY2VzcywgUXVldWUKZnJvbSBwYXRobGliIGltcG9ydCBQYXRoCmZyb20gdHlwZXMgaW1wb3J0IEZ1bmN0aW9uVHlwZQpmcm9tIH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b2FkLAogICAgICAgICAgICBvbm54PXNlbGYuX3VzZV9vbm54LAogICAgICAgICAgICBmb3JjZV9vbm54X2NwdT1zZWxmLl9mb3JjZV9vbm54X2NwdSwKICAgICAgICApCiAgICAgICAgc2VsZi5fbW9kZWwgPSBtb2RlbAogICAgICAgICgKICAgICAgICAgICAgc2VsZi5fZ2V0X3NwZWVjaF90aW1lc3RhbXBzLAogICAgICAgICAgICBfLCAgIyBzYXZlX2F1ZGlvLAogICAgICAgICAgICBfLCAgIyByZWFkX2F1ZGlvLAogICAgICAgICAgICBfLCAgIyBWQURJdGVyYXRvciwKICAgICAgICAgICAgXywgICMgY29sbGVjdF9jaHVua3MKICAgICAgICApID0gdXRpbHMKCiAgICBkZWYgZGV0ZWN0X3ZvaWNlKAogICAgICAgIHNlbGYsCiAgICAgICAgYXVkaW9fZmlsZTogUGF0aCwKICAgICkgLT4gVW5pb25bTGlzdFtEaWN0W3N0ciwgaW50XV0sIExpc3RbTGlzdFtEaWN0W3N0ciwgaW50XV1dXToKICAgICAgICAiIiIKICAgICAgICBJbmZlciB0aGUgYXVkaW8gdGhyb3VnaCB0aGUgVkFEIG1vZGVsIGFuZCByZXR1cm4gdGhlIHNwZWVjaCB0aW1lc3RhbXBzLgoKICAgICAgICA6cGFyYW0gYXVkaW9fZmlsZTogVGhlIGF1ZGlvIGZpbGUgdG8gaW5mZXIuCgogICAgICAgIDpyZXR1cm5zOiBUaGUgc3BlZWNoIHRpbWVzdGFtcHMgaW4gdGhlIGF1ZGlvLiBBIGxpc3Qgb2YgdGltZXN0YW1wcyB3aGVyZSBlYWNoIHRpbWVzdGFtcCBpcyBhIGRpY3Rpb25hcnkgd2l0aCB0aGUKICAgICAgICAgICAgICAgICBmb2xsb3dpbmcga2V5czoKCiAgICAgICAgICAgICAgICAgKiAic3RhcnQiOiBUaGUgc3RhcnQgc2FtcGxlIGluZGV4IG9mIHRoZSBzcGVlY2ggaW4gdGhlIGF1ZGlvLgogICAgICAgICAgICAgICAgICogImVuZCI6ICAgVGhlIGVuZCBzYW1wbGUgaW5kZXggb2YgdGhlIHNwZWVjaCBpbiB0aGUgYXVkaW8uCgogICAgICAgICAgICAgICAgIElmIGBwZXJfY2hhbm5lbGAgaXMgVHJ1ZSwgYSBsaXN0IG9mIHRpbWVzdGFtcHMgcGVyIGNoYW5uZWwgd2lsbCBiZSByZXR1cm5lZC4KICAgICAgICAiIiIKICAgICAgICAjIENhc3QgdG8gYSBudW1weSBhcnJheToKICAgICAgICBhdWRpbyA9IHNlbGYuX3JlYWRfYXVkaW8oYXVkaW9fZmlsZSkKCiAgICAgICAgIyBEZXRlY3Qgc3BlZWNoOgogICAgICAgIGlmIG5vdCBzZWxmLl9wZXJfY2hhbm5lbDoKICAgICAgICAgICAgcmV0dXJuIHNlbGYuX2dldF9zcGVlY2hfdGltZXN0YW1wcygKICAgICAgICAgICAgICAgIGF1ZGlvLAogICAgICAgICAgICAgICAgc2VsZi5fbW9kZWwsCiAgICAgICAgICAgICAgICB0aHJlc2hvbGQ9c2VsZi5fdGhyZXNob2xkLAogICAgICAgICAgICAgICAgbWluX3NwZWVjaF9kdXJhdGlvbl9tcz1zZWxmLl9taW5fc3BlZWNoX2R1cmF0aW9uX21zLAogICAgICAgICAgICAgICAgbWF4X3NwZWVjaF9kdXJhdGlvbl9zPXNlbGYuX21heF9zcGVlY2hfZHVyYXRpb25fcywKICAgICAgICAgICAgICAgIG1pbl9zaWxlbmNlX2R1cmF0aW9uX21zPXNlbGYuX21pbl9zaWxlbmNlX2R1cmF0aW9uX21zLAogICAgICAgICAgICAgICAgc3BlZWNoX3BhZF9tcz1zZWxmLl9zcGVlY2hfcGFkX21zLAogICAgICAgICAgICAgICAgc2FtcGxpbmdfcmF0ZT1zZWxmLl9zYW1wbGluZ19yYXRlLAogICAgICAgICAgICAgICAgd2luZG93X3NpemVfc2FtcGxlcz1zZWxmLl93aW5kb3dfc2l6ZV9zYW1wbGVzLAogICAgICAgICAgICAgICAgcmV0dXJuX3NlY29uZHM9c2VsZi5fcmV0dXJuX3NlY29uZHMsCiAgICAgICAgICAgICkKCiAgICAgICAgIyBQZXIgY2hhbm5lbDoKICAgICAgICBzcGVlY2hfdGltZXN0YW1wcyA9IFtdCiAgICAgICAgZm9yIGNoYW5uZWwgaW4gYXVkaW86CiAgICAgICAgICAgIHNwZWVjaF90aW1lc3RhbXBzLmFwcGVuZCgKICAgICAgICAgICAgICAgIHNlbGYuX2dldF9zcGVlY2hfdGltZXN0YW1wcygKICAgICAgICAgICAgICAgICAgICBjaGFubmVsLAogICAgICAgICAgICAgICAgICAgIHNlbGYuX21vZGVsLAogICAgICAgICAgICAgICAgICAgIHRocmVzaG9sZD1zZWxmLl90aHJlc2hvbGQsCiAgICAgICAgICAgICAgICAgICAgbWluX3NwZWVjaF9kdXJhdGlvbl9tcz1zZWxmLl9taW5fc3BlZWNoX2R1cmF0aW9uX21zLAogICAgICAgICAgICAgICAgICAgIG1heF9zcGVlY2hfZHVyYXRpb25fcz1zZWxmLl9tYXhfc3BlZWNoX2R1cmF0aW9uX3MsCiAgICAgICAgICAgICAgICAgICAgbWluX3NpbGVuY2VfZHVyYXRpb25fbXM9c2VsZi5fbWluX3NpbGVuY2VfZHVyYXRpb25fbXMsCiAgICAgICAgICAgICAgICAgICAgc3BlZWNoX3BhZF9tcz1zZWxmLl9zcGVlY2hfcGFkX21zLAogICAgICAgICAgICAgICAgICAgIHNhbXBsaW5nX3JhdGU9c2VsZi5fc2FtcGxpbmdfcmF0ZSwKICAgICAgICAgICAgICAgICAgICB3aW5kb3dfc2l6ZV9zYW1wbGVzPXNlbGYuX3dpbmRvd19zaXplX3NhbXBsZXMsCiAgICAgICAgICAgICAgICAgICAgcmV0dXJuX3NlY29uZHM9c2VsZi5fcmV0dXJuX3NlY29uZHMsCiAgICAgICAgICAgICAgICApCiAgICAgICAgICAgICkKCiAgICAgICAgcmV0dXJuIHNwZWVjaF90aW1lc3RhbXBzCgogICAgZGVmIF9yZWFkX2F1ZGlvKAogICAg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EZhbHNlLAogICAgIyBPdGhlciBrd2FyZ3M6CiAgICB1c2VfbXVsdGlwcm9jZXNzaW5nOiBpbnQgPSAwLAogICAgdmVyYm9zZTogYm9vbCA9IEZhbHNlLAopOgogICAgIiIiCiAgICBQZXJmb3JtIHZvaWNlIGFjdGl2aXR5IGRldGVjdGlvbiBvbiBnaXZlbiBhdWRpbyBmaWxlcyB1c2luZyB0aGUgc2lsZXJvIFZBRCBtb2RlbCAtCiAgICBodHRwczovL2dpdGh1Yi5jb20vc25ha2VyczQvc2lsZXJvLXZhZC4gVGhlIGVuZCByZXN1bHQgaXMgYSBkaWN0aW9uYXJ5IHdpdGggdGhlIGZpbGUgbmFtZXMgYXMga2V5cyBhbmQgdGhlaXIKICAgIFZBRCB0aW1lc3RhbXBzIGRpY3Rpb25hcmllcyBhcyB2YWx1ZS4KCiAgICBGb3IgZXhhbXBsZTo6CgogICAgICAgIHsKICAgICAgICAgICAgImZpbGVfMS53YXYiOiBbCiAgICAgICAgICAgICAgICB7InN0YXJ0IjogMCwgImVuZCI6IDE2MDAwfSwKICAgICAgICAgICAgICAgIHsic3RhcnQiOiAxNjAwMCwgImVuZCI6IDMyMDAwfSwKICAgICAgICAgICAgICAgIHsic3RhcnQiOiAzMjAwMCwgImVuZCI6IDQ4MDAwfSwKICAgICAgICAgICAgICAgIC4uLgogICAgICAgICAgICBdLAogICAgICAgICAgICAiZmlsZV8yLndhdiI6IFsKICAgICAgICAgICAgICAgIHsic3RhcnQiOiAwLCAiZW5kIjogMTYwMDB9LAogICAgICAgICAgICAgICAgeyJzdGFydCI6IDE2MDAwLCAiZW5kIjogMzIwMDB9LAogICAgICAgICAgICAgICAgeyJzdGFydCI6IDMyMDAwLCAiZW5kIjogNDgwMDB9LAogICAgICAgICAgICAgICAgLi4uCiAgICAgICAgICAgIF0sCiAgICAgICAgICAgIC4uLgogICAgICAgIH0KCgogICAgOnBhcmFtIGRhdGFfcGF0aDogICAgICAgICAgICAgICBUaGUgcGF0aCB0byB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kaWFyaXphdGlvbiBpcyBwZXJmb3JtZWQgcGVyIGNoYW5uZWwgc28gdGhhdCBlYWNoIGNoYW5uZWwgaW4gdGhlIGF1ZGlvIGJlbG9uZyB0byBhIGRpZmZlcmVudCBzcGVha2VyLiBUaGUKICAgIGVuZCByZXN1bHQgaXMgYSBkaWN0aW9uYXJ5IHdpdGggdGhlIGZpbGUgbmFtZXMgYXMga2V5cyBhbmQgdGhlaXIgZGlhcml6YXRpb24gYXMgdmFsdWUuIEEgZGlhcml6YXRpb24gaXMgYSBsaXN0CiAgICBvZiB0dXBsZXM6IChzdGFydCwgZW5kLCBzcGVha2VyX2xhYmVsKS4KCiAgICBGb3IgZXhhbXBsZTo6CgogICAgICAgIHsKICAgICAgICAgICAgImZpbGVfMS53YXYiOiBbCiAgICAgICAgICAgICAgICAoMC4wLCAxLjAsICJzcGVha2VyXzAiKSwKICAgICAgICAgICAgICAgICgxLjAsIDIuMCwgInNwZWFrZXJfMSIpLAogICAgICAgICAgICAgICAgKDIuMCwgMy4wLCAic3BlYWtlcl8wIiksCiAgICAgICAgICAgICAgICAuLi4KICAgICAgICAgICAgXSwKICAgICAgICAgICAgImZpbGVfMi53YXYiOiBbCiAgICAgICAgICAgICAgICAoMC4wLCAxLjAsICJzcGVha2VyXzAiKSwKICAgICAgICAgICAgICAgICgxLjAsIDIuMCwgInNwZWFrZXJfMSIpLAogICAgICAgICAgICAgICAgKDIuMCwgMy4wLCAic3BlYWtlcl8wIiksCiAgICAgICAgICAgICAgICAuLi4KICAgICAgICAgICAgXSwKICAgICAgICAgICAgLi4uCiAgICAgICAgfQoKCiAgICA6cGFyYW0gZGF0YV9wYXRoOiAgICAgICAgICAgICAgIFRoZSBwYXRoIHRvIHRoZSBhdWRpbyBmaWxlcyB0byBkaWFyaXplLiBDYW4gYmUgYSBwYXRoIHRvIGEgc2luZ2xlIGZpbGUsIGEgcGF0aCB0byBhCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRpcmVjd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wbGVbZGljdCwgZGljdF06CiAgICAiIiIKICAgIFByb2Nlc3MgdGhlIHJlc3VsdHMgb2YgdGhlIHRhc2tzLgoKICAgIDpwYXJhbSByZXN1bHRzOiBUaGUgcmVzdWx0cyB0byBwcm9jZXNzLgogICAgOnBhcmFtIHZlcmJvc2U6IFZlcmJvc2l0eS4KCiAgICA6cmV0dXJuczogVGhlIHByb2Nlc3NlZCByZXN1bHRzIGFzIGEgdHVwbGUgb2Ygc3VjY2Vzc2VzIGFuZCBlcnJvcnMuCiAgICAiIiIKICAgIGlmIHZlcmJvc2U6CiAgICAgICAgX0xPR0dFUi5pbmZvKCJTdW1tYXJpemluZyB0aGUgcmVzdWx0cy4iKQogICAgc3VjY2Vzc2VzID0ge30KICAgIGVycm9ycyA9IHt9CiAgICBmb3IgaXNfZXJyb3IsIHJlc3VsdCBpbiByZXN1bHRzOgogICAgICAgIGlmIGlzX2Vycm9yOgogICAgICAgICAgICBlcnJvcnNbcmVzdWx0WzBdXSA9IHJlc3VsdFsxXQogICAgICAgIGVsc2U6CiAgICAgICAgICAgIHN1Y2Nlc3Nlc1tyZXN1bHRbMF1dID0gcmVzdWx0WzFdCiAgICBpZiB2ZXJib3NlOgogICAgICAgIF9MT0dHRVIuaW5mbyhmIkRvbmUgKHtsZW4oc3VjY2Vzc2VzKX0ve2xlbihzdWNjZXNzZXMpICsgbGVuKGVycm9ycyl9KVxuIikKCiAgICByZXR1cm4gc3VjY2Vzc2VzLCBlcnJvcnMK
origin_filename: ''
image: ''
command: ''
entry_points:
audio_file:
doc: Get the audio file of the task.
lineno: 43
has_varargs: false
outputs:
- doc: The audio file of the task.
type: Path
parameters:
- name: self
has_kwargs: false
name: audio_file
do_task:
doc: Do the task on the given speech timestamps. The task will diarize the VAD
speech timestamps into speakers.
lineno: 94
has_varargs: false
parameters:
- name: self
- name: speech_timestamps
type: List[List[Dict[str, int]]]
doc: The speech timestamps per channel to do the task on as outputted from
the VAD.
has_kwargs: false
name: do_task
get_result:
doc: Get the result of the task. A tuple of the audio file name and the result.
lineno: 61
has_varargs: false
outputs:
- doc: The result of the task.
type: Tuple[str, list]
parameters:
- name: self
has_kwargs: false
name: get_result
to_tuple:
doc: Convert the task to a tuple to reconstruct it later (used for multiprocessing
to pass in queue).
lineno: 116
has_varargs: false
outputs:
- doc: The converted task.
type: Tuple[str, dict]
parameters:
- name: self
has_kwargs: false
name: to_tuple
create_task:
doc: Create a task with the given audio file.
lineno: 146
has_varargs: false
outputs:
- doc: The created task.
type: BaseTask
parameters:
- name: self
- name: audio_file
type: Path
doc: The audio file to assign to the task.
has_kwargs: false
name: create_task
from_tuple:
doc: Create a task from a tuple of the audio file name and the task kwargs.
lineno: 157
has_varargs: false
outputs:
- doc: The created task.
type: BaseTask
parameters:
- name: cls
- name: task_tuple
type: Tuple[str, dict]
doc: The task tuple to create the task from.
has_kwargs: false
name: from_tuple
load:
doc: Load the VAD model.
lineno: 234
has_varargs: false
parameters:
- name: self
- name: force_reload
type: bool
doc: Whether to force reload the model even if it was already loaded. Default
is True.
default: true
has_kwargs: false
name: load
detect_voice:
doc: "Perform voice activity detection on given audio files using the silero\
\ VAD model -\nhttps://github.com/snakers4/silero-vad. The end result is a\
\ dictionary with the file names as keys and their\nVAD timestamps dictionaries\
\ as value.\n\nFor example::\n\n {\n \"file_1.wav\": [\n \
\ {\"start\": 0, \"end\": 16000},\n {\"start\": 16000, \"end\"\
: 32000},\n {\"start\": 32000, \"end\": 48000},\n ...\n\
\ ],\n \"file_2.wav\": [\n {\"start\": 0, \"end\"\
: 16000},\n {\"start\": 16000, \"end\": 32000},\n {\"\
start\": 32000, \"end\": 48000},\n ...\n ],\n ...\n\
\ }"
lineno: 393
has_varargs: false
parameters:
- name: data_path
type: Union[str, Path, List[Union[str, Path]]]
doc: The path to the audio files to diarize. Can be a path to a single file,
a path to a directory or a list of paths to files.
- name: use_onnx
type: bool
doc: Whether to use ONNX for inference. Default is True.
default: true
- name: force_onnx_cpu
type: bool
doc: Whether to force ONNX to use CPU for inference. Default is True.
default: true
- name: threshold
type: float
doc: Speech threshold. Silero VAD outputs speech probabilities for each audio
chunk, probabilities ABOVE this value are considered as SPEECH. It is better
to tune this parameter for each dataset separately, but "lazy" 0.5 is pretty
good for most datasets.
default: 0.5
- name: sampling_rate
type: int
doc: Currently, silero VAD models support 8000 and 16000 sample rates.
default: 16000
- name: min_speech_duration_ms
type: int
doc: Final speech chunks shorter min_speech_duration_ms are thrown out.
default: 250
- name: max_speech_duration_s
type: float
doc: Maximum duration of speech chunks in seconds. Chunks longer than `max_speech_duration_s`
will be split at the timestamp of the last silence that lasts more than
100ms (if any), to prevent aggressive cutting. Otherwise, they will be split
aggressively just before max_speech_duration_s.
default: float('inf')
- name: min_silence_duration_ms
type: int
doc: In the end of each speech chunk wait for min_silence_duration_ms before
separating it.
default: 100
- name: window_size_samples
type: int
doc: Audio chunks of window_size_samples size are fed to the silero VAD model.
default: 512
- name: speech_pad_ms
type: int
doc: Final speech chunks are padded by speech_pad_ms each side.
default: 30
- name: return_seconds
type: bool
doc: Whether return timestamps in seconds. False means to return timestamps
in samples (default - False).
default: false
- name: per_channel
type: bool
doc: Whether to return timestamps per channel (default - False). This will
run VAD on each channel separately and return a list of timestamps per channel.
default: false
- name: use_multiprocessing
type: int
doc: The number of workers to use for multiprocessing. If 0, no multiprocessing
will be used. Default is 0.
default: 0
- name: verbose
type: bool
doc: Verbosity.
default: false
has_kwargs: false
name: detect_voice
diarize:
doc: "Perform speech diarization on given audio files using the silero VAD model\
\ - https://github.com/snakers4/silero-vad.\nThe speech diarization is performed\
\ per channel so that each channel in the audio belong to a different speaker.\
\ The\nend result is a dictionary with the file names as keys and their diarization\
\ as value. A diarization is a list\nof tuples: (start, end, speaker_label).\n\
\nFor example::\n\n {\n \"file_1.wav\": [\n (0.0, 1.0,\
\ \"speaker_0\"),\n (1.0, 2.0, \"speaker_1\"),\n (2.0,\
\ 3.0, \"speaker_0\"),\n ...\n ],\n \"file_2.wav\"\
: [\n (0.0, 1.0, \"speaker_0\"),\n (1.0, 2.0, \"speaker_1\"\
),\n (2.0, 3.0, \"speaker_0\"),\n ...\n ],\n\
\ ...\n }"
lineno: 517
has_varargs: false
parameters:
- name: data_path
type: Union[str, Path, List[Union[str, Path]]]
doc: The path to the audio files to diarize. Can be a path to a single file,
a path to a directory or a list of paths to files.
- name: use_onnx
type: bool
doc: Whether to use ONNX for inference. Default is True.
default: true
- name: force_onnx_cpu
type: bool
doc: Whether to force ONNX to use CPU for inference. Default is True.
default: true
- name: threshold
type: float
doc: Speech threshold. Silero VAD outputs speech probabilities for each audio
chunk, probabilities ABOVE this value are considered as SPEECH. It is better
to tune this parameter for each dataset separately, but "lazy" 0.5 is pretty
good for most datasets.
default: 0.5
- name: sampling_rate
type: int
doc: Currently, silero VAD models support 8000 and 16000 sample rates.
default: 16000
- name: min_speech_duration_ms
type: int
doc: Final speech chunks shorter min_speech_duration_ms are thrown out.
default: 250
- name: max_speech_duration_s
type: float
doc: Maximum duration of speech chunks in seconds. Chunks longer than `max_speech_duration_s`
will be split at the timestamp of the last silence that lasts more than
100ms (if any), to prevent aggressive cutting. Otherwise, they will be split
aggressively just before max_speech_duration_s.
default: float('inf')
- name: min_silence_duration_ms
type: int
doc: In the end of each speech chunk wait for min_silence_duration_ms before
separating it.
default: 100
- name: window_size_samples
type: int
doc: Audio chunks of window_size_samples size are fed to the silero VAD model.
default: 512
- name: speech_pad_ms
type: int
doc: Final speech chunks are padded by speech_pad_ms each side.
default: 30
- name: speaker_labels
type: List[str]
doc: The speaker labels to use for the diarization. If not given, the speakers
will be named "speaker_0", "speaker_1", etc.
default: null
- name: use_multiprocessing
type: int
doc: The number of workers to use for multiprocessing. If 0, no multiprocessing
will be used. Default is 0.
default: 0
- name: verbose
type: bool
doc: Verbosity.
default: false
has_kwargs: false
name: diarize
disable_auto_mount: false
default_handler: detect_voice
kind: job