Skip to content

Commit

Permalink
fix snakers4 silero-vad utils expansion (pytorch#261)
Browse files Browse the repository at this point in the history
* fix utils expansion

* get_speech_timestamp => get_speech_ts

* get_speech_timestamps sampling rate

* Update snakers4_silero-vad_vad.md

Co-authored-by: Nicolas Hug <[email protected]>

* Update snakers4_silero-vad_vad.md

Co-authored-by: Nicolas Hug <[email protected]>

Co-authored-by: Nicolas Hug <[email protected]>
  • Loading branch information
vmoens and NicolasHug authored Dec 14, 2021
1 parent 94f0352 commit 3bdedd9
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion snakers4_silero-vad_language.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ model, utils = torch.hub.load(repo_or_dir='snakers4/silero-vad',
model='silero_lang_detector',
force_reload=True)

get_language, read_audio = utils
get_language, read_audio, *_ = utils

files_dir = torch.hub.get_dir() + '/snakers4_silero-vad_master/files'

Expand Down
2 changes: 1 addition & 1 deletion snakers4_silero-vad_number.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ model, utils = torch.hub.load(repo_or_dir='snakers4/silero-vad',

(get_number_ts,
_, read_audio,
_, _) = utils
*_) = utils

files_dir = torch.hub.get_dir() + '/snakers4_silero-vad_master/files'

Expand Down
14 changes: 8 additions & 6 deletions snakers4_silero-vad_vad.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,24 @@ pip install -q torchaudio soundfile

```python
import torch

torch.set_num_threads(1)
from pprint import pprint

model, utils = torch.hub.load(repo_or_dir='snakers4/silero-vad',
model='silero_vad',
force_reload=True)

(get_speech_ts,
_, _, read_audio,
_, _, _) = utils
(get_speech_timestamps,
_, read_audio,
*_) = utils

files_dir = torch.hub.get_dir() + '/snakers4_silero-vad_master/files'

wav = read_audio(f'{files_dir}/en.wav')
speech_timestamps = get_speech_ts(wav, model,
num_steps=4)
sampling_rate = 16000 # also accepts 8000
wav = read_audio(f'{files_dir}/en.wav', sampling_rate=sampling_rate)
speech_timestamps = get_speech_timestamps(wav, model, sampling_rate=sampling_rate) # see docstring for other sampling rates

pprint(speech_timestamps)
```

Expand Down

0 comments on commit 3bdedd9

Please sign in to comment.