Update app.py
Browse files
app.py
CHANGED
|
@@ -7,7 +7,7 @@ from faster_whisper import WhisperModel
|
|
| 7 |
import os
|
| 8 |
import re
|
| 9 |
import uuid
|
| 10 |
-
|
| 11 |
|
| 12 |
|
| 13 |
def get_language_name(lang_code):
|
|
@@ -228,13 +228,14 @@ def whisper_subtitle(uploaded_file,Source_Language,max_words_per_subtitle=8):
|
|
| 228 |
write_subtitles_to_file(word_segments, filename=customize_srt_name)
|
| 229 |
with open(original_txt_name, 'w', encoding='utf-8') as f1:
|
| 230 |
f1.write(text)
|
| 231 |
-
return
|
| 232 |
|
| 233 |
#@title Using Gradio Interface
|
| 234 |
def subtitle_maker(Audio_or_Video_File,Source_Language,max_words_per_subtitle):
|
| 235 |
try:
|
| 236 |
default_srt_path,customize_srt_path,word_level_srt_path,text_path=whisper_subtitle(Audio_or_Video_File,Source_Language,max_words_per_subtitle=max_words_per_subtitle)
|
| 237 |
-
except:
|
|
|
|
| 238 |
default_srt_path,customize_srt_path,word_level_srt_path,text_path=None,None,None,None
|
| 239 |
return default_srt_path,customize_srt_path,word_level_srt_path,text_path
|
| 240 |
|
|
|
|
| 7 |
import os
|
| 8 |
import re
|
| 9 |
import uuid
|
| 10 |
+
import shutil
|
| 11 |
|
| 12 |
|
| 13 |
def get_language_name(lang_code):
|
|
|
|
| 228 |
write_subtitles_to_file(word_segments, filename=customize_srt_name)
|
| 229 |
with open(original_txt_name, 'w', encoding='utf-8') as f1:
|
| 230 |
f1.write(text)
|
| 231 |
+
return original_srt_name,customize_srt_name,word_level_srt_name,original_txt_name
|
| 232 |
|
| 233 |
#@title Using Gradio Interface
|
| 234 |
def subtitle_maker(Audio_or_Video_File,Source_Language,max_words_per_subtitle):
|
| 235 |
try:
|
| 236 |
default_srt_path,customize_srt_path,word_level_srt_path,text_path=whisper_subtitle(Audio_or_Video_File,Source_Language,max_words_per_subtitle=max_words_per_subtitle)
|
| 237 |
+
except Exception as e:
|
| 238 |
+
print(f"Error in whisper_subtitle: {e}")
|
| 239 |
default_srt_path,customize_srt_path,word_level_srt_path,text_path=None,None,None,None
|
| 240 |
return default_srt_path,customize_srt_path,word_level_srt_path,text_path
|
| 241 |
|