Skip to content

Commit 8c54094

Browse files
authored
fix: Ensure the SNAC code is within codebook bounds (#93)
1 parent 3820919 commit 8c54094

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

models/orpheus.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,13 @@ namespace chatllm::orpheus::tts
519519
{
520520
id = id - 10 - ((vocoder_ids.size() % 7) * 4096);
521521
if (id < 0) return;
522+
523+
// Ensure the SNAC code is within codebook bounds
524+
if (id >= codec_config.codebook_size) {
525+
ggml::log(GGML_LOG_LEVEL_WARN, "SNAC code %d exceeds codebook_size %d, clamping with modulo\n",
526+
id, codec_config.codebook_size);
527+
id = id % codec_config.codebook_size;
528+
}
522529

523530
pcm_samples.clear();
524531

0 commit comments

Comments
 (0)