marks
commited on
Commit
·
e9f6da1
1
Parent(s):
45c0e10
More async fixes
Browse files- api_clients.py +14 -5
api_clients.py
CHANGED
|
@@ -109,12 +109,21 @@ class OpenRouterClient:
|
|
| 109 |
class ElevenLabsClient:
|
| 110 |
def __init__(self, api_key: str):
|
| 111 |
self.api_key = api_key
|
|
|
|
| 112 |
|
| 113 |
-
def get_voices(self):
|
| 114 |
-
"""
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 118 |
|
| 119 |
async def generate_audio(self, text: str, voice_id: str):
|
| 120 |
"""Asynchronously generate audio"""
|
|
|
|
| 109 |
class ElevenLabsClient:
|
| 110 |
def __init__(self, api_key: str):
|
| 111 |
self.api_key = api_key
|
| 112 |
+
elevenlabs.set_api_key(api_key)
|
| 113 |
|
| 114 |
+
def get_voices(self) -> List[Tuple[str, str]]:
|
| 115 |
+
"""
|
| 116 |
+
Synchronously get available voices from ElevenLabs
|
| 117 |
+
|
| 118 |
+
Returns:
|
| 119 |
+
List of tuples containing (voice_id, voice_name)
|
| 120 |
+
"""
|
| 121 |
+
try:
|
| 122 |
+
voices = elevenlabs.voices()
|
| 123 |
+
return [(voice.voice_id, voice.name) for voice in voices]
|
| 124 |
+
except Exception as e:
|
| 125 |
+
logger.error("Failed to fetch voices from ElevenLabs", exc_info=True)
|
| 126 |
+
raise
|
| 127 |
|
| 128 |
async def generate_audio(self, text: str, voice_id: str):
|
| 129 |
"""Asynchronously generate audio"""
|