Update orpheus-tts/engine_class.py
Browse files- orpheus-tts/engine_class.py +14 -3
orpheus-tts/engine_class.py
CHANGED
@@ -86,7 +86,7 @@ class OrpheusModel:
|
|
86 |
if voice not in self.engine.available_voices:
|
87 |
raise ValueError(f"Voice {voice} is not available for model {self.model_name}")
|
88 |
|
89 |
-
def _format_prompt(self, prompt, voice="
|
90 |
# Use Kartoffel model format based on documentation
|
91 |
if voice:
|
92 |
full_prompt = f"{voice}: {prompt}"
|
@@ -121,12 +121,12 @@ class OrpheusModel:
|
|
121 |
token_count = 0
|
122 |
|
123 |
async def async_producer():
|
|
|
124 |
async for result in self.engine.generate(prompt=prompt_string, sampling_params=sampling_params, request_id=request_id):
|
125 |
# Place each token text into the queue.
|
126 |
token_text = result.outputs[0].text
|
127 |
print(f"DEBUG: Generated token {token_count}: {repr(token_text)}")
|
128 |
token_queue.put(token_text)
|
129 |
-
nonlocal token_count
|
130 |
token_count += 1
|
131 |
print(f"DEBUG: Generation completed. Total tokens: {token_count}")
|
132 |
token_queue.put(None) # Sentinel to indicate completion.
|
@@ -146,6 +146,17 @@ class OrpheusModel:
|
|
146 |
thread.join()
|
147 |
|
148 |
def generate_speech(self, **kwargs):
|
149 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
150 |
|
151 |
|
|
|
86 |
if voice not in self.engine.available_voices:
|
87 |
raise ValueError(f"Voice {voice} is not available for model {self.model_name}")
|
88 |
|
89 |
+
def _format_prompt(self, prompt, voice="Sophie", model_type="larger"):
|
90 |
# Use Kartoffel model format based on documentation
|
91 |
if voice:
|
92 |
full_prompt = f"{voice}: {prompt}"
|
|
|
121 |
token_count = 0
|
122 |
|
123 |
async def async_producer():
|
124 |
+
nonlocal token_count
|
125 |
async for result in self.engine.generate(prompt=prompt_string, sampling_params=sampling_params, request_id=request_id):
|
126 |
# Place each token text into the queue.
|
127 |
token_text = result.outputs[0].text
|
128 |
print(f"DEBUG: Generated token {token_count}: {repr(token_text)}")
|
129 |
token_queue.put(token_text)
|
|
|
130 |
token_count += 1
|
131 |
print(f"DEBUG: Generation completed. Total tokens: {token_count}")
|
132 |
token_queue.put(None) # Sentinel to indicate completion.
|
|
|
146 |
thread.join()
|
147 |
|
148 |
def generate_speech(self, **kwargs):
|
149 |
+
print("DEBUG: Starting generate_speech")
|
150 |
+
try:
|
151 |
+
token_generator = self.generate_tokens_sync(**kwargs)
|
152 |
+
print("DEBUG: Token generator created successfully")
|
153 |
+
|
154 |
+
audio_generator = tokens_decoder_sync(token_generator)
|
155 |
+
print("DEBUG: Audio decoder called successfully")
|
156 |
+
|
157 |
+
return audio_generator
|
158 |
+
except Exception as e:
|
159 |
+
print(f"DEBUG: Error in generate_speech: {e}")
|
160 |
+
raise e
|
161 |
|
162 |
|