forked from saharmor/whisper-playground
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enhanced audio pre-processing by implementing voice activity detectio…
…n for selecting speech-containing audio chunks. Also, addressed end-of-stream behavior for sequential mode and cleanup behavior for disconnected clients. Tidied up some logging messages for better clarity.
- Loading branch information
Showing
6 changed files
with
55 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import torch | ||
from config import SPEECH_CONFIDENCE_THRESHOLD | ||
|
||
|
||
class SileroVAD: | ||
|
||
def __init__(self): | ||
self.model, self.utils = torch.hub.load( | ||
repo_or_dir='snakers4/silero-vad', | ||
model='silero_vad', | ||
force_reload=True | ||
) | ||
(self.get_speech_timestamps, self.save_audio, self.read_audio, self.VADIterator, | ||
self.collect_chunks) = self.utils | ||
|
||
def __call__(self, audio): | ||
confidence = self.model(torch.from_numpy(audio), 16000).item() | ||
return confidence >= SPEECH_CONFIDENCE_THRESHOLD, confidence | ||
|
||
|
||
silero_vad = SileroVAD() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters