Skip to content

Commit

Permalink
Move .cache/torch/hub to local for openvoice
Browse files Browse the repository at this point in the history
  • Loading branch information
sbalandi committed Sep 3, 2024
1 parent a85afef commit 2a88c21
Showing 1 changed file with 22 additions and 8 deletions.
30 changes: 22 additions & 8 deletions notebooks/openvoice/openvoice.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -748,6 +748,16 @@
"Audio(ref_speaker_path)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"torch_hub_local = Path(\"torch_hub_local/\")\n",
"%env TORCH_HOME={str(torch_hub_local.absolute())}"
]
},
{
"attachments": {},
"cell_type": "markdown",
Expand All @@ -768,17 +778,21 @@
"\n",
"url = \"https://github.com/snakers4/silero-vad/zipball/v3.0\"\n",
"\n",
"torch_hub_dir = torch.hub.get_dir()\n",
"torch_hub_dir = torch_hub_local / \"hub\"\n",
"torch.hub.set_dir(torch_hub_dir.as_posix())\n",
"\n",
"zip_filename = \"v3.0.zip\"\n",
"download_file(url, directory=torch_hub_dir, filename=zip_filename)\n",
"zip_ref = zipfile.ZipFile(Path(torch_hub_dir, zip_filename).as_posix(), \"r\")\n",
"output_path = Path(torch_hub_dir, \"v3.0\")\n",
"zip_ref.extractall(path=output_path.as_posix())\n",
"zip_ref.close()\n",
"output_path = torch_hub_dir / \"v3.0\"\n",
"if not (torch_hub_dir / zip_filename).exists():\n",
" download_file(url, directory=torch_hub_dir, filename=zip_filename)\n",
" zip_ref = zipfile.ZipFile((torch_hub_dir / zip_filename).as_posix(), \"r\")\n",
" zip_ref.extractall(path=output_path.as_posix())\n",
" zip_ref.close()\n",
"\n",
"v3_dirs = [d for d in output_path.iterdir() if \"snakers4-silero-vad\" in d.as_posix()]\n",
"if len(v3_dirs) > 0:\n",
" os.symlink(v3_dirs[0].as_posix(), Path(torch_hub_dir, \"snakers4_silero-vad_v3.0\").as_posix())"
"if len(v3_dirs) > 0 and not (torch_hub_dir / \"snakers4_silero-vad_v3.0\").exists():\n",
" v3_dir = str(v3_dirs[0])\n",
" os.rename(str(v3_dirs[0]), (torch_hub_dir / \"snakers4_silero-vad_v3.0\").as_posix())"
]
},
{
Expand Down

0 comments on commit 2a88c21

Please sign in to comment.