Spaces:
Running
Running
jhj0517
commited on
Commit
·
07b6329
1
Parent(s):
b678293
rename the variables
Browse files
modules/vad/silero_vad.py
CHANGED
|
@@ -240,15 +240,15 @@ class SileroVAD:
|
|
| 240 |
Returns:
|
| 241 |
Tuple containing:
|
| 242 |
- Processed audio as a numpy array
|
| 243 |
-
- Duration of
|
| 244 |
"""
|
| 245 |
if not chunks:
|
| 246 |
return np.array([], dtype=np.float32), 0.0
|
| 247 |
|
| 248 |
total_samples = audio.shape[0]
|
| 249 |
-
|
| 250 |
-
|
| 251 |
-
|
| 252 |
|
| 253 |
if not silence_non_speech:
|
| 254 |
processed_audio = np.concatenate([audio[chunk["start"]: chunk["end"]] for chunk in chunks])
|
|
@@ -258,7 +258,7 @@ class SileroVAD:
|
|
| 258 |
start, end = chunk['start'], chunk['end']
|
| 259 |
processed_audio[start:end] = audio[start:end]
|
| 260 |
|
| 261 |
-
return processed_audio,
|
| 262 |
|
| 263 |
@staticmethod
|
| 264 |
def format_timestamp(
|
|
|
|
| 240 |
Returns:
|
| 241 |
Tuple containing:
|
| 242 |
- Processed audio as a numpy array
|
| 243 |
+
- Duration of non-speech (silenced or removed) audio in seconds
|
| 244 |
"""
|
| 245 |
if not chunks:
|
| 246 |
return np.array([], dtype=np.float32), 0.0
|
| 247 |
|
| 248 |
total_samples = audio.shape[0]
|
| 249 |
+
speech_samples_count = sum(chunk["end"] - chunk["start"] for chunk in chunks)
|
| 250 |
+
non_speech_samples_count = total_samples - speech_samples_count
|
| 251 |
+
non_speech_duration = non_speech_samples_count / self.sampling_rate
|
| 252 |
|
| 253 |
if not silence_non_speech:
|
| 254 |
processed_audio = np.concatenate([audio[chunk["start"]: chunk["end"]] for chunk in chunks])
|
|
|
|
| 258 |
start, end = chunk['start'], chunk['end']
|
| 259 |
processed_audio[start:end] = audio[start:end]
|
| 260 |
|
| 261 |
+
return processed_audio, non_speech_duration
|
| 262 |
|
| 263 |
@staticmethod
|
| 264 |
def format_timestamp(
|