Skip to content

Commit

Permalink
Merge pull request #436 from jhj0517/feature/google-drive-mount
Browse files Browse the repository at this point in the history
Add Google Drive path mounting on Colab
  • Loading branch information
jhj0517 authored Dec 22, 2024
2 parents f1355bb + 2f26540 commit 6abf188
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 5 deletions.
4 changes: 3 additions & 1 deletion app.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,8 @@ def launch(self):
ssl_verify=args.ssl_verify,
ssl_keyfile=args.ssl_keyfile,
ssl_keyfile_password=args.ssl_keyfile_password,
ssl_certfile=args.ssl_certfile
ssl_certfile=args.ssl_certfile,
allowed_paths=eval(args.allowed_paths) if args.allowed_paths else None
)

@staticmethod
Expand Down Expand Up @@ -333,6 +334,7 @@ def on_change_models(model_size: str):
parser.add_argument('--colab', type=str2bool, default=False, nargs='?', const=True, help='Is colab user or not')
parser.add_argument('--api_open', type=str2bool, default=False, nargs='?', const=True,
help='Enable api or not in Gradio')
parser.add_argument('--allowed_paths', type=str, default=None, help='Gradio allowed paths')
parser.add_argument('--inbrowser', type=str2bool, default=True, nargs='?', const=True,
help='Whether to automatically start Gradio app or not')
parser.add_argument('--ssl_verify', type=str2bool, default=True, nargs='?', const=True,
Expand Down
44 changes: 40 additions & 4 deletions notebook/whisper-webui.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,42 @@
"!pip install git+https://github.com/jhj0517/ultimatevocalremover_api.git"
]
},
{
"cell_type": "code",
"source": [
"#@title # (Optional) Mount Google Drive\n",
"#@markdown Uploading large input files directly via UI may consume alot of time because it has to be uploaded in colab's server.\n",
"#@markdown <br>This section is for using the input file paths from Google Drive to reduce such file uploading time.\n",
"#@markdown <br>And it will mount the output paths to your Google Drive's. This section is optional and can be ignored.\n",
"\n",
"\n",
"# Mount Google Drive\n",
"from google.colab import drive\n",
"import os\n",
"drive.mount('/content/drive')\n",
"\n",
"\n",
"# Symlink Output Paths for Whisper-WebUI\n",
"import os\n",
"\n",
"OUTPUT_DIRECTORY_PATH = '/content/drive/MyDrive/Whisper-WebUI/outputs' # @param {type:\"string\"}\n",
"local_output_path = '/content/Whisper-WebUI/outputs'\n",
"os.makedirs(local_output_path, exist_ok=True)\n",
"os.makedirs(OUTPUT_DIRECTORY_PATH, exist_ok=True)\n",
"\n",
"if os.path.exists(local_output_path):\n",
" !rm -r \"$local_output_path\"\n",
"\n",
"os.symlink(OUTPUT_DIRECTORY_PATH, local_output_path)\n",
"!ls \"$local_output_path\""
],
"metadata": {
"cellView": "form",
"id": "y2DY5oSb9Bol"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"source": [
Expand Down Expand Up @@ -93,12 +129,12 @@
"id": "Qosz9BFlGui3",
"cellView": "form"
},
"execution_count": null,
"execution_count": 4,
"outputs": []
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 6,
"metadata": {
"id": "PQroYRRZzQiN",
"cellView": "form"
Expand All @@ -108,9 +144,9 @@
"#@title #Run\n",
"#@markdown Once the installation is complete, you can use public URL that is displayed.\n",
"if 'arguments' in locals():\n",
" !python app.py --share --colab{arguments}\n",
" !python app.py --share --colab --allowed_path \"['/content/Whisper-WebUI/outputs']\"{arguments}\n",
"else:\n",
" !python app.py --share --colab"
" !python app.py --share --colab --allowed_path \"['/content/Whisper-WebUI/outputs']\""
]
}
],
Expand Down

0 comments on commit 6abf188

Please sign in to comment.