Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,25 +1,25 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
from youtube_transcript_api import YouTubeTranscriptApi
|
| 3 |
|
| 4 |
-
|
|
|
|
| 5 |
try:
|
| 6 |
-
video_id =
|
|
|
|
|
|
|
|
|
|
| 7 |
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
final_transcript = ' '.join([i['text'] for i in transcript])
|
| 11 |
-
return final_transcript
|
| 12 |
except Exception as e:
|
| 13 |
-
|
| 14 |
|
| 15 |
-
# Create the Gradio interface
|
| 16 |
iface = gr.Interface(
|
| 17 |
-
fn=
|
| 18 |
-
inputs=gr.Textbox(
|
| 19 |
-
outputs=gr.Textbox(label="
|
| 20 |
-
title="YouTube
|
| 21 |
-
description="
|
| 22 |
)
|
| 23 |
|
| 24 |
-
# Launch the Gradio app
|
| 25 |
iface.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from youtube_transcript_api import YouTubeTranscriptApi
|
| 3 |
|
| 4 |
+
|
| 5 |
+
def transkribiere_youtube_video(video_url):
|
| 6 |
try:
|
| 7 |
+
video_id = video_url.split("v=")[1]
|
| 8 |
+
if "&" in video_id:
|
| 9 |
+
video_id = video_id.split("&")[0] # falls zusätzliche Parameter in URL
|
| 10 |
+
transcript = YouTubeTranscriptApi.get_transcript(video_id, languages=['de', 'en']) # Transkripte in DE & EN (falls vorhanden)
|
| 11 |
|
| 12 |
+
text = " ".join([entry['text'] for entry in transcript])
|
| 13 |
+
return text
|
|
|
|
|
|
|
| 14 |
except Exception as e:
|
| 15 |
+
return f"Fehler: {str(e)}. Stelle sicher, dass ein Transkript für das Video verfügbar ist und der Link korrekt ist."
|
| 16 |
|
|
|
|
| 17 |
iface = gr.Interface(
|
| 18 |
+
fn=transkribiere_youtube_video,
|
| 19 |
+
inputs=gr.Textbox(lines=1, placeholder="Gib hier den YouTube Video-Link ein"),
|
| 20 |
+
outputs=gr.Textbox(lines=20, label="Transkript"),
|
| 21 |
+
title="YouTube Transkription",
|
| 22 |
+
description="Gib einen YouTube-Videolink ein und erhalte den transkribierten Text."
|
| 23 |
)
|
| 24 |
|
|
|
|
| 25 |
iface.launch()
|