Rohannk commited on
Commit
d7c0552
·
verified ·
1 Parent(s): 290326e

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +97 -0
app.py ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import whisper
3
+ import google.generativeai as genai
4
+
5
+ # Gemini API
6
+ genai.configure(api_key="import gradio as gr
7
+ import whisper
8
+ import google.generativeai as genai
9
+
10
+ # Gemini API
11
+ genai.configure(api_key="import gradio as gr
12
+ import whisper
13
+ import google.generativeai as genai
14
+
15
+ # Gemini API
16
+ genai.configure(api_key="AIzaSyABCcQc7tbhSRH-QE1hwgTFgncC5RcANoU")
17
+
18
+ # Load models
19
+ speech_model = whisper.load_model("base")
20
+ ai_model = genai.GenerativeModel("gemini-1.5-flash")
21
+
22
+ def voice_assistant(audio):
23
+
24
+ # Speech to text
25
+ result = speech_model.transcribe(audio)
26
+
27
+ user_text = result["text"]
28
+
29
+ # Gemini response
30
+ response = ai_model.generate_content(user_text)
31
+
32
+ return f"You said: {user_text}\n\nAI: {response.text}"
33
+
34
+ # Gradio UI
35
+ interface = gr.Interface(
36
+ fn=voice_assistant,
37
+ inputs=gr.Audio(type="filepath"),
38
+ outputs="text",
39
+ title="AI Voice Assistant",
40
+ description="Speak and get AI responses"
41
+ )
42
+
43
+ interface.launch()")
44
+
45
+ # Load models
46
+ speech_model = whisper.load_model("base")
47
+ ai_model = genai.GenerativeModel("gemini-1.5-flash")
48
+
49
+ def voice_assistant(audio):
50
+
51
+ # Speech to text
52
+ result = speech_model.transcribe(audio)
53
+
54
+ user_text = result["text"]
55
+
56
+ # Gemini response
57
+ response = ai_model.generate_content(user_text)
58
+
59
+ return f"You said: {user_text}\n\nAI: {response.text}"
60
+
61
+ # Gradio UI
62
+ interface = gr.Interface(
63
+ fn=voice_assistant,
64
+ inputs=gr.Audio(type="filepath"),
65
+ outputs="text",
66
+ title="AI Voice Assistant",
67
+ description="Speak and get AI responses"
68
+ )
69
+
70
+ interface.launch()")
71
+
72
+ # Load models
73
+ speech_model = whisper.load_model("base")
74
+ ai_model = genai.GenerativeModel("gemini-1.5-flash")
75
+
76
+ def voice_assistant(audio):
77
+
78
+ # Speech to text
79
+ result = speech_model.transcribe(audio)
80
+
81
+ user_text = result["text"]
82
+
83
+ # Gemini response
84
+ response = ai_model.generate_content(user_text)
85
+
86
+ return f"You said: {user_text}\n\nAI: {response.text}"
87
+
88
+ # Gradio UI
89
+ interface = gr.Interface(
90
+ fn=voice_assistant,
91
+ inputs=gr.Audio(type="filepath"),
92
+ outputs="text",
93
+ title="AI Voice Assistant",
94
+ description="Speak and get AI responses"
95
+ )
96
+
97
+ interface.launch()