Skip to content
Open
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: 9 additions & 2 deletions kokoro.js/src/phonemize.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ const PUNCTUATION_PATTERN = new RegExp(`(\\s*[${escapeRegExp(PUNCTUATION)}]+\\s*
/**
* Phonemize text using the eSpeak-NG phonemizer
* @param {string} text The text to phonemize
* @param {"a"|"b"} language The language to use
* @param {"a"|"b"|"d"} language The language to use
* @param {boolean} norm Whether to normalize the text
* @returns {Promise<string>} The phonemized text
*/
Expand All @@ -181,7 +181,14 @@ export async function phonemize(text, language = "a", norm = true) {
const sections = split(text, PUNCTUATION_PATTERN);

// 3. Convert each section to phonemes
const lang = language === "a" ? "en-us" : "en";
let lang;
if (language === "a") {
lang = "en-us";
} else if (language === "d") {
lang = "de";
} else {
lang = "en";
}
const ps = (await Promise.all(sections.map(async ({ match, text }) => (match ? text : (await espeakng(text, lang)).join(" "))))).join("");

// 4. Post-process phonemes
Expand Down
1 change: 1 addition & 0 deletions kokoro/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
languages = [
"a", # American English
"b", # British English
"d", # German
"h", # Hindi
"e", # Spanish
"f", # French
Expand Down
2 changes: 2 additions & 0 deletions kokoro/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
ALIASES = {
'en-us': 'a',
'en-gb': 'b',
'de': 'd',
'es': 'e',
'fr-fr': 'f',
'hi': 'h',
Expand All @@ -26,6 +27,7 @@
b='British English',

# espeak-ng
d='de',
e='es',
f='fr-fr',
h='hi',
Expand Down