Skip to content

the ultimate vocal synthesizer - sing, speak, beatbox, and more

Rust

Speak: the examples are a menu in the action bar (on a phone they showed 1.5 of 4 over an empty screen)

Jameson Hodge3dc1eb786cc2
diff --git a/docs/ui-redesign.md b/docs/ui-redesign.md
index 8cabff3..66424c5 100644
--- a/docs/ui-redesign.md
+++ b/docs/ui-redesign.md
@@ -51,7 +51,7 @@ A hook, `usePhosphor(draw)`, replaces `useCanvasLoop` for the vector screens: DP
| Mode | Left | Right column |
|---|---|---|
| Play | face (`AnatomyView`) | Breathe + Whisper; tube, vocal folds, spectrum, vowels, voice encoders, keys |
-| Speak | face | Speak + rate + IPA; say (text field, transcription, examples), gestural score, consonant chart, tube, vocal folds |
+| Speak | face | Speak + examples menu + rate + IPA; say (text field, transcription), gestural score, consonant chart, tube, vocal folds |
| Sing | face | Sing + song menu; pitch roll, lyrics chips, spectrum with the ring zone, song encoders, keys |
| Beatbox | face with the hit's big symbol | Play beat + pattern menu + Mic FX; step sequencer, waterfall spectrogram, pads, tempo encoders + the beat as text, bass keys |
| Bestiary | creature (`CreatureView`, its description under its name) | the calls + Breathe; creature gallery, waterfall spectrogram and unrolled airway, creature encoders, compact keys |
diff --git a/src/ui/components/SpeakPanel.tsx b/src/ui/components/SpeakPanel.tsx
index a49fbeb..0d718af 100644
--- a/src/ui/components/SpeakPanel.tsx
+++ b/src/ui/components/SpeakPanel.tsx
@@ -3,7 +3,7 @@ import { useStore } from "../store.ts";
import { speakText, speakPhrases, stopSpeaking, onPlan, currentPlan, spokenWordNow, speakingNow } from "../speech.ts";
import { mouthWords } from "../mouthWords.ts";
import { tokenizeIpa } from "../../wasm/engine.ts";
-import { Slider } from "./Controls.tsx";
+import { Menu, Slider } from "./Controls.tsx";
import { Chip, Screen } from "./Screen.tsx";
import { ActionBar, PrimaryButton } from "./ActionBar.tsx";
import { ScoreView, planNow } from "./ScoreView.tsx";
@@ -165,6 +165,16 @@ export function SpeakRight() {
<div className="right right-speak">
<ActionBar label="Speak" onSpace={press}>
<PrimaryButton label="Speak" playing={speaking} busy={busy ? "Preparing…" : null} onClick={press} />
+ {/* puts an example in the box: the menu always reads Examples, since the box shows the words */}
+ <Menu
+ label="Examples"
+ value=""
+ options={[{ value: "", label: "Examples", disabled: true }, ...EXAMPLES.map((ex) => ({ value: ex, label: ex }))]}
+ onChange={(ex) => {
+ setText(ex);
+ setIpa(false);
+ }}
+ />
<div className="act-slider">
<Slider label="Rate" value={rate} min={0.5} max={1.8} onChange={setRate} format={(v) => `${v.toFixed(2)}×`} />
</div>
@@ -193,20 +203,6 @@ export function SpeakRight() {
{trans ? `/${trans}/` : ""}
</p>
</div>
- <div className="examples" role="group" aria-label="Examples">
- {EXAMPLES.map((ex) => (
- <Chip
- key={ex}
- toggle={false}
- onClick={() => {
- setText(ex);
- setIpa(false);
- }}
- >
- {ex}
- </Chip>
- ))}
- </div>
</div>
</Screen>
<Screen className="s-score" title="Gestural score">
diff --git a/src/ui/styles.css b/src/ui/styles.css
index bd6f89b..c5c73f7 100644
--- a/src/ui/styles.css
+++ b/src/ui/styles.css
@@ -376,12 +376,6 @@ input[type="range"]::-moz-range-thumb {
gap: 10px;
}
-.examples {
- display: flex;
- flex-wrap: wrap;
- gap: 6px;
-}
-
.chip {
border: 1px solid var(--line);
background: transparent;
@@ -1326,8 +1320,10 @@ button.primary.large {
box-shadow: 0 0 10px rgba(255, 179, 64, 0.35);
}
+/* shrinks before the bar wraps (to 120 px), grows to 200 px when there's room */
.act-slider {
- width: 200px;
+ flex: 1 1 120px;
+ max-width: 200px;
}
.act-error {
@@ -1855,6 +1851,16 @@ input[type="range"]::-moz-range-thumb {
.s-say { grid-area: say; }
+/* the text and its transcription: no floor, or the screen is mostly empty */
+.right-speak .s-say .screen-body {
+ min-height: 0;
+}
+
+/* a select is as wide as its longest option (here a whole sentence); this one always reads Examples */
+.right-speak .act-row .menu select {
+ width: 9.5em;
+}
+
/* the tube and folds' floor sets how tall the score is in a short window (rows of canvases share
by fr from their floors): lower, so the speak button above them fits a 1280 x 800 window */
.right-speak .s-tube .screen-body,
@@ -1867,7 +1873,7 @@ input[type="range"]::-moz-range-thumb {
.say {
padding: 6px 14px 10px;
display: grid;
- grid-template-rows: auto auto minmax(0, 1fr);
+ grid-template-rows: auto auto;
gap: 8px;
overflow: hidden;
}
@@ -1908,28 +1914,6 @@ input[type="range"]::-moz-range-thumb {
white-space: nowrap;
}
-.say .examples {
- display: flex;
- flex-wrap: nowrap;
- gap: 4px;
- align-items: flex-start;
- overflow-x: auto;
- scrollbar-width: none;
-}
-
-.say .examples .chip {
- flex: none;
-}
-
-.say .examples::-webkit-scrollbar {
- display: none;
-}
-
-.say .examples .chip {
- font-size: 9px;
- padding: 2px 7px;
-}
-
.vowel-pick {
display: flex;
gap: 4px;
@@ -2038,9 +2022,6 @@ input[type="range"]::-moz-range-thumb {
.right-speak .screen-body {
min-height: 200px;
}
- .s-say .screen-body {
- min-height: 170px;
- }
}
@media (max-width: 640px) {
@@ -2048,9 +2029,6 @@ input[type="range"]::-moz-range-thumb {
grid-template-columns: minmax(0, 1fr);
grid-template-areas: "act" "say" "score" "chart" "tube" "folds";
}
- .s-say .screen-body {
- min-height: 230px;
- }
.say-row {
flex-wrap: wrap;
}
diff --git a/tools/e2e.ts b/tools/e2e.ts
index a2cbbec..50b0f82 100644
--- a/tools/e2e.ts
+++ b/tools/e2e.ts
@@ -103,6 +103,13 @@ async function run(viewport: { width: number; height: number }, tag: string) {
}
logs.push(`[${tag}] speech rms then silence ${speechRms.map((r) => r.toFixed(4)).join(",")}`);
if (!(Math.max(...speechRms.slice(-3)) < 1e-3)) errors.push(`[${tag}] voice still sounding after the phrase: ${speechRms.slice(-3).join(",")}`);
+ // the Examples menu puts a phrase in the box, then reads Examples again
+ const examples = page.getByRole("combobox", { name: "Examples" });
+ await examples.selectOption({ label: "She sells sea shells by the sea shore." });
+ const typed = await page.getByRole("textbox", { name: "Text to speak" }).inputValue();
+ const menuNow = await examples.inputValue();
+ logs.push(`[${tag}] example picked: box "${typed}", menu "${menuNow}"`);
+ if (!typed.startsWith("She sells") || menuNow !== "") errors.push(`[${tag}] the Examples menu didn't fill the box and reset (box "${typed}", menu "${menuNow}")`);
await page.locator("button.ipa", { hasText: "ʃ" }).first().click();
await page.waitForTimeout(700);
await page.screenshot({ path: `${outDir}/${tag}-4-pad.png` });
@@ -314,6 +321,6 @@ await run({ width: 1440, height: 980 }, "desktop");
await run({ width: 390, height: 844 }, "mobile");
await browser.close();
console.log("console errors:", errors.length ? "\n" + errors.join("\n") : "none");
-console.log(logs.filter((l) => /load|rate|warn|transcription|creature|held|back to|beatbox|silence|sing|octave|retry/i.test(l)).slice(0, 52).join("\n"));
+console.log(logs.filter((l) => /load|rate|warn|transcription|example|creature|held|back to|beatbox|silence|sing|octave|retry/i.test(l)).slice(0, 52).join("\n"));
// a run that collected errors fails, so CI and agents can't read it as a pass
if (errors.length) process.exit(1);