Spaces:
Running
Running
Questions: '?' glued to the word, as in v2's training text (a space made wh-questions rise)
Browse files- cleaner.js +2 -2
- english.js +1 -1
- index.html +3 -3
cleaner.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
// Browser port of matcha_patch/polish_cleaners.py + polish_mixed_cleaners: Polish text normalisation, espeak-ng (WASM) IPA,
|
| 2 |
// English words in {braces} phonemized with the en-us voice, symbol ids. Must match the Python cleaners character for character.
|
| 3 |
import { initialize, setVoice, getPhonemes } from "https://cdn.jsdelivr.net/npm/espeak-phonemizer@0.1.2/src/espeak.mjs";
|
| 4 |
-
import { SYMBOL_TO_ID } from "./symbols.js?v=
|
| 5 |
|
| 6 |
const PL_WORD = "0-9a-ząćęłńóśźż";
|
| 7 |
const esc = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
@@ -62,7 +62,7 @@ const unstress = (ph) => { const i = ph.indexOf(" "); const head = i < 0 ? ph :
|
|
| 62 |
|
| 63 |
export async function textToIpa(text) {
|
| 64 |
await initPhonemizer();
|
| 65 |
-
text = text.replace(/\s
|
| 66 |
if (!text.includes("{")) return plPhon(text);
|
| 67 |
let out = "", pos = 0;
|
| 68 |
for (const m of text.matchAll(/\{([^{}]+)\}/g)) {
|
|
|
|
| 1 |
// Browser port of matcha_patch/polish_cleaners.py + polish_mixed_cleaners: Polish text normalisation, espeak-ng (WASM) IPA,
|
| 2 |
// English words in {braces} phonemized with the en-us voice, symbol ids. Must match the Python cleaners character for character.
|
| 3 |
import { initialize, setVoice, getPhonemes } from "https://cdn.jsdelivr.net/npm/espeak-phonemizer@0.1.2/src/espeak.mjs";
|
| 4 |
+
import { SYMBOL_TO_ID } from "./symbols.js?v=20261005c";
|
| 5 |
|
| 6 |
const PL_WORD = "0-9a-ząćęłńóśźż";
|
| 7 |
const esc = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
|
|
| 62 |
|
| 63 |
export async function textToIpa(text) {
|
| 64 |
await initPhonemizer();
|
| 65 |
+
text = text.replace(/\s+\?/g, "?"); // v2 was trained on VoxCPM2 texts with '?' glued to the word: "kuchni ?" -> "kuchni?" (a space makes wh-questions rise)
|
| 66 |
if (!text.includes("{")) return plPhon(text);
|
| 67 |
let out = "", pos = 0;
|
| 68 |
for (const m of text.matchAll(/\{([^{}]+)\}/g)) {
|
english.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
| 3 |
// unlisted words; a frequency table is too big for the browser). Inflected forms whose full form is a common Polish word
|
| 4 |
// (wina, legendy, deskę) are precomputed in english_data.json -> pl_inflected_block.
|
| 5 |
let D = null;
|
| 6 |
-
export async function initEnglish(url = new URL("./english_data.json?v=
|
| 7 |
if (!D) {
|
| 8 |
const j = await (await fetch(url)).json();
|
| 9 |
D = { cur: new Set(j.curated), rap: new Set(j.read_as_polish), suf: j.suffixes, loan: j.loan_stems, block: new Set(j.pl_inflected_block) };
|
|
|
|
| 3 |
// unlisted words; a frequency table is too big for the browser). Inflected forms whose full form is a common Polish word
|
| 4 |
// (wina, legendy, deskę) are precomputed in english_data.json -> pl_inflected_block.
|
| 5 |
let D = null;
|
| 6 |
+
export async function initEnglish(url = new URL("./english_data.json?v=20261005c", import.meta.url)) {
|
| 7 |
if (!D) {
|
| 8 |
const j = await (await fetch(url)).json();
|
| 9 |
D = { cur: new Set(j.curated), rap: new Set(j.read_as_polish), suf: j.suffixes, loan: j.loan_stems, block: new Set(j.pl_inflected_block) };
|
index.html
CHANGED
|
@@ -92,9 +92,9 @@ footer img{height:30px;display:block}
|
|
| 92 |
<script>window.coi={coepCredentialless:()=>true}</script><script src="coi-serviceworker.js"></script>
|
| 93 |
<script src="https://cdn.jsdelivr.net/npm/onnxruntime-web@1.30.0/dist/ort.all.min.js" crossorigin="anonymous"></script>
|
| 94 |
<script type="module">
|
| 95 |
-
import { textToIpa, ipaToIds, initPhonemizer } from "./cleaner.js?v=
|
| 96 |
-
import { initEnglish, markEnglish } from "./english.js?v=
|
| 97 |
-
import { EFFECTS, DEFAULTS, UI_DEFAULTS, applyChain } from "./effects.js?v=
|
| 98 |
const $=id=>document.getElementById(id); const SR=22050;
|
| 99 |
const LOCAL = location.hostname==="localhost"||location.hostname==="127.0.0.1";
|
| 100 |
const MODEL_BASE = LOCAL ? "/release-v2/" : "https://huggingface.co/machinekind/Matcha-TTS-PL-v2/resolve/main/";
|
|
|
|
| 92 |
<script>window.coi={coepCredentialless:()=>true}</script><script src="coi-serviceworker.js"></script>
|
| 93 |
<script src="https://cdn.jsdelivr.net/npm/onnxruntime-web@1.30.0/dist/ort.all.min.js" crossorigin="anonymous"></script>
|
| 94 |
<script type="module">
|
| 95 |
+
import { textToIpa, ipaToIds, initPhonemizer } from "./cleaner.js?v=20261005c";
|
| 96 |
+
import { initEnglish, markEnglish } from "./english.js?v=20261005c";
|
| 97 |
+
import { EFFECTS, DEFAULTS, UI_DEFAULTS, applyChain } from "./effects.js?v=20261005c";
|
| 98 |
const $=id=>document.getElementById(id); const SR=22050;
|
| 99 |
const LOCAL = location.hostname==="localhost"||location.hostname==="127.0.0.1";
|
| 100 |
const MODEL_BASE = LOCAL ? "/release-v2/" : "https://huggingface.co/machinekind/Matcha-TTS-PL-v2/resolve/main/";
|