Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,14 +1,26 @@
|
|
1 |
import os
|
2 |
import gradio as gr
|
3 |
import elevenlabs
|
|
|
4 |
from speech_recognition import Recognizer, AudioFile
|
5 |
import io
|
6 |
from google import genai
|
7 |
from google.genai import types
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
|
9 |
# --- API Keys (Set as environment variables for security!) ---
|
10 |
genai_api_key = os.environ.get("GOOGLE_API_KEY") # Gemini API Key
|
11 |
-
elevenlabs_api_key = os.environ.get("ELEVENLABS_API_KEY")
|
12 |
|
13 |
#elevenlabs.set_api_key(elevenlabs_api_key)
|
14 |
elevenlabs.API_KEY = elevenlabs_api_key
|
@@ -56,7 +68,15 @@ def evaluate_answer(question, answer):
|
|
56 |
|
57 |
def text_to_speech(text, voice):
|
58 |
"""Converts text to speech using ElevenLabs."""
|
59 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
60 |
return audio
|
61 |
|
62 |
def transcribe_audio(audio_file):
|
|
|
1 |
import os
|
2 |
import gradio as gr
|
3 |
import elevenlabs
|
4 |
+
from elevenlabs.client import ElevenLabs
|
5 |
from speech_recognition import Recognizer, AudioFile
|
6 |
import io
|
7 |
from google import genai
|
8 |
from google.genai import types
|
9 |
+
from dotenv import load_dotenv
|
10 |
+
from elevenlabs import play
|
11 |
+
|
12 |
+
load_dotenv()
|
13 |
+
|
14 |
+
elevenlabs = ElevenLabs(
|
15 |
+
api_key=os.getenv("ELEVENLABS_API_KEY"),
|
16 |
+
)
|
17 |
+
|
18 |
+
|
19 |
+
|
20 |
|
21 |
# --- API Keys (Set as environment variables for security!) ---
|
22 |
genai_api_key = os.environ.get("GOOGLE_API_KEY") # Gemini API Key
|
23 |
+
#elevenlabs_api_key = os.environ.get("ELEVENLABS_API_KEY")
|
24 |
|
25 |
#elevenlabs.set_api_key(elevenlabs_api_key)
|
26 |
elevenlabs.API_KEY = elevenlabs_api_key
|
|
|
68 |
|
69 |
def text_to_speech(text, voice):
|
70 |
"""Converts text to speech using ElevenLabs."""
|
71 |
+
|
72 |
+
audio = elevenlabs.text_to_speech.convert(
|
73 |
+
text=text,
|
74 |
+
voice_id="JBFqnCBsd6RMkjVDRZzb",
|
75 |
+
model_id="eleven_multilingual_v2",
|
76 |
+
output_format="mp3_44100_128",
|
77 |
+
)
|
78 |
+
|
79 |
+
#audio = elevenlabs.tts(text=text, voice=voice, model="eleven_monolingual_v1")
|
80 |
return audio
|
81 |
|
82 |
def transcribe_audio(audio_file):
|