mirror of
https://github.com/tcsenpai/youlama.git
synced 2025-06-07 03:35:41 +00:00
bugfixed the status bar
This commit is contained in:
parent
81e270d509
commit
9e3fa8af1e
54
app.py
54
app.py
@ -187,7 +187,7 @@ def create_interface():
|
|||||||
"### A powerful tool for transcribing and summarizing audio/video content"
|
"### A powerful tool for transcribing and summarizing audio/video content"
|
||||||
)
|
)
|
||||||
|
|
||||||
with gr.Tabs(selected=1) as tabs: # Set YouTube tab as default (index 1)
|
with gr.Tabs(selected="YouTube") as tabs: # Use tab name instead of index
|
||||||
with gr.TabItem("Local File"):
|
with gr.TabItem("Local File"):
|
||||||
gr.Markdown(
|
gr.Markdown(
|
||||||
"""
|
"""
|
||||||
@ -263,14 +263,13 @@ def create_interface():
|
|||||||
):
|
):
|
||||||
try:
|
try:
|
||||||
if not audio:
|
if not audio:
|
||||||
yield "", None, "", "Please upload an audio file"
|
return "", None, "", "Please upload an audio file"
|
||||||
return
|
|
||||||
|
|
||||||
# Update status for each step
|
# Update status for each step
|
||||||
yield "Loading model...", None, "", None
|
status = "Loading model..."
|
||||||
model = load_model(model)
|
model = load_model(model)
|
||||||
|
|
||||||
yield "Transcribing audio...", None, "", None
|
status = "Transcribing audio..."
|
||||||
segments, info = model.transcribe(
|
segments, info = model.transcribe(
|
||||||
audio,
|
audio,
|
||||||
language=lang if lang != "Auto-detect" else None,
|
language=lang if lang != "Auto-detect" else None,
|
||||||
@ -282,17 +281,20 @@ def create_interface():
|
|||||||
full_text = " ".join([segment.text for segment in segments])
|
full_text = " ".join([segment.text for segment in segments])
|
||||||
|
|
||||||
if summarize and OLLAMA_AVAILABLE:
|
if summarize and OLLAMA_AVAILABLE:
|
||||||
yield f"Generating summary...", info.language, "", None
|
status = "Generating summary..."
|
||||||
summary = ollama.summarize(full_text, ollama_model)
|
summary = ollama.summarize(full_text, ollama_model)
|
||||||
yield full_text, info.language, (
|
return (
|
||||||
summary if summary else ""
|
full_text,
|
||||||
), "Processing complete!"
|
info.language,
|
||||||
|
summary if summary else "",
|
||||||
|
"Processing complete!",
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
yield full_text, info.language, "", "Processing complete!"
|
return full_text, info.language, "", "Processing complete!"
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"Error in transcribe_with_summary: {str(e)}")
|
logger.error(f"Error in transcribe_with_summary: {str(e)}")
|
||||||
yield f"Error: {str(e)}", None, "", "Processing failed!"
|
return f"Error: {str(e)}", None, "", "Processing failed!"
|
||||||
|
|
||||||
transcribe_btn.click(
|
transcribe_btn.click(
|
||||||
fn=transcribe_with_summary,
|
fn=transcribe_with_summary,
|
||||||
@ -389,7 +391,7 @@ def create_interface():
|
|||||||
def process_yt_with_summary(url, model, lang, summarize, ollama_model):
|
def process_yt_with_summary(url, model, lang, summarize, ollama_model):
|
||||||
try:
|
try:
|
||||||
# Update status for each step
|
# Update status for each step
|
||||||
yield "Checking URL and fetching video information...", None, None, None, None
|
status = "Checking URL and fetching video information..."
|
||||||
result = process_youtube_url(
|
result = process_youtube_url(
|
||||||
url, model, lang, summarize, ollama_model
|
url, model, lang, summarize, ollama_model
|
||||||
)
|
)
|
||||||
@ -397,23 +399,31 @@ def create_interface():
|
|||||||
if len(result) == 4:
|
if len(result) == 4:
|
||||||
text, lang, source, summary = result
|
text, lang, source, summary = result
|
||||||
if source == "Subtitles":
|
if source == "Subtitles":
|
||||||
yield f"Processing subtitles...", None, None, None, None
|
status = "Processing subtitles..."
|
||||||
else:
|
else:
|
||||||
yield f"Transcribing video...", None, None, None, None
|
status = "Transcribing video..."
|
||||||
|
|
||||||
if summarize and summary:
|
if summarize and summary:
|
||||||
yield f"Generating summary...", None, None, None, None
|
status = "Generating summary..."
|
||||||
|
|
||||||
yield text, lang, source, (
|
return (
|
||||||
summary if summary else ""
|
text,
|
||||||
), "Processing complete!"
|
lang,
|
||||||
|
source,
|
||||||
|
summary if summary else "",
|
||||||
|
"Processing complete!",
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
yield result[0], result[1], result[
|
return (
|
||||||
2
|
result[0],
|
||||||
], "", f"Error: {result[0]}"
|
result[1],
|
||||||
|
result[2],
|
||||||
|
"",
|
||||||
|
f"Error: {result[0]}",
|
||||||
|
)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"Error in process_yt_with_summary: {str(e)}")
|
logger.error(f"Error in process_yt_with_summary: {str(e)}")
|
||||||
yield f"Error: {str(e)}", None, None, "", "Processing failed!"
|
return f"Error: {str(e)}", None, None, "", "Processing failed!"
|
||||||
|
|
||||||
yt_process_btn.click(
|
yt_process_btn.click(
|
||||||
fn=process_yt_with_summary,
|
fn=process_yt_with_summary,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user