Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,21 +1,27 @@
|
|
1 |
# Required Libraries
|
|
|
|
|
2 |
import whisper
|
3 |
from groq import Groq
|
4 |
from gtts import gTTS
|
5 |
import gradio as gr
|
6 |
-
import os
|
7 |
-
import tempfile
|
8 |
from pydub import AudioSegment
|
9 |
|
10 |
# ---------------------------
|
11 |
# π API Key Configuration
|
12 |
# ---------------------------
|
13 |
-
GROQ_API_KEY= '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'
|
14 |
|
15 |
-
|
16 |
-
|
17 |
-
#
|
18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
|
20 |
# ---------------------------
|
21 |
# ποΈ Audio Processing
|
@@ -69,6 +75,7 @@ def get_groq_response(user_input):
|
|
69 |
"""Get chatbot response from Groq's API."""
|
70 |
try:
|
71 |
print(f"[INFO] Sending input to Groq: {user_input}")
|
|
|
72 |
chat_completion = client.chat.completions.create(
|
73 |
messages=[
|
74 |
{"role": "user", "content": user_input}
|
@@ -154,4 +161,5 @@ interface = gr.Interface(
|
|
154 |
|
155 |
# Launch Gradio App
|
156 |
if __name__ == "__main__":
|
|
|
157 |
interface.launch(share=True)
|
|
|
1 |
# Required Libraries
|
2 |
+
import os
|
3 |
+
import tempfile
|
4 |
import whisper
|
5 |
from groq import Groq
|
6 |
from gtts import gTTS
|
7 |
import gradio as gr
|
|
|
|
|
8 |
from pydub import AudioSegment
|
9 |
|
10 |
# ---------------------------
|
11 |
# π API Key Configuration
|
12 |
# ---------------------------
|
13 |
+
os.environ['GROQ_API_KEY'] = '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'
|
14 |
|
15 |
+
# ---------------------------
|
16 |
+
# π₯ Load Whisper Model
|
17 |
+
# ---------------------------
|
18 |
+
try:
|
19 |
+
whisper_model = whisper.load_model("base")
|
20 |
+
print("[INFO] Whisper model loaded successfully.")
|
21 |
+
except AttributeError:
|
22 |
+
from whisper import Whisper
|
23 |
+
whisper_model = Whisper.load_model("base")
|
24 |
+
print("[INFO] Whisper model loaded using alternative syntax.")
|
25 |
|
26 |
# ---------------------------
|
27 |
# ποΈ Audio Processing
|
|
|
75 |
"""Get chatbot response from Groq's API."""
|
76 |
try:
|
77 |
print(f"[INFO] Sending input to Groq: {user_input}")
|
78 |
+
client = Groq(api_key=os.environ['GROQ_API_KEY'])
|
79 |
chat_completion = client.chat.completions.create(
|
80 |
messages=[
|
81 |
{"role": "user", "content": user_input}
|
|
|
161 |
|
162 |
# Launch Gradio App
|
163 |
if __name__ == "__main__":
|
164 |
+
print("[INFO] Starting Gradio Interface...")
|
165 |
interface.launch(share=True)
|