Ath
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -1,13 +1,10 @@
|
|
1 |
-
# Install the necessary libraries
|
2 |
-
!pip install google-generativeai requests gradio
|
3 |
-
|
4 |
import os
|
5 |
import requests
|
6 |
import google.generativeai as genai
|
7 |
import gradio as gr
|
8 |
|
9 |
# Configure your Google Generative AI API key
|
10 |
-
genai.configure(api_key="
|
11 |
|
12 |
# Create the model
|
13 |
generation_config = {
|
@@ -27,7 +24,7 @@ model = genai.GenerativeModel(
|
|
27 |
chat_session = model.start_chat(history=[])
|
28 |
|
29 |
# Eleven Labs API configuration
|
30 |
-
eleven_labs_api_key = "
|
31 |
eleven_labs_url = "https://api.elevenlabs.io/v1/text-to-speech/aEO01A4wXwd1O8GPgGlF"
|
32 |
|
33 |
def chat_and_tts(user_input):
|
@@ -53,7 +50,7 @@ def chat_and_tts(user_input):
|
|
53 |
|
54 |
# Check if the response is successful and save the audio content to a file
|
55 |
if tts_response.status_code == 200:
|
56 |
-
audio_path = '
|
57 |
with open(audio_path, 'wb') as file:
|
58 |
file.write(tts_response.content)
|
59 |
return response_text, audio_path
|
|
|
|
|
|
|
|
|
1 |
import os
|
2 |
import requests
|
3 |
import google.generativeai as genai
|
4 |
import gradio as gr
|
5 |
|
6 |
# Configure your Google Generative AI API key
|
7 |
+
genai.configure(api_key=os.getenv("GOOGLE_API_KEY"))
|
8 |
|
9 |
# Create the model
|
10 |
generation_config = {
|
|
|
24 |
chat_session = model.start_chat(history=[])
|
25 |
|
26 |
# Eleven Labs API configuration
|
27 |
+
eleven_labs_api_key = os.getenv("ELEVEN_LABS_API_KEY")
|
28 |
eleven_labs_url = "https://api.elevenlabs.io/v1/text-to-speech/aEO01A4wXwd1O8GPgGlF"
|
29 |
|
30 |
def chat_and_tts(user_input):
|
|
|
50 |
|
51 |
# Check if the response is successful and save the audio content to a file
|
52 |
if tts_response.status_code == 200:
|
53 |
+
audio_path = 'response_audio.mp3'
|
54 |
with open(audio_path, 'wb') as file:
|
55 |
file.write(tts_response.content)
|
56 |
return response_text, audio_path
|