jhj0517 commited on
Commit
19ebfe1
2 Parent(s): f02937a 4c2c99c

Merge pull request #78 from jhj0517/add-colab

Browse files
app.py CHANGED
@@ -203,6 +203,7 @@ parser.add_argument('--server_port', type=int, default=None, help='Gradio server
203
  parser.add_argument('--username', type=str, default=None, help='Gradio authentication username')
204
  parser.add_argument('--password', type=str, default=None, help='Gradio authentication password')
205
  parser.add_argument('--theme', type=str, default=None, help='Gradio Blocks theme')
 
206
  _args = parser.parse_args()
207
 
208
  if __name__ == "__main__":
 
203
  parser.add_argument('--username', type=str, default=None, help='Gradio authentication username')
204
  parser.add_argument('--password', type=str, default=None, help='Gradio authentication password')
205
  parser.add_argument('--theme', type=str, default=None, help='Gradio Blocks theme')
206
+ parser.add_argument('--colab', type=bool, default=False, nargs='?', const=True, help='Is colab user or not')
207
  _args = parser.parse_args()
208
 
209
  if __name__ == "__main__":
modules/subtitle_manager.py CHANGED
@@ -119,8 +119,11 @@ def get_serialized_vtt(dicts):
119
 
120
 
121
  def safe_filename(name):
 
122
  INVALID_FILENAME_CHARS = r'[<>:"/\\|?*\x00-\x1f]'
123
  safe_name = re.sub(INVALID_FILENAME_CHARS, '_', name)
 
 
124
  # Truncate the filename if it exceeds the max_length (20)
125
  if len(safe_name) > 20:
126
  file_extension = safe_name.split('.')[-1]
 
119
 
120
 
121
  def safe_filename(name):
122
+ from app import _args
123
  INVALID_FILENAME_CHARS = r'[<>:"/\\|?*\x00-\x1f]'
124
  safe_name = re.sub(INVALID_FILENAME_CHARS, '_', name)
125
+ if not _args.colab:
126
+ return safe_name
127
  # Truncate the filename if it exceeds the max_length (20)
128
  if len(safe_name) > 20:
129
  file_extension = safe_name.split('.')[-1]
notebook/whisper-webui.ipynb CHANGED
@@ -36,8 +36,7 @@
36
  "!nvidia-smi"
37
  ],
38
  "metadata": {
39
- "id": "23yZvUlagEsx",
40
- "cellView": "form"
41
  },
42
  "execution_count": null,
43
  "outputs": []
@@ -85,8 +84,7 @@
85
  "#@markdown If you wonder how these arguments are used, you can see the [Wiki](https://github.com/jhj0517/Whisper-WebUI/wiki/Command-Line-Arguments)."
86
  ],
87
  "metadata": {
88
- "id": "Qosz9BFlGui3",
89
- "cellView": "form"
90
  },
91
  "execution_count": null,
92
  "outputs": []
@@ -95,17 +93,16 @@
95
  "cell_type": "code",
96
  "execution_count": null,
97
  "metadata": {
98
- "id": "PQroYRRZzQiN",
99
- "cellView": "form"
100
  },
101
  "outputs": [],
102
  "source": [
103
  "#@title #Run\n",
104
  "#@markdown Once the installation is complete, you can use public URL that is displayed.\n",
105
  "if 'arguments' in locals():\n",
106
- " !python app.py --share{arguments}\n",
107
  "else:\n",
108
- " !python app.py --share"
109
  ]
110
  }
111
  ],
 
36
  "!nvidia-smi"
37
  ],
38
  "metadata": {
39
+ "id": "23yZvUlagEsx"
 
40
  },
41
  "execution_count": null,
42
  "outputs": []
 
84
  "#@markdown If you wonder how these arguments are used, you can see the [Wiki](https://github.com/jhj0517/Whisper-WebUI/wiki/Command-Line-Arguments)."
85
  ],
86
  "metadata": {
87
+ "id": "Qosz9BFlGui3"
 
88
  },
89
  "execution_count": null,
90
  "outputs": []
 
93
  "cell_type": "code",
94
  "execution_count": null,
95
  "metadata": {
96
+ "id": "PQroYRRZzQiN"
 
97
  },
98
  "outputs": [],
99
  "source": [
100
  "#@title #Run\n",
101
  "#@markdown Once the installation is complete, you can use public URL that is displayed.\n",
102
  "if 'arguments' in locals():\n",
103
+ " !python app.py --share --colab{arguments}\n",
104
  "else:\n",
105
+ " !python app.py --share --colab"
106
  ]
107
  }
108
  ],