Spaces:
Running
Make automatic Tone Center read as automatic in examples
Browse filesSwitch the Tone Center control and example data away from a misleading `0 Hz` placeholder so automatic session shaping reads correctly in the UI. This keeps the examples aligned with the actual behavior: blank means Rhythma chooses the tone center from the session profile.
Constraint: `0` is not a meaningful tone center value in this product
Confidence: high
Scope-risk: narrow
Reversibility: clean
Directive: Keep automatic controls visually distinct from real numeric overrides in future UI changes
Tested: python -m py_compile app.py tests/test_rhythma_ui_copy.py
Tested: PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 python -c "import pytest; raise SystemExit(pytest.main(['tests/test_rhythma_ui_copy.py','-q','-p','no:cacheprovider']))"
Not-tested: Live Gradio rendering in this environment because gradio is not installed locally
- app.py +18 -12
- tests/test_rhythma_ui_copy.py +6 -0
|
@@ -133,6 +133,17 @@ def normalize_rhythm_override(value):
|
|
| 133 |
return value
|
| 134 |
|
| 135 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 136 |
def build_runtime_session_profile(
|
| 137 |
analysis_result,
|
| 138 |
base_freq=None,
|
|
@@ -255,10 +266,13 @@ def create_interface():
|
|
| 255 |
)
|
| 256 |
|
| 257 |
with gr.Accordion("Session shaping controls", open=False):
|
| 258 |
-
override_freq = gr.
|
| 259 |
-
|
|
|
|
|
|
|
| 260 |
label="Tone Center (Hz)",
|
| 261 |
-
|
|
|
|
| 262 |
)
|
| 263 |
override_modulation = gr.Dropdown(
|
| 264 |
choices=["sine", "pulse", "chirp"],
|
|
@@ -313,15 +327,7 @@ def create_interface():
|
|
| 313 |
)
|
| 314 |
|
| 315 |
gr.Examples(
|
| 316 |
-
examples=
|
| 317 |
-
["I need something steady before a difficult conversation.", None, 0, "sine", "Automatic", 12],
|
| 318 |
-
["I want to feel grounded and open as the evening slows down.", None, 0, "sine", "Automatic", 18],
|
| 319 |
-
["I need a clear horizon for deep work.", None, 0, "sine", "focused", 20],
|
| 320 |
-
["Everything feels loud and I want a softer landing.", None, 0, "sine", "Automatic", 14],
|
| 321 |
-
["I feel bright and want a livelier pulse without losing calm.", None, 0, "pulse", "active", 10],
|
| 322 |
-
["Give me a long unwind after a heavy day.", None, 0, "sine", "relaxed", 30],
|
| 323 |
-
["I want a gentle session for a low-energy morning.", None, 0, "sine", "Automatic", 16],
|
| 324 |
-
],
|
| 325 |
inputs=[input_text, audio_input, override_freq, override_modulation, override_rhythm, duration],
|
| 326 |
outputs=[
|
| 327 |
session_name_output, emotional_tone_output, listening_path_output,
|
|
|
|
| 133 |
return value
|
| 134 |
|
| 135 |
|
| 136 |
+
SESSION_EXAMPLES = [
|
| 137 |
+
["I need something steady before a difficult conversation.", None, None, "sine", "Automatic", 12],
|
| 138 |
+
["I want to feel grounded and open as the evening slows down.", None, None, "sine", "Automatic", 18],
|
| 139 |
+
["I need a clear horizon for deep work.", None, None, "sine", "focused", 20],
|
| 140 |
+
["Everything feels loud and I want a softer landing.", None, None, "sine", "Automatic", 14],
|
| 141 |
+
["I feel bright and want a livelier pulse without losing calm.", None, None, "pulse", "active", 10],
|
| 142 |
+
["Give me a long unwind after a heavy day.", None, None, "sine", "relaxed", 30],
|
| 143 |
+
["I want a gentle session for a low-energy morning.", None, None, "sine", "Automatic", 16],
|
| 144 |
+
]
|
| 145 |
+
|
| 146 |
+
|
| 147 |
def build_runtime_session_profile(
|
| 148 |
analysis_result,
|
| 149 |
base_freq=None,
|
|
|
|
| 266 |
)
|
| 267 |
|
| 268 |
with gr.Accordion("Session shaping controls", open=False):
|
| 269 |
+
override_freq = gr.Number(
|
| 270 |
+
value=None,
|
| 271 |
+
minimum=0,
|
| 272 |
+
precision=0,
|
| 273 |
label="Tone Center (Hz)",
|
| 274 |
+
placeholder="Automatic",
|
| 275 |
+
info="Leave blank to let Rhythma choose a tone center from your session profile."
|
| 276 |
)
|
| 277 |
override_modulation = gr.Dropdown(
|
| 278 |
choices=["sine", "pulse", "chirp"],
|
|
|
|
| 327 |
)
|
| 328 |
|
| 329 |
gr.Examples(
|
| 330 |
+
examples=SESSION_EXAMPLES,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 331 |
inputs=[input_text, audio_input, override_freq, override_modulation, override_rhythm, duration],
|
| 332 |
outputs=[
|
| 333 |
session_name_output, emotional_tone_output, listening_path_output,
|
|
@@ -32,6 +32,12 @@ def test_normalize_rhythm_override_treats_automatic_as_none():
|
|
| 32 |
assert app.normalize_rhythm_override("Automatic") is None
|
| 33 |
|
| 34 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
def test_build_session_copy_uses_human_labels():
|
| 36 |
app = import_app_with_gradio_stub()
|
| 37 |
analysis = {
|
|
|
|
| 32 |
assert app.normalize_rhythm_override("Automatic") is None
|
| 33 |
|
| 34 |
|
| 35 |
+
def test_session_examples_leave_tone_center_blank_for_automatic_mode():
|
| 36 |
+
app = import_app_with_gradio_stub()
|
| 37 |
+
|
| 38 |
+
assert all(example[2] is None for example in app.SESSION_EXAMPLES)
|
| 39 |
+
|
| 40 |
+
|
| 41 |
def test_build_session_copy_uses_human_labels():
|
| 42 |
app = import_app_with_gradio_stub()
|
| 43 |
analysis = {
|