From 3b01302cfbb47ed0f02c34f28aae99d7280f1c8c Mon Sep 17 00:00:00 2001 From: Kazeia Team Date: Thu, 9 Apr 2026 10:35:05 +0200 Subject: [PATCH] Fix missing eos/pad embeddings in native C++ pipeline MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The native pipeline was adding zeros after trailing text tokens instead of tts_eos_embed then tts_pad_embed. This caused the model to mispronounce final words (e.g. "développement" → "devopment"). Co-Authored-By: Claude Opus 4.6 (1M context) --- executorch-custom/tts_pipeline_jni.cpp | 13 +++++++++++-- .../src/main/java/com/kazeia/tts/Qwen3TtsEngine.kt | 1 + .../app/src/main/java/com/kazeia/tts/TtsPipeline.kt | 1 + 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/executorch-custom/tts_pipeline_jni.cpp b/executorch-custom/tts_pipeline_jni.cpp index 4c4f0c6..91d5970 100644 --- a/executorch-custom/tts_pipeline_jni.cpp +++ b/executorch-custom/tts_pipeline_jni.cpp @@ -222,6 +222,7 @@ Java_com_kazeia_tts_TtsPipeline_nativeRun( jfloatArray jTrailing,jint nTrailing, jfloatArray jCodecEmb, jfloatArray jCpEmbs, jfloatArray jCpHeads, jfloatArray jTCos,jfloatArray jTSin, jfloatArray jCCos,jfloatArray jCSin, + jfloatArray jEosEmbed, jfloatArray jPadEmbed, jint maxTokens) { if(!gState||!gState->loaded) return nullptr; @@ -257,6 +258,10 @@ Java_com_kazeia_tts_TtsPipeline_nativeRun( env->GetFloatArrayRegion(jCCos,0,ccSize,cCos.data()); env->GetFloatArrayRegion(jCSin,0,ccSize,cSin.data()); + std::vector eosEmbed(DIM,0), padEmbed(DIM,0); + if(jEosEmbed) env->GetFloatArrayRegion(jEosEmbed,0,DIM,eosEmbed.data()); + if(jPadEmbed) env->GetFloatArrayRegion(jPadEmbed,0,DIM,padEmbed.data()); + // Pipeline state int tkvElem=T_KV*T_KV_LEN*T_HD; std::vector tK(T_L*tkvElem,0), tV(T_L*tkvElem,0); @@ -317,13 +322,17 @@ Java_com_kazeia_tts_TtsPipeline_nativeRun( const float*ec=cpEmbs.data()+((long)cb*CB_SIZE+std::min(std::max(codes[cb+1],0),CB_SIZE-1))*DIM; for(int k=0;k