Update engines/orpheus_engine.py
Browse files- engines/orpheus_engine.py +39 -43
engines/orpheus_engine.py
CHANGED
|
@@ -22,24 +22,11 @@ START_TOKEN_ID = 128259
|
|
| 22 |
END_TOKEN_IDS = [128009, 128260, 128261, 128257]
|
| 23 |
CUSTOM_TOKEN_PREFIX = "<custom_token_"
|
| 24 |
|
| 25 |
-
|
| 26 |
class OrpheusVoice:
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
Attributes:
|
| 31 |
-
name (str): The name of the voice. Must be one of the AVAILABLE_VOICES.
|
| 32 |
-
|
| 33 |
-
Raises:
|
| 34 |
-
ValueError: If the voice name provided is not in AVAILABLE_VOICES.
|
| 35 |
-
"""
|
| 36 |
-
def __init__(self, name: str):
|
| 37 |
-
# if name not in AVAILABLE_VOICES:
|
| 38 |
-
# raise ValueError(f"Invalid voice '{name}'. Available voices: {AVAILABLE_VOICES}")
|
| 39 |
-
self.name = name
|
| 40 |
|
| 41 |
-
def __repr__(self):
|
| 42 |
-
return f"OrpheusVoice(name='{self.name}')"
|
| 43 |
|
| 44 |
|
| 45 |
class OrpheusEngine(BaseEngine):
|
|
@@ -319,34 +306,43 @@ class OrpheusEngine(BaseEngine):
|
|
| 319 |
logging.info("Returning None after failed conversion.")
|
| 320 |
return None
|
| 321 |
|
| 322 |
-
def get_voices(self):
|
| 323 |
-
"""
|
| 324 |
-
Retrieve the list of available voices.
|
| 325 |
|
| 326 |
-
|
| 327 |
-
|
| 328 |
-
"""
|
| 329 |
-
|
| 330 |
-
|
| 331 |
-
|
| 332 |
-
"""
|
| 333 |
-
|
| 334 |
-
|
| 335 |
-
|
| 336 |
-
|
| 337 |
-
|
| 338 |
-
|
| 339 |
-
|
| 340 |
-
|
| 341 |
-
"""
|
| 342 |
-
|
| 343 |
-
|
| 344 |
-
|
| 345 |
-
|
| 346 |
-
|
| 347 |
-
|
| 348 |
-
|
| 349 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 350 |
|
| 351 |
def set_voice_parameters(self, **kwargs):
|
| 352 |
"""
|
|
|
|
| 22 |
END_TOKEN_IDS = [128009, 128260, 128261, 128257]
|
| 23 |
CUSTOM_TOKEN_PREFIX = "<custom_token_"
|
| 24 |
|
|
|
|
| 25 |
class OrpheusVoice:
|
| 26 |
+
def __init__(self, name: str, gender: str | None = None):
|
| 27 |
+
self.name = name
|
| 28 |
+
self.gender = gender # optional, falls du es anzeigen willst
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
|
|
|
|
|
|
|
| 30 |
|
| 31 |
|
| 32 |
class OrpheusEngine(BaseEngine):
|
|
|
|
| 306 |
logging.info("Returning None after failed conversion.")
|
| 307 |
return None
|
| 308 |
|
|
|
|
|
|
|
|
|
|
| 309 |
|
| 310 |
+
_SPEAKERS = [
|
| 311 |
+
# männlich
|
| 312 |
+
OrpheusVoice("Jakob", "m"),
|
| 313 |
+
OrpheusVoice("Anton", "m"),
|
| 314 |
+
OrpheusVoice("Julian", "m"),
|
| 315 |
+
OrpheusVoice("Jan", "m"),
|
| 316 |
+
OrpheusVoice("Alexander", "m"),
|
| 317 |
+
OrpheusVoice("Emil", "m"),
|
| 318 |
+
OrpheusVoice("Ben", "m"),
|
| 319 |
+
OrpheusVoice("Elias", "m"),
|
| 320 |
+
OrpheusVoice("Felix", "m"),
|
| 321 |
+
OrpheusVoice("Jonas", "m"),
|
| 322 |
+
OrpheusVoice("Noah", "m"),
|
| 323 |
+
OrpheusVoice("Maximilian", "m"),
|
| 324 |
+
# weiblich
|
| 325 |
+
OrpheusVoice("Sophie", "f"),
|
| 326 |
+
OrpheusVoice("Marie", "f"),
|
| 327 |
+
OrpheusVoice("Mia", "f"),
|
| 328 |
+
OrpheusVoice("Maria", "f"),
|
| 329 |
+
OrpheusVoice("Sophia", "f"),
|
| 330 |
+
OrpheusVoice("Lina", "f"),
|
| 331 |
+
OrpheusVoice("Lea", "f"),
|
| 332 |
+
]
|
| 333 |
+
|
| 334 |
+
# -----------------------------------------------------------
|
| 335 |
+
# Public API, damit das FastAPI-Backend sie abfragen kann
|
| 336 |
+
# -----------------------------------------------------------
|
| 337 |
+
def get_voices(self) -> list[OrpheusVoice]:
|
| 338 |
+
"""Return a list of available voices for the Kartoffel checkpoint."""
|
| 339 |
+
return self._SPEAKERS
|
| 340 |
+
|
| 341 |
+
# In set_voice() akzeptieren wir einfach den Namen:
|
| 342 |
+
def set_voice(self, voice_name: str) -> None:
|
| 343 |
+
if voice_name not in [v.name for v in self._SPEAKERS]:
|
| 344 |
+
raise ValueError(f"Unknown Orpheus speaker '{voice_name}'")
|
| 345 |
+
self.current_voice = voice_name
|
| 346 |
|
| 347 |
def set_voice_parameters(self, **kwargs):
|
| 348 |
"""
|