Athspi commited on
Commit
d4def9e
·
verified ·
1 Parent(s): 7a742e9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -16
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
- # Export the model to ONNX format
167
- torch.onnx.export(
168
- model,
169
- dummy_input,
170
- file_path,
171
- export_params=True,
172
- opset_version=14,
173
- input_names=["input_ids"],
174
- output_names=["logits"],
175
- dynamic_axes={
176
- "input_ids": {0: "batch_size", 1: "sequence_length"},
177
- "logits": {0: "batch_size", 1: "sequence_length"}
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 hear it converted to natural-sounding speech.
196
 
197
  **Tips:**
198
- - Use paralinguistic cues like `<chuckle>` or `<sigh>`.
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():