File size: 1,646 Bytes
f45d7ef
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1b96e76
647b3cc
f45d7ef
 
 
 
80fc7a5
 
f45d7ef
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import whisper
from pytube import YouTube
from transformers import pipeline
import gradio as gr
import os

model = whisper.load_model("base")
summarizer = pipeline("summarization")

def get_audio(url):
  yt = YouTube(url)
  video = yt.streams.filter(only_audio=True).first()
  out_file=video.download(output_path=".")
  base, ext = os.path.splitext(out_file)
  new_file = base+'.mp3'
  os.rename(out_file, new_file)
  a = new_file
  return a

def get_text(url):
  result = model.transcribe(get_audio(url))
  return result['text']

def get_summary(url):
  article = get_text(url)
  b = summarizer(article)
  b = b[0]['summary_text']
  return b
  
with gr.Blocks() as demo:
  gr.Markdown("<h1><center>Youtube-Video-Transkription  </center></h1>")
  gr.Markdown("<center>Gebe den Link deines Youtube Contents ein und klicke Enter</center>")
  with gr.Tab('Get the transcription of any Youtube video'):
    with gr.Row():
      input_text_1 = gr.Textbox(placeholder='Enter the Youtube video URL', label='URL')
      output_text_1 = gr.Textbox(placeholder='Transcription of the video', label='Transcription')
    result_button_1 = gr.Button('Sprache in Text wandeln')
  with gr.Tab('Zusammenfassung erstellen lassen'):
    with gr.Row():
      input_text = gr.Textbox(placeholder='Enter the Youtube video URL', label='URL')
      output_text = gr.Textbox(placeholder='Summary text of the Youtube Video', label='Summary')
    result_button = gr.Button('Get Summary')

  result_button.click(get_summary, inputs = input_text, outputs = output_text)
  result_button_1.click(get_text, inputs = input_text_1, outputs = output_text_1)
demo.launch(debug=True)