| 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() |