Spaces:
Runtime error
Runtime error
fixes to have two sepakers in the debug.py
Browse files- debug.py +13 -6
- speech_service.py +19 -3
debug.py
CHANGED
|
@@ -5,24 +5,31 @@ from speech_service import SpeechService
|
|
| 5 |
|
| 6 |
load_dotenv()
|
| 7 |
|
| 8 |
-
print ("Initializing CLIP templates")
|
| 9 |
-
clip_transform = CLIPTransform()
|
| 10 |
-
print ("CLIP success")
|
| 11 |
|
| 12 |
print ("Initializing Chat")
|
| 13 |
chat_service = ChatService()
|
| 14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
prompts = [
|
| 16 |
"hello, how are you today?",
|
| 17 |
-
"tell me about your
|
| 18 |
"hmm, interesting, tell me more about that.",
|
| 19 |
"wait, that is so interesting, what else?",
|
| 20 |
]
|
| 21 |
for prompt in prompts:
|
| 22 |
print (f'prompt: "{prompt}"')
|
|
|
|
| 23 |
response = chat_service.chat(prompt)
|
| 24 |
print (f'response: "{response}"')
|
| 25 |
-
|
| 26 |
|
| 27 |
|
| 28 |
print ("Chat success")
|
|
|
|
| 5 |
|
| 6 |
load_dotenv()
|
| 7 |
|
| 8 |
+
# print ("Initializing CLIP templates")
|
| 9 |
+
# clip_transform = CLIPTransform()
|
| 10 |
+
# print ("CLIP success")
|
| 11 |
|
| 12 |
print ("Initializing Chat")
|
| 13 |
chat_service = ChatService()
|
| 14 |
+
|
| 15 |
+
user_speech_service = SpeechService(voice_id="Adam")
|
| 16 |
+
ai_speech_service = SpeechService(voice_id="2OviOUQc1JsQRQgNkVBj") # Chales003
|
| 17 |
+
|
| 18 |
+
user_speech_service.print_voices()
|
| 19 |
+
|
| 20 |
+
|
| 21 |
prompts = [
|
| 22 |
"hello, how are you today?",
|
| 23 |
+
"tell me about your shadow self?",
|
| 24 |
"hmm, interesting, tell me more about that.",
|
| 25 |
"wait, that is so interesting, what else?",
|
| 26 |
]
|
| 27 |
for prompt in prompts:
|
| 28 |
print (f'prompt: "{prompt}"')
|
| 29 |
+
user_speech_service.speak(prompt)
|
| 30 |
response = chat_service.chat(prompt)
|
| 31 |
print (f'response: "{response}"')
|
| 32 |
+
ai_speech_service.speak(response)
|
| 33 |
|
| 34 |
|
| 35 |
print ("Chat success")
|
speech_service.py
CHANGED
|
@@ -5,20 +5,36 @@ from elevenlabs import generate, stream
|
|
| 5 |
|
| 6 |
|
| 7 |
class SpeechService:
|
| 8 |
-
def __init__(self):
|
| 9 |
account_sid = os.environ["ELEVENLABS_API_KEY"]
|
| 10 |
set_api_key(account_sid)
|
|
|
|
|
|
|
| 11 |
|
| 12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
def speak(self, prompt):
|
| 14 |
# audio = generate(
|
| 15 |
# text=prompt,
|
| 16 |
-
# voice=
|
| 17 |
-
# model=
|
| 18 |
# )
|
| 19 |
# play(audio)
|
| 20 |
audio_stream = generate(
|
| 21 |
text=prompt,
|
|
|
|
|
|
|
| 22 |
stream=True
|
| 23 |
)
|
| 24 |
# stream(audio_stream)
|
|
|
|
| 5 |
|
| 6 |
|
| 7 |
class SpeechService:
|
| 8 |
+
def __init__(self, voice_id="Bella", model_id="eleven_monolingual_v1"):
|
| 9 |
account_sid = os.environ["ELEVENLABS_API_KEY"]
|
| 10 |
set_api_key(account_sid)
|
| 11 |
+
self._voice_id = voice_id
|
| 12 |
+
self._model_id = model_id
|
| 13 |
|
| 14 |
|
| 15 |
+
# def print_models(self):
|
| 16 |
+
# models = generate()
|
| 17 |
+
# for model in models:
|
| 18 |
+
# print (model["id"], model["name"])
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
def print_voices(self):
|
| 22 |
+
from elevenlabs.api import Voices
|
| 23 |
+
voices = Voices.from_api()
|
| 24 |
+
for voice in voices:
|
| 25 |
+
print (voice)
|
| 26 |
+
|
| 27 |
def speak(self, prompt):
|
| 28 |
# audio = generate(
|
| 29 |
# text=prompt,
|
| 30 |
+
# voice=self._voice_id,
|
| 31 |
+
# model=self._model_id,
|
| 32 |
# )
|
| 33 |
# play(audio)
|
| 34 |
audio_stream = generate(
|
| 35 |
text=prompt,
|
| 36 |
+
voice=self._voice_id,
|
| 37 |
+
model=self._model_id,
|
| 38 |
stream=True
|
| 39 |
)
|
| 40 |
# stream(audio_stream)
|