Skip to content

Commit ff1d179

Browse files
committed
kokoro fixes for every better pausing
1 parent 7b04191 commit ff1d179

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

otherarch/ttscpp/src/kokoro_model.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "kokoro_model.h"
2+
#include <regex>
23

34
static struct ggml_tensor * build_albert_attn_mask(ggml_context * ctx, struct kokoro_duration_context *kctx, const kokoro_ubatch & batch) {
45
kctx->attn_mask = ggml_new_tensor_2d(ctx, GGML_TYPE_F32, (int64_t) batch.n_tokens, (int64_t) batch.n_tokens);
@@ -1423,8 +1424,9 @@ int kokoro_runner::generate(std::string prompt, struct tts_response * response,
14231424
// replace all non-sentence terminating characters with '--' which espeak will treat as a pause.
14241425
// We preserve the other punctuation for cleaner chunking pre-tokenization
14251426
prompt = replace_any(prompt, ";:", "--");
1426-
prompt = replace_any(prompt, "\n", ". ");
1427+
prompt = replace_any(prompt, "\n", "--");
14271428
kokoro_str_replace_all(prompt,"","'");
1429+
prompt = std::regex_replace(prompt, std::regex("(\\w)([.!?]) "), "$1$2, ");
14281430
kokoro_str_replace_all(prompt," - "," -- ");
14291431
kokoro_str_replace_all(prompt,"he's ","he is ");
14301432
kokoro_str_replace_all(prompt,"'s ","s ");

0 commit comments

Comments
 (0)