Spaces:
Running
Running
"placeholder" removed
Browse files
app.py
CHANGED
@@ -306,7 +306,7 @@ def handle_calculate_cost(dialogue_script: str, tts_model: str):
|
|
306 |
return "Cost: $0.000000 (No valid lines)"
|
307 |
cost = calculate_cost(total_chars, len(parsed_lines), tts_model)
|
308 |
return f"Estimated OpenAI Cost: ${cost:.6f} (for {total_chars} characters in {len(parsed_lines)} lines)"
|
309 |
-
except ValueError as e:
|
310 |
return f"Error: {str(e)}"
|
311 |
except Exception as e:
|
312 |
return f"Error calculating cost: {str(e)}"
|
@@ -363,11 +363,19 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
363 |
interactive=True
|
364 |
)
|
365 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
366 |
detailed_speaker_config_input = gr.Code(
|
367 |
label="Detailed Speaker Configuration (JSON)",
|
368 |
language="json",
|
369 |
lines=7,
|
370 |
-
|
371 |
visible=(DEFAULT_SPEAKER_CONFIG_METHOD == "Detailed Configuration (JSON)"),
|
372 |
info="Define voice, and optionally model-compatible speed/instructions per speaker."
|
373 |
)
|
|
|
306 |
return "Cost: $0.000000 (No valid lines)"
|
307 |
cost = calculate_cost(total_chars, len(parsed_lines), tts_model)
|
308 |
return f"Estimated OpenAI Cost: ${cost:.6f} (for {total_chars} characters in {len(parsed_lines)} lines)"
|
309 |
+
except ValueError as e: # Handles MAX_SCRIPT_LENGTH
|
310 |
return f"Error: {str(e)}"
|
311 |
except Exception as e:
|
312 |
return f"Error calculating cost: {str(e)}"
|
|
|
363 |
interactive=True
|
364 |
)
|
365 |
|
366 |
+
initial_json_config_example = """
|
367 |
+
[
|
368 |
+
{"speaker": "Alice", "voice": "nova", "speed": 1.1, "instructions": "sound excited"},
|
369 |
+
{"speaker": "Bob", "voice": "echo"},
|
370 |
+
{"speaker": "Narrator", "voice": "shimmer", "instructions": "be very serious"}
|
371 |
+
]
|
372 |
+
""".strip()
|
373 |
+
|
374 |
detailed_speaker_config_input = gr.Code(
|
375 |
label="Detailed Speaker Configuration (JSON)",
|
376 |
language="json",
|
377 |
lines=7,
|
378 |
+
value=initial_json_config_example, # Corrected: Use value for default content
|
379 |
visible=(DEFAULT_SPEAKER_CONFIG_METHOD == "Detailed Configuration (JSON)"),
|
380 |
info="Define voice, and optionally model-compatible speed/instructions per speaker."
|
381 |
)
|