Commit
·
edb3bf2
1
Parent(s):
f386bb3
support url
Browse files
app.py
CHANGED
|
@@ -21,8 +21,8 @@
|
|
| 21 |
|
| 22 |
import logging
|
| 23 |
import os
|
| 24 |
-
import tempfile
|
| 25 |
import urllib.request
|
|
|
|
| 26 |
from pathlib import Path
|
| 27 |
|
| 28 |
import gradio as gr
|
|
@@ -142,15 +142,11 @@ def process_url(
|
|
| 142 |
url: str,
|
| 143 |
):
|
| 144 |
logging.info(f"Processing URL: {url}")
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
repo_id,
|
| 151 |
-
add_punctuation,
|
| 152 |
-
f.name,
|
| 153 |
-
)
|
| 154 |
|
| 155 |
|
| 156 |
def process(language: str, repo_id: str, add_punctuation: str, in_filename: str):
|
|
@@ -276,6 +272,7 @@ with demo:
|
|
| 276 |
|
| 277 |
url_button = gr.Button("Submit for recognition")
|
| 278 |
|
|
|
|
| 279 |
output_srt_file_audio_url = gr.File(
|
| 280 |
label="Generated subtitles", show_label=True
|
| 281 |
)
|
|
@@ -330,6 +327,7 @@ with demo:
|
|
| 330 |
url_textbox,
|
| 331 |
],
|
| 332 |
outputs=[
|
|
|
|
| 333 |
output_srt_file_audio_url,
|
| 334 |
output_info_audio_url,
|
| 335 |
output_textbox_audio_url,
|
|
|
|
| 21 |
|
| 22 |
import logging
|
| 23 |
import os
|
|
|
|
| 24 |
import urllib.request
|
| 25 |
+
import uuid
|
| 26 |
from pathlib import Path
|
| 27 |
|
| 28 |
import gradio as gr
|
|
|
|
| 142 |
url: str,
|
| 143 |
):
|
| 144 |
logging.info(f"Processing URL: {url}")
|
| 145 |
+
_, ext = os.path.splitext(url)
|
| 146 |
+
random_filename = f"{uuid.uuid4().hex}{ext}"
|
| 147 |
+
urllib.request.urlretrieve(url, random_filename)
|
| 148 |
+
os.system(f"ls -lh {random_filename}")
|
| 149 |
+
return random_filename, process(language, repo_id, add_punctuation, random_filename)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 150 |
|
| 151 |
|
| 152 |
def process(language: str, repo_id: str, add_punctuation: str, in_filename: str):
|
|
|
|
| 272 |
|
| 273 |
url_button = gr.Button("Submit for recognition")
|
| 274 |
|
| 275 |
+
output_audio_url = gr.Audio(label="Audio")
|
| 276 |
output_srt_file_audio_url = gr.File(
|
| 277 |
label="Generated subtitles", show_label=True
|
| 278 |
)
|
|
|
|
| 327 |
url_textbox,
|
| 328 |
],
|
| 329 |
outputs=[
|
| 330 |
+
output_audio_url,
|
| 331 |
output_srt_file_audio_url,
|
| 332 |
output_info_audio_url,
|
| 333 |
output_textbox_audio_url,
|