Spaces:
Runtime error
Runtime error
David Li commited on
Commit ·
2079594
1
Parent(s): 8377508
fix: try again
Browse files
app.py
CHANGED
|
@@ -96,17 +96,21 @@ def get_all_files(url: str, end: str = "00:15:00"):
|
|
| 96 |
return filename
|
| 97 |
|
| 98 |
def get_text_from_mp3_whisper(inputType:str, mp3_file: str, url_path: str, taskName: str, srcLanguage: str)->str:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 99 |
model = whisper.load_model("medium")
|
| 100 |
# options = whisper.DecodingOptions(language="en", without_timestamps=True)
|
| 101 |
options = dict(language=srcLanguage)
|
| 102 |
transcribe_options = dict(task=taskName, **options)
|
| 103 |
# return if url_path is not set, taskName is not set, srcLanguage is not set
|
| 104 |
-
if not url_path:
|
| 105 |
-
return "url_path is not set"
|
| 106 |
-
if not taskName:
|
| 107 |
-
return "taskName is not set"
|
| 108 |
-
if not srcLanguage:
|
| 109 |
-
return "srcLanguage is not set"
|
| 110 |
if inputType == "url":
|
| 111 |
filename = get_all_files(url_path)
|
| 112 |
print("Retrieved the file")
|
|
|
|
| 96 |
return filename
|
| 97 |
|
| 98 |
def get_text_from_mp3_whisper(inputType:str, mp3_file: str, url_path: str, taskName: str, srcLanguage: str)->str:
|
| 99 |
+
# remove the file if it exists
|
| 100 |
+
if os.path.exists("transcript.srt"):
|
| 101 |
+
os.remove("transcript.srt")
|
| 102 |
+
|
| 103 |
+
if os.path.exists("temp.mp4"):
|
| 104 |
+
os.remove("temp.mp4")
|
| 105 |
+
|
| 106 |
+
if os.path.exists("subtitled.mp4"):
|
| 107 |
+
os.remove("subtitled.mp4")
|
| 108 |
+
|
| 109 |
model = whisper.load_model("medium")
|
| 110 |
# options = whisper.DecodingOptions(language="en", without_timestamps=True)
|
| 111 |
options = dict(language=srcLanguage)
|
| 112 |
transcribe_options = dict(task=taskName, **options)
|
| 113 |
# return if url_path is not set, taskName is not set, srcLanguage is not set
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 114 |
if inputType == "url":
|
| 115 |
filename = get_all_files(url_path)
|
| 116 |
print("Retrieved the file")
|