KokoroSharp icon indicating copy to clipboard operation
KokoroSharp copied to clipboard

Using Markdown in speech text

Open brucek5 opened this issue 8 months ago • 1 comments

I'm trying to understand the use and syntax of the speech Markdown.

In the source code, there is a comment block that states:

/* Customize pronunciation with Markdown link syntax and / slashes / like[Kokoro](/ kˈOkəɹO /) To adjust intonation, try punctuation;:,.!?—…"()“” or stress ˈ and ˌ Lower stress1 level or2 levels Raise stress 1 levelor 2 levels(only works on less stressed, usually short words) */

First Item: When I used the example is the speech text being "[Kokoro](/ kˈOkəɹO /)" , it all ways sounds the same no matter what's in between the slashes. Is there a standard language for this text?

Second Item: What is "stress" and what is the syntax of using it?

brucek5 avatar Mar 04 '26 19:03 brucek5

The in-place pronounciation feature was replaced in favour of a simpler global pronounciation dictionary for now.

You can now add your custom pronounciation of words or phrases, which would be the main purpose of this:

KokoroSharp.Processing.Tokenizer.AddWords([
    ("GIF", "ʤˈɪf"),
    ("KokoroSharp", "kOkˈOɹO ʃˈɑɹp")
]);

or skip the phonemizer if you have your own custom solution:

int[] tokens = Tokenizer.TokenizePhonemes(customPhonemes);
tts.Speak_Phonemes(originalText, tokens, voice); // text is optional in case you make use of the callbacks

For your example test -- Kokoro & KokoroSharp are the two words that are already hardcoded haha. As for the stress, it's simply token characters that can be used next to phonemes to emphasize them.

Lyrcaxis avatar Aug 26 '26 19:08 Lyrcaxis