ysharma HF staff commited on
Commit
e71a91a
·
verified ·
1 Parent(s): ae9a123

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -11
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
- info="Weights shown below are the normalized values of the sliders",
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 + 0.4 * voice2"
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]) # Use value instead of label
284
- for i in range(len(slider_configs))
285
- if checkbox_values[i] and slider_values[i] > 0]
286
 
287
  if not active_pairs:
288
  return ""
289
 
290
- # Calculate sum for normalization
 
 
 
 
 
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: