mirror of
https://github.com/snakers4/silero-vad.git
synced 2026-02-05 18:09:22 +08:00
This commit is contained in:
15
utils_vad.py
15
utils_vad.py
@@ -268,9 +268,18 @@ def get_speech_ts_adaptive(wav: torch.Tensor,
|
|||||||
if visualize_probs:
|
if visualize_probs:
|
||||||
pd.DataFrame({'probs': smoothed_probs}).plot(figsize=(16, 8))
|
pd.DataFrame({'probs': smoothed_probs}).plot(figsize=(16, 8))
|
||||||
|
|
||||||
for ts in speeches:
|
for i, ts in enumerate(speeches):
|
||||||
ts['start'] = max(0, ts['start'] - speech_pad_samples)
|
if i == 0:
|
||||||
ts['end'] += speech_pad_samples
|
ts['start'] = max(0, ts['start'] - speech_pad_samples)
|
||||||
|
if i != len(speeches) - 1:
|
||||||
|
silence_duration = speeches[i+1]['start'] - ts['end']
|
||||||
|
if silence_duration < 2 * speech_pad_samples:
|
||||||
|
ts['end'] += silence_duration // 2
|
||||||
|
speeches[i+1]['start'] = max(0, speeches[i+1]['start'] - silence_duration // 2)
|
||||||
|
else:
|
||||||
|
ts['end'] += speech_pad_samples
|
||||||
|
else:
|
||||||
|
ts['end'] = min(len(wav), ts['end'] + speech_pad_samples)
|
||||||
|
|
||||||
return speeches
|
return speeches
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user