From b9704fbe35d5a131562927f3454fae23adb4ce8f Mon Sep 17 00:00:00 2001 From: sontref Date: Thu, 31 Dec 2020 01:22:29 +0000 Subject: [PATCH] Small fix Number timestamps are now in ms. --- silero-vad.ipynb | 9 +++++---- utils.py | 6 +++--- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/silero-vad.ipynb b/silero-vad.ipynb index e90e9d0..8f33466 100755 --- a/silero-vad.ipynb +++ b/silero-vad.ipynb @@ -280,8 +280,8 @@ "sample_rate = 16000\n", "# convert ms in timestamps to samples\n", "for timestamp in number_timestamps:\n", - " timestamp['start'] = int(timestamp['start'] * sample_rate)\n", - " timestamp['end'] = int(timestamp['end'] * sample_rate)" + " timestamp['start'] = int(timestamp['start'] * sample_rate / 1000)\n", + " timestamp['end'] = int(timestamp['end'] * sample_rate / 1000)" ] }, { @@ -601,6 +601,7 @@ { "cell_type": "markdown", "metadata": { + "heading_collapsed": true, "hidden": true, "id": "5JHErdB7jsr0" }, @@ -640,8 +641,8 @@ "sample_rate = 16000\n", "# convert ms in timestamps to samples\n", "for timestamp in number_timestamps:\n", - " timestamp['start'] = int(timestamp['start'] * sample_rate)\n", - " timestamp['end'] = int(timestamp['end'] * sample_rate)" + " timestamp['start'] = int(timestamp['start'] * sample_rate / 1000)\n", + " timestamp['end'] = int(timestamp['end'] * sample_rate / 1000)" ] }, { diff --git a/utils.py b/utils.py index 597f4b5..2d8c68c 100644 --- a/utils.py +++ b/utils.py @@ -124,16 +124,16 @@ def get_number_ts(wav: torch.Tensor, for i, pred in enumerate(extended_preds): if pred == 1: if not triggered: - cur_timing['start'] = (i * hop_length) / sample_rate + cur_timing['start'] = int((i * hop_length) / (sample_rate / 1000)) triggered = True elif pred == 0: if triggered: - cur_timing['end'] = (i * hop_length) / sample_rate + cur_timing['end'] = int((i * hop_length) / (sample_rate / 1000)) timings.append(cur_timing) cur_timing = {} triggered = False if cur_timing: - cur_timing['end'] = len(wav) / sample_rate + cur_timing['end'] = int(len(wav) / (sample_rate / 1000)) timings.append(cur_timing) return timings