Spaces:
Sleeping
Sleeping
Commit
·
fb80730
1
Parent(s):
8694a76
Deploy Gradio app with fixed issues
Browse files- app.py +16 -1
- requirements.txt +4 -1
app.py
CHANGED
@@ -1,3 +1,4 @@
|
|
|
|
1 |
import gradio as gr
|
2 |
import time
|
3 |
import logging
|
@@ -7,6 +8,8 @@ from transformers import pipeline, AutoModelForSpeechSeq2Seq, AutoProcessor
|
|
7 |
from transformers.utils import is_flash_attn_2_available
|
8 |
from languages import get_language_names
|
9 |
from subtitle_manager import Subtitle
|
|
|
|
|
10 |
|
11 |
logging.basicConfig(level=logging.INFO)
|
12 |
last_model = None
|
@@ -47,6 +50,12 @@ def create_pipe(model, flash):
|
|
47 |
)
|
48 |
return pipe
|
49 |
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
def transcribe_webui_simple_progress(modelName, languageName, urlData, multipleFiles, microphoneData, task, flash,
|
51 |
chunk_length_s, batch_size, progress=gr.Progress()):
|
52 |
global last_model
|
@@ -82,7 +91,13 @@ def transcribe_webui_simple_progress(modelName, languageName, urlData, multipleF
|
|
82 |
if multipleFiles:
|
83 |
files += multipleFiles
|
84 |
if urlData:
|
85 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
86 |
if microphoneData:
|
87 |
files.append(microphoneData)
|
88 |
logging.info(files)
|
|
|
1 |
+
|
2 |
import gradio as gr
|
3 |
import time
|
4 |
import logging
|
|
|
8 |
from transformers.utils import is_flash_attn_2_available
|
9 |
from languages import get_language_names
|
10 |
from subtitle_manager import Subtitle
|
11 |
+
from pytube import YouTube
|
12 |
+
import os
|
13 |
|
14 |
logging.basicConfig(level=logging.INFO)
|
15 |
last_model = None
|
|
|
50 |
)
|
51 |
return pipe
|
52 |
|
53 |
+
def download_youtube_audio(url):
|
54 |
+
yt = YouTube(url)
|
55 |
+
audio_stream = yt.streams.filter(only_audio=True).first()
|
56 |
+
output_file = audio_stream.download(filename='temp_audio')
|
57 |
+
return output_file
|
58 |
+
|
59 |
def transcribe_webui_simple_progress(modelName, languageName, urlData, multipleFiles, microphoneData, task, flash,
|
60 |
chunk_length_s, batch_size, progress=gr.Progress()):
|
61 |
global last_model
|
|
|
91 |
if multipleFiles:
|
92 |
files += multipleFiles
|
93 |
if urlData:
|
94 |
+
try:
|
95 |
+
progress(0.2, desc="Downloading YouTube Audio..")
|
96 |
+
url_audio_file = download_youtube_audio(urlData)
|
97 |
+
files.append(url_audio_file)
|
98 |
+
except Exception as e:
|
99 |
+
logging.error(f"Failed to download YouTube audio: {e}")
|
100 |
+
return ["Error"], "Error", "Error"
|
101 |
if microphoneData:
|
102 |
files.append(microphoneData)
|
103 |
logging.info(files)
|
requirements.txt
CHANGED
@@ -2,4 +2,7 @@
|
|
2 |
torch>=2.1.1
|
3 |
gradio==4.16.0
|
4 |
transformers
|
5 |
-
accelerate
|
|
|
|
|
|
|
|
2 |
torch>=2.1.1
|
3 |
gradio==4.16.0
|
4 |
transformers
|
5 |
+
accelerate
|
6 |
+
pytube
|
7 |
+
optimum
|
8 |
+
safetensors
|