Skip to content

Commit

Permalink
Merge pull request #78 from jhj0517/add-colab
Browse files Browse the repository at this point in the history
Add colab
  • Loading branch information
jhj0517 committed Jan 15, 2024
2 parents 986ccb6 + 7274d07 commit 6222690
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
1 change: 1 addition & 0 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ def launch(self):
parser.add_argument('--username', type=str, default=None, help='Gradio authentication username')
parser.add_argument('--password', type=str, default=None, help='Gradio authentication password')
parser.add_argument('--theme', type=str, default=None, help='Gradio Blocks theme')
parser.add_argument('--colab', type=bool, default=False, nargs='?', const=True, help='Is colab user or not')
_args = parser.parse_args()

if __name__ == "__main__":
Expand Down
3 changes: 3 additions & 0 deletions modules/subtitle_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,11 @@ def get_serialized_vtt(dicts):


def safe_filename(name):
from app import _args
INVALID_FILENAME_CHARS = r'[<>:"/\\|?*\x00-\x1f]'
safe_name = re.sub(INVALID_FILENAME_CHARS, '_', name)
if not _args.colab:
return safe_name
# Truncate the filename if it exceeds the max_length (20)
if len(safe_name) > 20:
file_extension = safe_name.split('.')[-1]
Expand Down
13 changes: 5 additions & 8 deletions notebook/whisper-webui.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@
"!nvidia-smi"
],
"metadata": {
"id": "23yZvUlagEsx",
"cellView": "form"
"id": "23yZvUlagEsx"
},
"execution_count": null,
"outputs": []
Expand Down Expand Up @@ -85,8 +84,7 @@
"#@markdown If you wonder how these arguments are used, you can see the [Wiki](https://github.com/jhj0517/Whisper-WebUI/wiki/Command-Line-Arguments)."
],
"metadata": {
"id": "Qosz9BFlGui3",
"cellView": "form"
"id": "Qosz9BFlGui3"
},
"execution_count": null,
"outputs": []
Expand All @@ -95,17 +93,16 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "PQroYRRZzQiN",
"cellView": "form"
"id": "PQroYRRZzQiN"
},
"outputs": [],
"source": [
"#@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{arguments}\n",
" !python app.py --share --colab{arguments}\n",
"else:\n",
" !python app.py --share"
" !python app.py --share --colab"
]
}
],
Expand Down

0 comments on commit 6222690

Please sign in to comment.