Spaces:
Build error
Build error
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from youtube_transcript_api import YouTubeTranscriptApi
|
3 |
+
from shuttleai import ShuttleAI
|
4 |
+
def summary(id):
|
5 |
+
# Initialize the ShuttleAI client
|
6 |
+
shuttleai = ShuttleAI()
|
7 |
+
|
8 |
+
# Fetch the transcript from YouTube
|
9 |
+
transcript = YouTubeTranscriptApi.get_transcript(id)
|
10 |
+
|
11 |
+
# Combine the transcript into a single string
|
12 |
+
transcript_text = " ".join([item['text'] for item in transcript])
|
13 |
+
|
14 |
+
# Request shuttle ai to summarize the transcript
|
15 |
+
response = shuttleai.chat.completions.create(
|
16 |
+
model="shuttle-2-turbo",
|
17 |
+
messages=[
|
18 |
+
{"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."},
|
19 |
+
{"role": "user", "content": transcript_text}
|
20 |
+
],
|
21 |
+
stream=False
|
22 |
+
)
|
23 |
+
return response.choices[0].message.content
|
24 |
+
|
25 |
+
with gr.Blocks() as demo:
|
26 |
+
with gr.Tab("Summarize"):
|
27 |
+
gr.Textbox()
|
28 |
+
|
29 |
+
if __name__ == "__main__":
|
30 |
+
demo.launch()
|