Spaces:
Running
Running
File size: 9,126 Bytes
a1eafb4 e7f83e3 a1eafb4 e7f83e3 6c2477b 46de9a4 14a3c01 47da464 e7f83e3 47da464 0a683cf 47da464 3d37df0 be95d2c 3d37df0 be95d2c 47da464 bcda9c5 a3c313c be95d2c 12b9da4 89b0688 ceb00f0 a3c313c ce62558 ceb00f0 ce62558 6977cd1 a3c313c ceb00f0 ce62558 a3c313c ceb00f0 a3c313c be95d2c 9266c08 bcda9c5 47da464 3d37df0 a3c313c 3d37df0 8427c0e 94d2af5 47da464 5535231 47da464 18a6ba2 47da464 59d5061 47da464 e7f83e3 a1eafb4 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 |
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width" />
<title>Match TTS VCTK ONNX</title>
<link rel="stylesheet" href="style.css" />
</head>
<body>
<div>
<h1>Matcha-TTS VCTK-Onnx Demo</h1>
<p><a href="https://huggingface.co/Akjava/matcha-tts_vctk-onnx" target="link">Model Page</a></p>
<p>Initially take a long time to load model.browser's phonemized is poor than trained data.sometime strange speak would happen</p>
<br>
<script src="https://cdn.jsdelivr.net/npm/onnxruntime-web/dist/ort.webgpu.min.js" ></script>
<script type="module">
import { MatchaTTSRaw } from "./js-esm/matcha_tts_raw.js";
import { webWavPlay } from "./js-esm/web_wav_play.js";
import { arpa_to_ipa } from "./js-esm/arpa_to_ipa.js";
import { loadCmudict } from "./js-esm/cmudict_loader.js";
import { env,textToArpa} from "./js-esm/text_to_arpa.js";
env.allowLocalModels = true;
env.localModelPath = "./models/";
env.backends.onnx.logLevel = "fatal";
let matcha_tts_raw
let cmudict ={}
let speaking = false
async function main() {
if (speaking){
console.log("speaking return")
}
speaking = true
console.log("main called")
if(!matcha_tts_raw){
matcha_tts_raw = new MatchaTTSRaw()
console.time("load model");
await matcha_tts_raw.load_model('./models/matcha-tts/vctk_univ_simplify.onnx',{ executionProviders: ['webgpu','wasm'] });
console.timeEnd("load model");
let cmudictReady = loadCmudict(cmudict,'./dictionaries/cmudict-0.7b')
await cmudictReady
}else{
console.log("session exist skip load model")
}
const text = document.getElementById('textInput').value
const arpa_text = await textToArpa(cmudict,text)
const ipa_text = arpa_to_ipa(arpa_text).replace(/\s/g, "");
console.log(ipa_text)
const spks = document.getElementById('spks').value
const speed = document.getElementById('speed').value
const tempature = document.getElementById('temperature').value
console.time("infer");
const result = await matcha_tts_raw.infer(ipa_text, tempature, speed,spks);
console.timeEnd("infer");
if (result!=null){
webWavPlay(result)
}
speaking = false
}
function update_range(){
const value = document.getElementById('spks').value
let formattedNumber = value.toString().padStart(3, '0');
document.getElementById('spks_label').textContent = formattedNumber
}
function update_range2(){
const value = document.getElementById('temperature').value
//let formattedNumber = value.toString().padStart(3, '0');
document.getElementById('tempature_label').textContent = value//formattedNumber
}
function update_range3(){
const value = document.getElementById('speed').value
//let formattedNumber = value.toString().padStart(3, '0');
document.getElementById('speed_label').textContent = value//sformattedNumber
}
function tts(text,spk){
document.getElementById('textInput').value = text
document.getElementById('spks').value = spk
let formattedNumber = spk.toString().padStart(3, '0');
document.getElementById('spks_label').textContent = formattedNumber
main()
}
function shuffleArray(array) {
return array.slice().sort(() => Math.random() - 0.5);
}
window.onload = async function(){
document.getElementById('textInput').onchange = main;
document.getElementById('myButton').onclick = main;
document.getElementById('spks').onchange = update_range
document.getElementById('temperature').onchange = update_range2
document.getElementById('speed').onchange = update_range3
const word_text = `
Maybe.
Perhaps.
Probably.
Actually.
Basically.
Generally.
Usually.
Obviously.
Seriously.
Honestly.
Come here.
Go there.
Sit down.
Stand up.
Please wait.
Hurry up.
Be careful.
Be quiet.
Listen to me.
Look at this.
It's raining.
It's sunny.
It's cold.
It's hot.
It's late.
It's early.
It's easy.
It's difficult.
It's important.
It's interesting.
I'm excited!
I'm nervous.
I'm tired.
I'm hungry.
I'm thirsty.
I'm bored.
I'm happy.
I'm sad.
I'm angry.
I'm scared.
No problem.
You're welcome.
My pleasure.
Of course.
Sure thing.
No worries.
It's okay.
Don't mention it.
Any time.
See you later!
See you soon!
Take care!
Have a good one!
Good night!
Bye!
Farewell!
Any questions?
Is everything clear?
Do you need anything else?
Can I help you with anything?
What do you think?
I'm not sure about that.
I don't think so.
I disagree.
I see things differently.
That's not how I see it.
Exactly!
I agree.
That's right.
You're right.
I think so too.
I see your point.
You got this!
Hang in there!
Don't give up!
You can do it!
Keep trying!
I believe in you!
Got it.
Okay.
I understand.
Makes sense.
No problem.
You're welcome.
My pleasure.
Sure.
Of course.
Certainly.
Absolutely.
Definitely.
Wow!
Really?
No way!
Are you serious?
You're kidding!
That's incredible!
Unbelievable!
That's great!
That's awesome!
That's amazing!
I'm so happy!
This is fantastic!
Wonderful!
Excellent!
I'm sorry.
My bad.
Excuse me.
I apologize.
Forgive me.
Thank you!
Thanks!
Thank you so much!
I really appreciate it.
You're a lifesaver!
I owe you one.
Hello huggingface!
Good morning/afternoon/evening!
How are you?
How's it going?
What's up?
Long time no see!
Nice to meet you!
Good to see you!
`
const container = document.getElementById("buttons")
const words = shuffleArray(word_text.trim().split("\n"))
let number = 0
for (let word of words){
// Create Button
const button = document.createElement('button');
const spk = number
// Set Button Text
button.textContent = "#"+spk.toString()+" "+word;
button.style ="margin:4px;"
// add click event
button.onclick = () => tts(word, spk);
// add button to dom
container.appendChild(button);
number +=1
if (number>108){
break
}
}
}
</script>
<div id="buttons">
</div>
<br>
<input type="text" id="textInput" value ="Hello.Huggingface" style="width: 200px;" placeholder="Enter some text here...">
<button id="myButton">Text To Speak</button><br><br>
<label for ="spks" style="width: 110px;display: inline-block;">Speaker ID</label>
<input type="range" id="spks" min="0" max="107" value="0" />
<label for ="spks" id="spks_label">000</label><br>
<label for ="temperature" style="width: 110px;display: inline-block;">Temperature</label>
<input type="range" id="temperature" min="0" max="1.0" value="0.5" step="0.1"/>
<label for ="temperature" id="tempature_label">0.5</label><br>
<label for ="speed" style="width: 110px;display: inline-block;">Speed</label>
<input type="range" id="speed" min="0.1" max="2.0" value="1.0" step="0.1"/>
<label for ="speed" id="speed_label">1.0</label>
<br>
<br>
<div> <a href="https://huggingface.co/datasets/CSTR-Edinburgh/vctk">Dataset:CSTR-Edinburgh/vctk</a></div>
<br>
<div id="footer">
<b>Spaces</b><br>
<a href="/spaces/Akjava/matcha-tts_vctk-onnx" style="font-size: 9px" target="link">Match-TTS VCTK-ONNX</a> |
<a href="/spaces/Akjava/matcha-tts-onnx-benchmarks" style="font-size: 9px" target="link">Match-TTS ONNX-Benchmark</a> |
<br><br>
<b>Credits</b><br>
<a href="https://github.com/akjava/Matcha-TTS-Japanese" style="font-size: 9px" target="link">Matcha-TTS-Japanese</a> |
<a href = "http://www.udialogue.org/download/cstr-vctk-corpus.html" style="font-size: 9px" target="link">CSTR VCTK Corpus</a> |
<a href = "https://github.com/cmusphinx/cmudict" style="font-size: 9px" target="link">CMUDict</a> |
<a href = "https://huggingface.co/docs/transformers.js/index" style="font-size: 9px" target="link">Transformer.js</a> |
<a href = "https://huggingface.co/cisco-ai/mini-bart-g2p" style="font-size: 9px" target="link">mini-bart-g2p</a> |
<a href = "https://onnxruntime.ai/docs/get-started/with-javascript/web.html" style="font-size: 9px" target="link">ONNXRuntime-Web</a> |
<a href = "https://github.com/akjava/English-To-IPA-Collections" style="font-size: 9px" target="link">English-To-IPA-Collections</a> |
<a href ="https://huggingface.co/papers/2309.03199" style="font-size: 9px" target="link">Matcha-TTS Paper</a>
</div>
</div>
</body>
</html>
|