dankvoice: humanize answers via the @tiny role and narrate thinking
Answers spoken with /say were verbatim markdown-cleaned text while the built-in vocalizer speaks prose rewritten by a small model. Port that enhancer (bundle Qyr/T6o: same prompt, 1536 tokens, 6 s, 4000-char window, null-fallback/empty-skip contract) and resolve its model from modelRoles.tiny exactly as the harness does, so auto-speak sounds like the enhanced TUI voice instead of a pager. agent_end now also speaks the last assistant message's thinking blocks as their own unit before the answer; narration-flagged thinking counts as answer text. Both knobs are menu-toggleable, persisted, and env-overridable; the fixture gains a chat route (echo/prose) and seven scenarios cover the round-trip, the 404 fallback, ordering, the kill switches and role resolution (22 green, 58 suite-wide; live smoke through real frank-zealot + frank-tts). Refs #27
This commit is contained in:
+67
-2
@@ -68,6 +68,13 @@ providers:
|
||||
api: openai-speech
|
||||
YML
|
||||
|
||||
# omp config.yml fixture: the @tiny role points at the chat provider above
|
||||
export DV_OMPCONFIG="$WORK/ompconfig.yml"
|
||||
cat > "$DV_OMPCONFIG" <<'CFY'
|
||||
modelRoles:
|
||||
tiny: chat (box)/chatmodel:off
|
||||
CFY
|
||||
|
||||
cat > "$WORK/driver.ts" <<'TS'
|
||||
// Black-box driver: stand up the frank-tts fixture, load the extension against
|
||||
// it, invoke one scenario, print what the endpoint received and what got played.
|
||||
@@ -95,6 +102,14 @@ const server = createServer((req, res) => {
|
||||
res.end(AUDIO);
|
||||
return;
|
||||
}
|
||||
if (process.env.DV_REWRITE && req.url?.endsWith("/chat/completions")) {
|
||||
res.setHeader("content-type", "application/json");
|
||||
const spoken = process.env.DV_REWRITE === "echo"
|
||||
? String(JSON.parse(body).messages?.[1]?.content ?? "")
|
||||
: "Spoken, humanized words.";
|
||||
res.end(JSON.stringify({ choices: [{ message: { content: spoken } }] }));
|
||||
return;
|
||||
}
|
||||
res.statusCode = 404;
|
||||
res.end("{}");
|
||||
});
|
||||
@@ -107,6 +122,8 @@ if (scenario === "endpoint") {
|
||||
} else {
|
||||
process.env.DANKVOICE_URL = `http://127.0.0.1:${port}/v1`;
|
||||
}
|
||||
process.env.DANKVOICE_OMPCONFIG = process.env.DV_OMPCONFIG;
|
||||
if (scenario !== "endpoint") process.env.DANKVOICE_REWRITE_URL = `http://127.0.0.1:${port}/v1`;
|
||||
if (scenario === "noplayer") process.env.PATH = process.env.DV_EMPTY_BIN ?? "/nonexistent-bin";
|
||||
else process.env.PATH = `${dirname(process.env.DV_STUB ?? ".")}/bin:${process.env.PATH ?? ""}`;
|
||||
process.env.DANKVOICE_PLAYER = scenario === "noplayer" ? "" : process.env.DV_PLAYER_BIN ?? process.env.DV_STUB;
|
||||
@@ -195,6 +212,17 @@ if (!say) {
|
||||
case "decimals":
|
||||
await say.handler("Model 3.5 ships today. Version 1,5 too.", ctx);
|
||||
break;
|
||||
case "rewrite":
|
||||
await say.handler("The deploy failed because a secret was missing.", ctx);
|
||||
break;
|
||||
case "thinking":
|
||||
await say.handler("on", ctx);
|
||||
await agentEnd?.({ messages: [{ role: "assistant", content: [{ type: "thinking", thinking: "Considering the wiring." }, { type: "text", text: "The answer is nine." }] }] }, ctx);
|
||||
break;
|
||||
case "narration":
|
||||
await say.handler("on", ctx);
|
||||
await agentEnd?.({ messages: [{ role: "assistant", content: [{ type: "thinking", thinking: "Here is the result.", narration: true }] }] }, ctx);
|
||||
break;
|
||||
case "noplayer":
|
||||
await say.handler("speak anyway", ctx);
|
||||
break;
|
||||
@@ -213,7 +241,7 @@ for (const call of received) {
|
||||
};
|
||||
console.log(`CALL ${call.url} model=${field("model")} format=${field("response_format")} voice=${field("voice")} input=${field("input")}`);
|
||||
}
|
||||
console.log(`CALLS ${received.length}`);
|
||||
console.log(`CALLS ${received.filter((call) => call.url?.endsWith("/audio/speech")).length}`);
|
||||
const log = process.env.DV_STUB_LOG && existsSync(process.env.DV_STUB_LOG) ? readFileSync(process.env.DV_STUB_LOG, "utf8").trim() : "";
|
||||
console.log(`PLAYS ${log === "" ? 0 : log.split("\n").length}`);
|
||||
if (log !== "") for (const line of log.split("\n")) console.log(`PLAYER ${line}`);
|
||||
@@ -281,6 +309,7 @@ say_run() {
|
||||
@test "the endpoint is taken from the speech row of the models file, never the chat provider" {
|
||||
say_run endpoint
|
||||
[[ "$output" == *"http://127.0.0.1:1/v1/audio/speech"* ]]
|
||||
[[ "$output" == *"humanize chatmodel"* ]]
|
||||
[[ "$output" != *"10.0.0.1"* ]]
|
||||
}
|
||||
|
||||
@@ -316,6 +345,42 @@ say_run() {
|
||||
[[ "$output" == *"input=Version 1,5 too."* ]]
|
||||
}
|
||||
|
||||
@test "an answer is rewritten into spoken prose before synthesis" {
|
||||
DV_REWRITE=prose say_run rewrite
|
||||
[[ "$output" == *"CALL /v1/chat/completions"* ]]
|
||||
[[ "$output" == *"input=Spoken, humanized words."* ]]
|
||||
[[ "$output" == *"CALLS 1"* ]]
|
||||
}
|
||||
|
||||
@test "a failed rewrite speaks the mechanical text unchanged" {
|
||||
say_run speak
|
||||
[[ "$output" == *"input=hello world"* ]]
|
||||
}
|
||||
|
||||
@test "thinking is narrated before the answer as its own segment" {
|
||||
DV_REWRITE=echo say_run thinking
|
||||
[[ "$output" == *"input=Considering the wiring."* ]]
|
||||
[[ "$output" == *"input=The answer is nine."* ]]
|
||||
[[ "$output" == *"CALLS 2"* ]]
|
||||
local first second
|
||||
first=$(grep -n "input=Considering the wiring\." <<<"$output" | head -1 | cut -d: -f1)
|
||||
second=$(grep -n "input=The answer is nine\." <<<"$output" | head -1 | cut -d: -f1)
|
||||
[ -n "$first" ] && [ -n "$second" ] && [ "$first" -lt "$second" ]
|
||||
}
|
||||
|
||||
@test "thinking narration can be switched off" {
|
||||
DANKVOICE_THINKING=0 DV_REWRITE=echo say_run thinking
|
||||
[[ "$output" == *"input=The answer is nine."* ]]
|
||||
[[ "$output" != *"input=Considering the wiring."* ]]
|
||||
[[ "$output" == *"CALLS 1"* ]]
|
||||
}
|
||||
|
||||
@test "narration-flagged thinking is spoken once as the answer" {
|
||||
DV_REWRITE=echo say_run narration
|
||||
[[ "$output" == *"input=Here is the result."* ]]
|
||||
[[ "$output" == *"CALLS 1"* ]]
|
||||
}
|
||||
|
||||
@test "a missing player is reported, not swallowed" {
|
||||
say_run noplayer
|
||||
[[ "$output" == *"NOTIFY error dankvoice: no audio player found"* ]]
|
||||
@@ -331,7 +396,7 @@ say_run() {
|
||||
|
||||
@test "the menu lists every knob and a plain /say opens it" {
|
||||
say_run menu
|
||||
[[ "$output" == *"SELECT dankvoice — options Auto-speak: off (toggle)|Voice: server default (change)|Output device: system default (change)|Player: $DV_STUB (change)|Spoken cap: 700 chars (change)|Speak a test phrase"* ]]
|
||||
[[ "$output" == *"SELECT dankvoice — options Auto-speak: off (toggle)|Voice: server default (change)|Output device: system default (change)|Player: $DV_STUB (change)|Spoken cap: 700 chars (change)|Thinking narration: on (toggle)|Humanize answers: on (tiny) (toggle)|Speak a test phrase"* ]]
|
||||
[[ "$output" == *"NOTIFY info dankvoice: auto-speak armed (server default @ http://127.0.0.1:"* ]]
|
||||
say_run empty
|
||||
[[ "$output" == *"SELECT dankvoice — options"* ]]
|
||||
|
||||
Reference in New Issue
Block a user