Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions whispermlx/vads/silero.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,12 @@ def __call__(self, audio: AudioFile, **kwargs):
if sample_rate != 16000:
raise ValueError("Only 16000Hz sample rate is allowed")

waveform = audio["waveform"]
if not torch.is_tensor(waveform):
waveform = torch.as_tensor(waveform, dtype=torch.float32)

timestamps = self.get_speech_timestamps(
audio["waveform"].to(self.device),
waveform.to(self.device),
model=self.vad_pipeline,
sampling_rate=sample_rate,
max_speech_duration_s=self.chunk_size,
Expand All @@ -59,7 +63,9 @@ def __call__(self, audio: AudioFile, **kwargs):

@staticmethod
def preprocess_audio(audio):
return audio
if torch.is_tensor(audio):
return audio.to(dtype=torch.float32)
return torch.as_tensor(audio, dtype=torch.float32)

@staticmethod
def merge_chunks(
Expand Down
Loading