mirror of
https://github.com/snakers4/silero-vad.git
synced 2026-02-05 18:09:22 +08:00
Merge pull request #421 from yairl/master
Perform in-place resampling during read_audio.
This commit is contained in:
@@ -122,6 +122,14 @@ class Validator():
|
|||||||
def read_audio(path: str,
|
def read_audio(path: str,
|
||||||
sampling_rate: int = 16000):
|
sampling_rate: int = 16000):
|
||||||
|
|
||||||
|
if 'sox' in torchaudio.list_available_backends():
|
||||||
|
effects = [
|
||||||
|
['channels', '1'],
|
||||||
|
['rate', str(sampling_rate)]
|
||||||
|
]
|
||||||
|
|
||||||
|
wav, sr = torchaudio.sox_effects.apply_effects_file(path, effects=effects)
|
||||||
|
else:
|
||||||
wav, sr = torchaudio.load(path)
|
wav, sr = torchaudio.load(path)
|
||||||
|
|
||||||
if wav.size(0) > 1:
|
if wav.size(0) > 1:
|
||||||
|
|||||||
Reference in New Issue
Block a user