Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion crates/buzz-voice/src/pocket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,23 @@ pub fn load_text_to_speech(model_dir: &str) -> Result<PocketTts, String> {
impl PocketTts {
/// Split text into synthesis units that satisfy the bundle's exact
/// 50-token input limit.
///
/// The first sentence remains its own unit when it fits. Oversized
/// sentences fall back to clause, word, and UTF-8 scalar boundaries, while
/// later sentences pack into the largest natural unit that fits.
///
/// Chunks are contiguous substrings of the prepared model prompt and may
/// retain boundary whitespace. Concatenating them with `chunks.concat()`
/// reconstructs that prompt exactly, and each chunk's prepared token count
/// is at most 50.
pub fn split_text_into_chunks(&self, text: &str) -> Result<Vec<String>, String> {
let Some(prepared) = prepare_april_prompt(text) else {
return Ok(Vec::new());
};
self.inner
.lock()
.map_err(|_| "Pocket TTS engine lock poisoned".to_string())?
.split_prompt(&prepared)
.split_playback_prompt(&prepared)
}

/// Synthesize text with the supplied reference voice.
Expand Down
Loading
Loading