Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -163,20 +163,21 @@ def convert_model_to_onnx():
|
|
163 |
dummy_input = tokenizer(dummy_prompt, return_tensors="pt").input_ids.to(device)
|
164 |
file_path = "orpheus_model.onnx"
|
165 |
try:
|
166 |
-
#
|
167 |
-
torch.
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
|
|
180 |
return f"Model converted to ONNX and saved as '{file_path}'."
|
181 |
except Exception as e:
|
182 |
return f"Error during ONNX conversion: {e}"
|
@@ -192,10 +193,10 @@ VOICES = ["tara", "dan", "josh", "emma"]
|
|
192 |
with gr.Blocks(title="Orpheus Text-to-Speech") as demo:
|
193 |
gr.Markdown("""
|
194 |
# 🎵 Orpheus Text-to-Speech
|
195 |
-
Enter text to
|
196 |
|
197 |
**Tips:**
|
198 |
-
-
|
199 |
- Longer text can produce more natural results.
|
200 |
""")
|
201 |
with gr.Row():
|
|
|
163 |
dummy_input = tokenizer(dummy_prompt, return_tensors="pt").input_ids.to(device)
|
164 |
file_path = "orpheus_model.onnx"
|
165 |
try:
|
166 |
+
# Disable Torch Dynamo during export to avoid FX-tracing issues.
|
167 |
+
with torch._dynamo.disable():
|
168 |
+
torch.onnx.export(
|
169 |
+
model,
|
170 |
+
dummy_input,
|
171 |
+
file_path,
|
172 |
+
export_params=True,
|
173 |
+
opset_version=14,
|
174 |
+
input_names=["input_ids"],
|
175 |
+
output_names=["logits"],
|
176 |
+
dynamic_axes={
|
177 |
+
"input_ids": {0: "batch_size", 1: "sequence_length"},
|
178 |
+
"logits": {0: "batch_size", 1: "sequence_length"}
|
179 |
+
},
|
180 |
+
)
|
181 |
return f"Model converted to ONNX and saved as '{file_path}'."
|
182 |
except Exception as e:
|
183 |
return f"Error during ONNX conversion: {e}"
|
|
|
193 |
with gr.Blocks(title="Orpheus Text-to-Speech") as demo:
|
194 |
gr.Markdown("""
|
195 |
# 🎵 Orpheus Text-to-Speech
|
196 |
+
Enter text to have it converted into natural-sounding speech.
|
197 |
|
198 |
**Tips:**
|
199 |
+
- Include paralinguistic cues like `<chuckle>` or `<sigh>`.
|
200 |
- Longer text can produce more natural results.
|
201 |
""")
|
202 |
with gr.Row():
|