File size: 1,203 Bytes
ffe8c29 a981350 7566213 05567ad bdd209a 1d3d315 894aa8c e3282cd 1d3d315 edf9387 1d3d315 e739471 ca4b433 894aa8c a981350 894aa8c c8201be e3282cd 1d3d315 959680d 6c30bc1 96cdea4 3393dc7 aa3ea41 c8201be 1d3d315 96cdea4 ffe8c29 aa3ea41 | 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 | import gradio as gr
import os
from downloader import download_from_yt
from transcriber import transcribe
from email_sender import send_email
from auth import authorize
from text_splitter import split_into_paragraphs
def execute(pin, youtube_url, translate):
if (not authorize(pin)):
return "Błąd autoryzacji!"
video_title, audio_path = download_from_yt(youtube_url)
text = transcribe(audio_path, translate)
formatted_text = split_into_paragraphs(text)
os.remove(audio_path)
is_sent = send_email(f"Transkrypcja {video_title}", formatted_text)
return "Skryba zabiera się do pracy! Wypatruj emaila :)" if is_sent else "Coś się popsuło, spróbuj ponownie później :("
code = gr.Textbox(label='PIN', type='password', placeholder='*********', max_lines=1)
yt_url = gr.Textbox(label='Adres YouTube', placeholder='https://www.youtube.com/watch?v=dQw4w9WgXcQ', max_lines=1)
should_translate = gr.Checkbox(label='Wymaga tłumaczenia na angielski?')
status = gr.Label(label='Status', value='Czekam na zlecenie!')
demo = gr.Interface(
fn=execute,
inputs=[code, yt_url, should_translate],
outputs=[status],
)
if __name__ == "__main__":
demo.launch() |