Skip to content

feat: use blingfire as default sentence tokenizer - #2709

Open
davidzhao wants to merge 4 commits into
mainfrom
dz/blingfire-tokenizer
Open

davidzhao wants to merge 4 commits into
mainfrom
dz/blingfire-tokenizer

Conversation

@davidzhao

Copy link
Copy Markdown
Member

matches Python, blingfire is much more accurate compared to our basic tokenizer implementation.

matches Python, blingfire is much more accurate compared to our
basic tokenizer implementation.
@davidzhao
davidzhao requested a review from a team as a code owner October 12, 2026 23:59
@changeset-bot

changeset-bot Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: a7e92a5

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 41 packages
Name Type
@livekit/agents Patch
@livekit/agents-plugin-cartesia Patch
@livekit/agents-plugin-elevenlabs Patch
@livekit/agents-plugin-fishaudio Patch
@livekit/agents-plugin-inworld Patch
@livekit/agents-plugin-minimax Patch
@livekit/agents-plugin-neuphonic Patch
@livekit/agents-plugin-resemble Patch
@livekit/agents-plugin-rime Patch
@livekit/agents-plugin-anam Patch
@livekit/agents-plugin-anthropic Patch
@livekit/agents-plugin-assemblyai Patch
@livekit/agents-plugin-azure Patch
@livekit/agents-plugin-baseten Patch
@livekit/agents-plugin-bey Patch
@livekit/agents-plugin-cerebras Patch
@livekit/agents-plugin-deepgram Patch
@livekit/agents-plugin-did Patch
@livekit/agents-plugin-google Patch
@livekit/agents-plugin-hume Patch
@livekit/agents-plugin-krisp Patch
@livekit/agents-plugin-lemonslice Patch
@livekit/agents-plugin-liveavatar Patch
@livekit/agents-plugin-livekit Patch
@livekit/agents-plugin-meta Patch
@livekit/agents-plugin-mistral Patch
@livekit/agents-plugin-mistralai Patch
@livekit/agents-plugin-openai Patch
@livekit/agents-plugin-perplexity Patch
@livekit/agents-plugin-phonic Patch
@livekit/agents-plugin-protoface Patch
@livekit/agents-plugin-runway Patch
@livekit/agents-plugin-sarvam Patch
@livekit/agents-plugin-silero Patch
@livekit/agents-plugin-soniox Patch
@livekit/agents-plugin-speechify Patch
@livekit/agents-plugin-synthesia Patch
@livekit/agents-plugin-tavus Patch
@livekit/agents-plugins-test Patch
@livekit/agents-plugin-trugen Patch
@livekit/agents-plugin-xai Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@devin-ai-integration devin-ai-integration Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note

Newer findings are available below. Devin Review posted a newer report on this PR, in addition to the findings presented here.

Devin Review found 2 potential issues.

1 flag not posted on this PR by your GitHub settings — view it in Devin Review. (Configure)

Devin Review

Comment thread agents/src/tokenize/blingfire.ts
const sentence = rawSentence.replace(/\s*\n+\s*/g, ' ').trim();
if (!sentence || sentence.length < minSentenceLength) continue;

sentences.push([retainFormat ? rawSentence : sentence, start, end]);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Batched speech duplicates sentence separators

With retainFormat and sentence batching, splitSentences retains leading whitespace in each token. BufferedTokenStream adds another space between tokens, changing the text sent to TTS.

Learn more

The splitter builds consecutive slices of the original input. A sentence after a boundary can therefore start with the source's separating space. In a streamed batch, BufferedTokenStream unconditionally inserts one more space before adding this slice to a nonempty output buffer. The same join occurs on flush. The default framework adapters now enable retainFormat, and expressive TTS batches later sentences.

Example: With minSentenceLength: 1, minTokenLength: 200, and retainFormat: true, streaming First sentence. Second sentence. Third sentence. into one batch adds spaces before Second and Third on top of the retained source spaces.

Recommended fix: In BufferedTokenStream, join slices without adding a separator when their tokenizer reports retained original spacing, or have the retained-format splitter return tokens with a consistent separation contract. Test both incremental emission and flush with batching enabled.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the current behavior and same as python as well. we accept

devin-ai-integration[bot]

This comment was marked as resolved.

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