Spaces:
Sleeping
Sleeping
File size: 1,467 Bytes
f8c4214 789fbd1 f8c4214 5fdee6e |
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 47 48 49 50 51 52 |
from ai_client import Gemini
from extract_audio import simple_download_audio_from_youtube
from models import YTResultWithTranscript
import gradio as gr
import os
gemini = Gemini()
def summarize_audio(youtube_link: str):
yt_res = simple_download_audio_from_youtube(youtube_link)
yt_transcript = YTResultWithTranscript(
**yt_res.model_dump(), transcript="This is a transcript of the audio."
)
for chunk in gemini.generate_text(
yt_res.get_local_file_path(),
yt_res.id,
yt_res.uploader,
):
yt_transcript.transcript += chunk
yield yt_transcript.model_outputs()
demo = gr.Interface(
fn=summarize_audio,
inputs=gr.Textbox(label="YouTube Link"),
outputs=[
gr.Textbox(lines=1, label="ID"),
# title
gr.Textbox(lines=1, label="Title"),
# thumbnail_link
gr.Image(label="Thumbnail Link", type='filepath', show_download_button=True),
# uploader
gr.Textbox(lines=1, label="Uploader"),
# transcript
gr.Markdown(label="Transcript", show_copy_button=True),
],
title="Summarize Audio",
description="Summarize the content of an audio from a YouTube link.",
flagging_mode="never",
api_name="summarize",
)
def auth_handler(usr, pwd) -> bool:
username = os.environ.get("USERNAME")
password = os.environ.get("PASSWORD")
return usr == username and pwd == password
demo.launch(pwa=True, share=True)
|