thomasanto7001 commited on
Commit
a12c6a1
·
verified ·
1 Parent(s): 13b3b06

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +55 -0
app.py ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Tech Trends Curator with Audio
2
+
3
+ import gradio as gr
4
+ from groq import Groq
5
+ from gtts import gTTS
6
+ import uuid
7
+ import os
8
+
9
+ client = Groq(api_key=os.environ["GROQ_API_KEY"])
10
+
11
+ def get_tech_trends_with_audio(user_input, history):
12
+ system_prompt = {
13
+ "role": "system",
14
+ "content": (
15
+ "You are a tech trend curator. Summarize the latest AI tools, GitHub projects, "
16
+ "and startup news in an engaging tone. If asked for fake/funny trends, be creative and witty."
17
+ )
18
+ }
19
+
20
+ messages = [system_prompt, {"role": "user", "content": user_input}]
21
+
22
+ response = client.chat.completions.create(
23
+ model="llama3-8b-8192",
24
+ messages=messages
25
+ )
26
+
27
+ output_text = response.choices[0].message.content
28
+
29
+ # Convert text to speech
30
+ tts = gTTS(output_text)
31
+ filename = f"/tmp/{uuid.uuid4()}.mp3"
32
+ tts.save(filename)
33
+
34
+ return output_text, filename
35
+
36
+ # Define Gradio Interface
37
+ interface = gr.Interface(
38
+ fn=get_tech_trends_with_audio,
39
+ inputs=gr.Textbox(placeholder="Ask for top trends, tools, or fake news", label="Your Question"),
40
+ outputs=[
41
+ gr.Textbox(label="Trend Summary"),
42
+ gr.Audio(label="Audio Summary")
43
+ ],
44
+ title="📈 Tech Trends Curator",
45
+ description="Get AI, GitHub, and startup trend summaries — now with audio!",
46
+ examples=[
47
+ ["Top 3 AI tools this week"],
48
+ ["Funny fake trends in tech"],
49
+ ["What’s hot on GitHub in AI?"]
50
+ ],
51
+ theme="soft"
52
+ )
53
+
54
+ # Launch the app
55
+ interface.launch(share=True)