Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -255,8 +255,7 @@ with gr.Blocks(css=custom_css, theme="ocean") as demo:
|
|
| 255 |
lines=2,
|
| 256 |
scale=4,
|
| 257 |
interactive=False,
|
| 258 |
-
|
| 259 |
-
placeholder="This will begin to display immediately once any of the voice checkboxes is selected"
|
| 260 |
)
|
| 261 |
input_text = gr.Textbox(
|
| 262 |
label="Input Text",
|
|
@@ -273,30 +272,31 @@ with gr.Blocks(css=custom_css, theme="ocean") as demo:
|
|
| 273 |
def generate_voice_formula(*values):
|
| 274 |
"""
|
| 275 |
Generate a formatted string showing the normalized voice combination.
|
| 276 |
-
Returns: String like "0.6 * voice1
|
| 277 |
"""
|
| 278 |
n = len(values) // 2
|
| 279 |
checkbox_values = values[:n]
|
| 280 |
slider_values = list(values[n:])
|
| 281 |
|
| 282 |
# Get active sliders and their names
|
| 283 |
-
active_pairs = [(slider_values[i], slider_configs[i][0])
|
| 284 |
-
|
| 285 |
-
|
| 286 |
|
| 287 |
if not active_pairs:
|
| 288 |
return ""
|
| 289 |
|
| 290 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 291 |
total_sum = sum(value for value, _ in active_pairs)
|
| 292 |
|
| 293 |
if total_sum == 0:
|
| 294 |
return ""
|
| 295 |
|
| 296 |
-
# For single voice, always use weight 1.0
|
| 297 |
-
if len(active_pairs) == 1:
|
| 298 |
-
return f"1.000 * {active_pairs[0][1]}"
|
| 299 |
-
|
| 300 |
# Generate normalized formula for multiple voices
|
| 301 |
terms = []
|
| 302 |
for value, name in active_pairs:
|
|
|
|
| 255 |
lines=2,
|
| 256 |
scale=4,
|
| 257 |
interactive=False,
|
| 258 |
+
placeholder="This will begin to display immediately once any of the voice checkboxes is selected selected"
|
|
|
|
| 259 |
)
|
| 260 |
input_text = gr.Textbox(
|
| 261 |
label="Input Text",
|
|
|
|
| 272 |
def generate_voice_formula(*values):
|
| 273 |
"""
|
| 274 |
Generate a formatted string showing the normalized voice combination.
|
| 275 |
+
Returns: String like "0.6 * voice1" or "0.4 * voice1 + 0.6 * voice2"
|
| 276 |
"""
|
| 277 |
n = len(values) // 2
|
| 278 |
checkbox_values = values[:n]
|
| 279 |
slider_values = list(values[n:])
|
| 280 |
|
| 281 |
# Get active sliders and their names
|
| 282 |
+
active_pairs = [(slider_values[i], slider_configs[i][0])
|
| 283 |
+
for i in range(len(slider_configs))
|
| 284 |
+
if checkbox_values[i]]
|
| 285 |
|
| 286 |
if not active_pairs:
|
| 287 |
return ""
|
| 288 |
|
| 289 |
+
# If only one voice is selected, use its actual value
|
| 290 |
+
if len(active_pairs) == 1:
|
| 291 |
+
value, name = active_pairs[0]
|
| 292 |
+
return f"{value:.3f} * {name}"
|
| 293 |
+
|
| 294 |
+
# Calculate sum for normalization of multiple voices
|
| 295 |
total_sum = sum(value for value, _ in active_pairs)
|
| 296 |
|
| 297 |
if total_sum == 0:
|
| 298 |
return ""
|
| 299 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 300 |
# Generate normalized formula for multiple voices
|
| 301 |
terms = []
|
| 302 |
for value, name in active_pairs:
|