Spaces:
Sleeping
Sleeping
Commit
·
7732184
1
Parent(s):
3650db9
Update app.py
Browse files
app.py
CHANGED
@@ -18,10 +18,12 @@ st.set_page_config(
|
|
18 |
)
|
19 |
|
20 |
#@st.cache_resource
|
21 |
-
#@st.cache_data
|
22 |
def download_audio(link):
|
23 |
-
with yt_dlp.YoutubeDL({'extract_audio': True, 'format': 'bestaudio', 'outtmpl': '
|
24 |
-
video.
|
|
|
|
|
|
|
25 |
|
26 |
#Load Whisper pipeline via HuggingFace
|
27 |
@st.cache_resource
|
@@ -54,7 +56,7 @@ def load_nltk():
|
|
54 |
|
55 |
#Make the ASR task
|
56 |
@st.cache_data
|
57 |
-
def audio_speech_recognition(_model_pipeline,
|
58 |
return _model_pipeline(video, batch_size=64)["text"].strip()
|
59 |
|
60 |
#Make the Summarization task
|
@@ -120,7 +122,7 @@ def main():
|
|
120 |
with st.spinner("Carregando modelos..."):
|
121 |
|
122 |
if language == "Inglês (en)":
|
123 |
-
download_audio(link)
|
124 |
load_nltk()
|
125 |
whisper = load_whisper()
|
126 |
extractive = load_extractive()
|
@@ -133,7 +135,7 @@ def main():
|
|
133 |
st.header("Erro na seleção de linguagem.")
|
134 |
|
135 |
with st.spinner("Transcrevendo texto..."):
|
136 |
-
transcript_text = audio_speech_recognition(whisper)
|
137 |
|
138 |
with model_1:
|
139 |
st.header("Texto Sumarizado:")
|
|
|
18 |
)
|
19 |
|
20 |
#@st.cache_resource
|
|
|
21 |
def download_audio(link):
|
22 |
+
with yt_dlp.YoutubeDL({'extract_audio': True, 'format': 'bestaudio', 'outtmpl': '%(id)s.mp3'}) as video:
|
23 |
+
info_dict = video.extract_info(link, download = True)
|
24 |
+
id = info_dict['id']
|
25 |
+
video.download(link)
|
26 |
+
return id
|
27 |
|
28 |
#Load Whisper pipeline via HuggingFace
|
29 |
@st.cache_resource
|
|
|
56 |
|
57 |
#Make the ASR task
|
58 |
@st.cache_data
|
59 |
+
def audio_speech_recognition(_model_pipeline, video_id):
|
60 |
return _model_pipeline(video, batch_size=64)["text"].strip()
|
61 |
|
62 |
#Make the Summarization task
|
|
|
122 |
with st.spinner("Carregando modelos..."):
|
123 |
|
124 |
if language == "Inglês (en)":
|
125 |
+
id = download_audio(link)
|
126 |
load_nltk()
|
127 |
whisper = load_whisper()
|
128 |
extractive = load_extractive()
|
|
|
135 |
st.header("Erro na seleção de linguagem.")
|
136 |
|
137 |
with st.spinner("Transcrevendo texto..."):
|
138 |
+
transcript_text = audio_speech_recognition(whisper, id)
|
139 |
|
140 |
with model_1:
|
141 |
st.header("Texto Sumarizado:")
|