Spaces:
Runtime error
Runtime error
David Li
commited on
Commit
•
4865ee0
1
Parent(s):
c98b0fc
fix: try again
Browse files
app.py
CHANGED
@@ -92,6 +92,13 @@ def get_text_from_mp3_whisper(inputType:str, mp3_file: str, url_path: str, taskN
|
|
92 |
# options = whisper.DecodingOptions(language="en", without_timestamps=True)
|
93 |
options = dict(language=srcLanguage)
|
94 |
transcribe_options = dict(task=taskName, **options)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
95 |
if inputType == "url":
|
96 |
filename = get_all_files(url_path)
|
97 |
result = model.transcribe(filename, **transcribe_options)
|
@@ -129,12 +136,14 @@ gr.Interface(
|
|
129 |
title = 'Download Video From url and extract text from audio',
|
130 |
fn=get_text_from_mp3_whisper,
|
131 |
inputs=[
|
132 |
-
gr.Dropdown(["url", "file"]),
|
133 |
gr.inputs.Audio(type="filepath"),
|
134 |
gr.inputs.Textbox(),
|
135 |
-
gr.Dropdown(["translate", "transcribe"]),
|
136 |
-
gr.Dropdown(["Japanese", "English"])
|
137 |
],
|
|
|
|
|
138 |
outputs=[
|
139 |
"json", "text", gr.outputs.Video(type="file")
|
140 |
],
|
|
|
92 |
# options = whisper.DecodingOptions(language="en", without_timestamps=True)
|
93 |
options = dict(language=srcLanguage)
|
94 |
transcribe_options = dict(task=taskName, **options)
|
95 |
+
# return if url_path is not set, taskName is not set, srcLanguage is not set
|
96 |
+
if not url_path:
|
97 |
+
return "url_path is not set"
|
98 |
+
if not taskName:
|
99 |
+
return "taskName is not set"
|
100 |
+
if not srcLanguage:
|
101 |
+
return "srcLanguage is not set"
|
102 |
if inputType == "url":
|
103 |
filename = get_all_files(url_path)
|
104 |
result = model.transcribe(filename, **transcribe_options)
|
|
|
136 |
title = 'Download Video From url and extract text from audio',
|
137 |
fn=get_text_from_mp3_whisper,
|
138 |
inputs=[
|
139 |
+
gr.Dropdown(["url", "file"], value="url"),
|
140 |
gr.inputs.Audio(type="filepath"),
|
141 |
gr.inputs.Textbox(),
|
142 |
+
gr.Dropdown(["translate", "transcribe"], value="translate"),
|
143 |
+
gr.Dropdown(["Japanese", "English"], value="Japanese")
|
144 |
],
|
145 |
+
button_text="Go!",
|
146 |
+
button_color="#333333",
|
147 |
outputs=[
|
148 |
"json", "text", gr.outputs.Video(type="file")
|
149 |
],
|