jianfch / stable-ts

Transcription, forced alignment, and audio indexing with OpenAI's Whisper
MIT License
1.6k stars 177 forks source link

loading vad model from local installation #213

Closed psyntelis closed 10 months ago

psyntelis commented 1 year ago

Hi! Thanks for the amazing repo! This is really a great piece of work. I am trying to run the library in a virtual machine with no access to internet andI can't use VAD.

I tried to set the torch dir using:

torch.hub.set_dir(path_to_the_local_torch_hub_cache) and point to a dir where i hame manually stored the repo, but it doesn't work. torch.hub.load stills try to connect to the internet and eventually hangs.

To load successfully the repo i used the following command:

model, utils = torch.hub.load(repo_or_dir=path_to_local_dir_with_repo,
                              model='silero_vad',
                              source='local',
                              verbose=True
)

Is there another way to load the vad model from a local installation? If not, passing as an argument here wether the source is github or local would be useful.

jianfch commented 1 year ago

Once you loaded the model and utils, you can update stable_whisper.stabilization._model_cache with them and it will use those directly when vad=True.

model, utils = torch.hub.load(repo_or_dir=path_to_local_dir_with_repo,
                              model='silero_vad',
                              source='local',
                              verbose=True)
stable_whisper.stabilization._model_cache[False] = (model, utils[0])