Update app.py
Browse files
app.py
CHANGED
@@ -5,10 +5,11 @@ import torch
|
|
5 |
import gradio as gr
|
6 |
from transformers import pipeline
|
7 |
|
8 |
-
text_summary = pipeline("summarization", model="
|
|
|
9 |
|
10 |
def summary (input):
|
11 |
-
max_length =
|
12 |
if len(input) > max_length:
|
13 |
input = input[:max_length]
|
14 |
output = text_summary(input)
|
@@ -45,7 +46,14 @@ def get_german_youtube_transcript(video_url):
|
|
45 |
formatter = TextFormatter()
|
46 |
text_transcript = formatter.format_transcript(transcript)
|
47 |
summary_text = summary(text_transcript)
|
48 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
49 |
except Exception as e:
|
50 |
return f"Es ist ein Fehler aufgetreten: {e}"
|
51 |
|
@@ -53,9 +61,12 @@ gr.close_all()
|
|
53 |
|
54 |
demo = gr.Interface(fn=get_german_youtube_transcript,
|
55 |
inputs=[gr.Textbox(label="YouTube Url zum Zusammenfassen eingeben",lines=1)],
|
56 |
-
outputs=[
|
57 |
-
|
58 |
-
|
|
|
|
|
|
|
59 |
allow_flagging="never",
|
60 |
submit_btn="Übermitteln",
|
61 |
clear_btn="Bereinigen",
|
|
|
5 |
import gradio as gr
|
6 |
from transformers import pipeline
|
7 |
|
8 |
+
text_summary = pipeline("summarization", model="sshleifer/distilbart-cnn-12-6", torch_dtype=torch.bfloat16)
|
9 |
+
text_translate = pipeline("translation", model="google-t5/t5-small", torch_dtype=torch.bfloat16)
|
10 |
|
11 |
def summary (input):
|
12 |
+
max_length = 2048 # adjust this value as needed
|
13 |
if len(input) > max_length:
|
14 |
input = input[:max_length]
|
15 |
output = text_summary(input)
|
|
|
46 |
formatter = TextFormatter()
|
47 |
text_transcript = formatter.format_transcript(transcript)
|
48 |
summary_text = summary(text_transcript)
|
49 |
+
|
50 |
+
summary_text = summary_text[:300]
|
51 |
+
#text_transcript = text_transcript[:300] # truncate to 300 characters
|
52 |
+
|
53 |
+
#transcript_output = text_translate(text_transcript)
|
54 |
+
#transcript_output = transcript_output[0]['translation_text']
|
55 |
+
summary_output = text_translate(summary_text)
|
56 |
+
return summary_output[0]['translation_text'], text_transcript
|
57 |
except Exception as e:
|
58 |
return f"Es ist ein Fehler aufgetreten: {e}"
|
59 |
|
|
|
61 |
|
62 |
demo = gr.Interface(fn=get_german_youtube_transcript,
|
63 |
inputs=[gr.Textbox(label="YouTube Url zum Zusammenfassen eingeben",lines=1)],
|
64 |
+
outputs=[
|
65 |
+
gr.Textbox(label="Zusammengefasster Text (DE)",lines=4),
|
66 |
+
gr.Textbox(label="Video-Transkript (EN)", lines=10)
|
67 |
+
],
|
68 |
+
title="Projekt 2: YouTube-Video(EN)-Zusammenfassung (DE)",
|
69 |
+
description="Diese Anwendung wird genutzt, um den Inhalt eines YouTube-Videos auf Englisch in eine deutsche Zusammenfassung zu übersetzen.",
|
70 |
allow_flagging="never",
|
71 |
submit_btn="Übermitteln",
|
72 |
clear_btn="Bereinigen",
|