import gradio as gr from youtube_transcript_api import YouTubeTranscriptApi from shuttleai import ShuttleAI def summary(id): # Initialize the ShuttleAI client shuttleai = ShuttleAI() # Fetch the transcript from YouTube transcript = YouTubeTranscriptApi.get_transcript(id) # Combine the transcript into a single string transcript_text = " ".join([item['text'] for item in transcript]) # Request shuttle ai to summarize the transcript response = shuttleai.chat.completions.create( model="shuttle-2-turbo", messages=[ {"role": "system", "content": "You are going to be given a transcript by the user. You need to summarize this transcript to give a summary of the video. Summarize the video with a maximum of 4 sentences. Keep necessary details as needed."}, {"role": "user", "content": transcript_text} ], stream=False ) return response.choices[0].message.content with gr.Blocks() as demo: with gr.Tab("Summarize"): gr.Textbox() if __name__ == "__main__": demo.launch()