Skip to content

Voice: end voiced audio cleanly; cut long summaries at a sentence - #92

Merged
DowLucas merged 1 commit into
mainfrom
fix/voice-audio-endings
Oct 8, 2026
Merged

DowLucas merged 1 commit into
mainfrom
fix/voice-audio-endings

Conversation

@DowLucas

@DowLucas DowLucas commented Oct 8, 2026

Copy link
Copy Markdown
Owner

Why

Reports of spoken summaries cutting off at the end. I fetched the same sentence from Chatterbox and Kokoro at 1.0 / 1.2 / 1.5× and measured: every clip already ends with 176–516 ms of silence, so the speech services are not truncating. But two things on our side can lose the ending:

  • Kokoro's WAV is a streamed file: RIFF and data sizes are 0xFFFFFFFF and a LIST chunk precedes the data (78-byte header). Kokoro is the fallback whenever the GPU is busy, which is often. Players have to guess where it ends; the plugin's duration estimate assumes 44 bytes.
  • Outputs that close the stream when the player exits (Bluetooth headphones, ~200–300 ms behind) drop whatever is still buffered.

Separately, toSpokenText cut an over-long summary at the word cap and appended "." mid-sentence, which sounds like an ending cut off too.

What changed

  • services/wav.ts finishWav: reads fmt and data (whatever chunks come between), trusts the bytes actually present over a streamed size, and writes a canonical 44-byte PCM WAV with correct sizes plus trailing silence. Anything that is not 16-bit PCM RIFF/WAVE passes through untouched.
  • voice-audio applies it: 400 ms by default (VOICE.padMs), or pad_ms (0–1000). The plugin sends 0 for mid-speech pieces (DowLucas/devscope-plugin, 0.33.0), so long speech gains no extra pauses. Older plugins get padding on every piece, which is harmless.
  • toSpokenText: over the word cap, it ends at the last full sentence if that keeps at least half; over the character cap, at a sentence or a whole word with "…", never mid-word.

Testing

  • New wav.test.ts: padding and sizes, a Kokoro-style streamed WAV with a LIST chunk, pad 0, a short body, non-PCM passthrough.
  • voice.test.ts: default padding, pad_ms: 0, out-of-range pad_ms rejected.
  • voiceSummary.test.ts: sentence-boundary cut, fallback word cut, character cut at a whole word.
  • Real files: Chatterbox and Kokoro output run through finishWav come out with exact 0.4 s of added silence and are read correctly by Python's strict wave module.

🤖 Generated with Claude Code

…ence

- voice-audio rewrites the speech service's WAV as a canonical PCM file with
  real sizes (Kokoro streams 0xFFFFFFFF sizes and a LIST chunk) and appends
  trailing silence (400 ms, or pad_ms), so outputs that close the stream early
  keep the last word.
- toSpokenText cuts an over-long summary at its last full sentence, and a
  character cut at a whole word, instead of mid-sentence.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 24 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 798801e4-e31a-4e12-ac44-56353f0dff44
📥 Commits

Reviewing files that changed from the base of the PR and between 9581c20 and d53c00f.

📒 Files selected for processing (8)
  • CHANGELOG.md
  • CLAUDE.md
  • packages/backend/src/routes/__tests__/voice.test.ts
  • packages/backend/src/routes/voice.ts
  • packages/backend/src/services/__tests__/voiceSummary.test.ts
  • packages/backend/src/services/__tests__/wav.test.ts
  • packages/backend/src/services/voiceSummary.ts
  • packages/backend/src/services/wav.ts
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@DowLucas
DowLucas merged commit cd3f7b2 into main Oct 8, 2026
6 checks passed
@DowLucas
DowLucas deleted the fix/voice-audio-endings branch October 8, 2026 12:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant