Safwanahmad619 commited on
Commit
94786a8
·
verified ·
1 Parent(s): 433c053

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -12
app.py CHANGED
@@ -54,19 +54,18 @@
54
  # )
55
 
56
  # iface.launch()
57
-
58
  import os
59
  import gradio as gr
60
  import whisper
61
  from gtts import gTTS
62
- from gemani import Gemani # Assuming you have a Gemani client similar to Groq
63
  import io # Import io for BytesIO
64
 
65
- # Get the Gemani API key from environment variables
66
- GEMANI_API_KEY = os.getenv("GEMANI_API_KEY")
67
- if not GEMANI_API_KEY:
68
- raise ValueError("GEMANI_API_KEY environment variable is not set.")
69
- client = Gemani(api_key=GEMANI_API_KEY) # Initialize the Gemani client
70
 
71
  # Load Whisper model
72
  model = whisper.load_model("base")
@@ -80,12 +79,13 @@ def chatbot(audio=None):
80
  transcription = model.transcribe(audio)
81
  user_input = transcription.get("text", "")
82
 
83
- # Generate a response using Gemani API
84
- chat_completion = client.chat.completions.create(
85
- messages=[{"role": "user", "content": user_input}],
86
- model="gemani-model-8b", # Replace with the correct model name for Gemani
 
87
  )
88
- response_text = chat_completion.choices[0].message.content
89
 
90
  # Convert the response text to speech using gTTS
91
  tts = gTTS(text=response_text, lang='en')
 
54
  # )
55
 
56
  # iface.launch()
 
57
  import os
58
  import gradio as gr
59
  import whisper
60
  from gtts import gTTS
61
+ from anthropic import Anthropic # Import the Anthropic client
62
  import io # Import io for BytesIO
63
 
64
+ # Get the Anthropic API key from environment variables
65
+ ANTHROPIC_API_KEY = os.getenv("anthropic_key")
66
+ if not ANTHROPIC_API_KEY:
67
+ raise ValueError("ANTHROPIC_API_KEY environment variable is not set.")
68
+ client = Anthropic(api_key=ANTHROPIC_API_KEY) # Initialize the Anthropic client
69
 
70
  # Load Whisper model
71
  model = whisper.load_model("base")
 
79
  transcription = model.transcribe(audio)
80
  user_input = transcription.get("text", "")
81
 
82
+ # Generate a response using Anthropic API
83
+ chat_completion = client.completions.create(
84
+ prompt=user_input,
85
+ model="claude-v1", # Replace with the correct model name for Anthropic
86
+ max_tokens=100, # Adjust as needed
87
  )
88
+ response_text = chat_completion['completion']
89
 
90
  # Convert the response text to speech using gTTS
91
  tts = gTTS(text=response_text, lang='en')