Akjava commited on
Commit
db61e17
1 Parent(s): 0fcbf28

Upload 27 files

Browse files
dictionaries/LICENSE_cmudict-0.7b.txt ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Copyright (c) 2015, Carnegie Mellon University
2
+ All rights reserved.
3
+
4
+ Redistribution and use in source and binary forms, with or without
5
+ modification, are permitted provided that the following conditions are met:
6
+
7
+ * Redistributions of source code must retain the above copyright notice, this
8
+ list of conditions and the following disclaimer.
9
+
10
+ * Redistributions in binary form must reproduce the above copyright notice,
11
+ this list of conditions and the following disclaimer in the documentation
12
+ and/or other materials provided with the distribution.
13
+
14
+ * Neither the name of dictTools nor the names of its
15
+ contributors may be used to endorse or promote products derived from
16
+ this software without specific prior written permission.
17
+
18
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
22
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
25
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
+
dictionaries/cmudict-0.7b ADDED
The diff for this file is too large to render. See raw diff
 
js-esm/arpa_to_ipa.js ADDED
@@ -0,0 +1,315 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //ver 0.1
2
+
3
+ const vowels = {
4
+ //apply rule owel length is indicated (AA -> ɑː, ER -> ɝː, IY -> iː, UW -> uː). However, unstressed word-final ER and IY are short (i.e., ER0 -> ɝ and IY -> i when word-final).
5
+ 'AA0': 'ɑː',
6
+ 'AA1': 'ɑː',
7
+ 'AA2': 'ɑː',
8
+ 'AE0': 'æ',
9
+ 'AE1': 'æ',
10
+ 'AE2': 'æ',
11
+ 'AH0': 'ə',
12
+ 'AH1': 'ʌ',
13
+ 'AH2': 'ə',//AH is converted to ʌ when bearing primary stress and to ə otherwise (AH1 -> ʌ; AH0, AH2 -> ə) from https://github.com/menelik3/cmudict-ipa
14
+ 'AO0': 'ɔ',
15
+ 'AO1': 'ɔ',
16
+ 'AO2': 'ɔ',
17
+ 'AW0': 'aʊ',
18
+ 'AW1': 'aʊ',
19
+ 'AW2': 'aʊ',
20
+ 'AY0': 'aɪ',
21
+ 'AY1': 'aɪ',
22
+ 'AY2': 'aɪ',
23
+ 'EH0': 'ɛ',
24
+ 'EH1': 'ɛ',
25
+ 'EH2': 'ɛ',
26
+ 'ER0': 'ɝ',//somehow this way betters
27
+ 'ER1': 'ɝː',
28
+ 'ER2': 'ɝː',
29
+ 'EY0': 'eɪ',
30
+ 'EY1': 'eɪ',
31
+ 'EY2': 'eɪ',
32
+ 'IH0': 'ɪ',
33
+ 'IH1': 'ɪ',
34
+ 'IH2': 'ɪ',
35
+ 'IY0': 'iː',
36
+ 'IY1': 'iː',
37
+ 'IY2': 'iː',
38
+ 'OW0': 'oʊ',
39
+ 'OW1': 'oʊ',
40
+ 'OW2': 'oʊ',
41
+ 'OY0': 'ɔɪ',
42
+ 'OY1': 'ɔɪ',
43
+ 'OY2': 'ɔɪ',
44
+ 'UH0': 'ʊ',
45
+ 'UH1': 'ʊ',
46
+ 'UH2': 'ʊ',
47
+ 'UW0': 'uː',
48
+ 'UW1': 'uː',
49
+ 'UW2': 'uː'
50
+ };
51
+
52
+ const consonants = {
53
+ 'B': 'b',
54
+ 'CH': 'tʃ',
55
+ 'D': 'd',
56
+ 'DH': 'ð',
57
+ 'F': 'f',
58
+ 'G': 'g',
59
+ 'HH': 'h',
60
+ 'JH': 'dʒ',
61
+ 'K': 'k',
62
+ 'L': 'l',
63
+ 'M': 'm',
64
+ 'N': 'n',
65
+ 'NG': 'ŋ',
66
+ 'P': 'p',
67
+ 'R': 'r',
68
+ 'S': 's',
69
+ 'SH': 'ʃ',
70
+ 'T': 't',
71
+ 'TH': 'θ',
72
+ 'V': 'v',
73
+ 'W': 'w',
74
+ 'Y': 'j',
75
+ 'Z': 'z',
76
+ 'ZH': 'ʒ'
77
+ };
78
+
79
+
80
+ const AccentMode ={
81
+ SIMPLIFIED_VOWEL_ALIGNED:"SIMPLIFIED_VOWEL_ALIGNED",//Stable not for Human
82
+ STANDARD:"STANDARd",//for Human but broken ,it's hard to split syallable constraints correctly
83
+ NONE:"NONE"
84
+ };
85
+
86
+ const arpa_to_ipa_lookup_tables = {
87
+ ...vowels,
88
+ ...consonants
89
+ };
90
+
91
+ class Syllable {
92
+ constructor(ontop,nucleus, coder,accent,ontop_arpa) {
93
+ this.ontop = ontop;
94
+ this.ontop_arpa = ontop_arpa
95
+ this.nucleus = nucleus; // vowel
96
+
97
+ this.coder = coder
98
+ this.accent = accent;
99
+ }
100
+
101
+
102
+ display() {
103
+ console.log(`Ontop: ${this.ontop} Nucleus: ${this.nucleus}, Coder: ${this.coder}, Accent: ${this.accent}`);
104
+ }
105
+ }
106
+
107
+ //for AccentMode.STANDARD but not good
108
+ const consonantClusters = [
109
+ "PL", "PR", "TR", "BR", "KR", "GR", "DR", "GL", "FL", "BL", "KL",
110
+ // Stop + Nasal
111
+ "TN", "DN", "PN", "GN", "BM", "DM", "PM", "GM", "TM",
112
+ // Fricative + Approximant/Lateral
113
+ "SL", "SW", "SHL", "SHR", "VL", "VR", "ZL", "ZR", "THL", "THR",
114
+ "FTH", "VTH", "ZTH",
115
+ // Other important combinations
116
+ "FY", "KY", "MY", "NY", "HY", "BY", "PY", "LY",
117
+ //add
118
+ "KW","DW",
119
+ // 3-phoneme Clusters
120
+ "SPR", "STR", "SKR", "SPL", "STL", "SKL", "SHT", "SPT", "STK", "SPN"
121
+ ];
122
+
123
+ // for AccentMode.STANDARD but not good
124
+ function splitCodaOnset(consonants,pre_nucleus=null,post_nucleus=null) {
125
+ if (consonants.length==0){
126
+ return [[],[]];
127
+ }else if (consonants.length==1){
128
+ return [[],consonants];
129
+ }
130
+ let peakIndex = 1
131
+ const cluster=consonants.join("")
132
+ if ((cluster == "DM" || cluster == "DN") && (pre_nucleus == "ə" || pre_nucleus=="æ")){ //AD
133
+ peakIndex = 1
134
+ }else if (consonantClusters.includes(cluster)){
135
+ return [[],consonants];
136
+ }
137
+
138
+
139
+ if (cluster == "RDV"){
140
+ peakIndex = 2
141
+ }
142
+ else{
143
+ if (consonants.length>3){
144
+ const last_cluster=consonants.slice(1).join("")
145
+ //console.log(head_cluster)
146
+ if (consonantClusters.includes(last_cluster)){
147
+ peakIndex = 1
148
+ }else{
149
+ peakIndex = 2
150
+ }
151
+ }
152
+ }
153
+
154
+ const coda = consonants.slice(0, peakIndex);
155
+ const onset = consonants.slice(peakIndex);
156
+
157
+ return [ coda, onset ];
158
+ }
159
+
160
+ // Function to convert Arpabet to IPA
161
+ function arpa_to_ipa(arpa_text,accent_mode=AccentMode.SIMPLIFIED_VOWEL_ALIGNED) {
162
+ arpa_text = arpa_text.replaceAll(",","\t,").replaceAll(".","\t.").replaceAll("?","\t?").replaceAll("!","\t!")
163
+ console.log(arpa_text)
164
+ const words = arpa_text.split("\t")
165
+ const ipa_texts = []
166
+ words.forEach(function(word){
167
+ word = word.trim()
168
+ //console.log(`'${word}'`)
169
+ if (word == ""){
170
+ return
171
+ }
172
+ else if (word == "." || word ==","|| word =="!"|| word =="?"){
173
+ ipa_texts.push(word)
174
+ }else{
175
+
176
+ let syllable = arpa_to_ipa_with_syllables(word)
177
+ const ipa_text = syallablesToString(syllable,accent_mode)
178
+
179
+ ipa_texts.push(ipa_text)
180
+ ipa_texts.push(" ") //word separator
181
+ }
182
+
183
+ });
184
+
185
+ return ipa_texts.join("").replaceAll(" .",".").replaceAll(" ,",",").replaceAll(" ?","?").replaceAll(" !","!")
186
+
187
+
188
+ }
189
+
190
+ function arpas_symbol_to_ipa(phonemes){
191
+ let ipaText = ""
192
+ for (let i = 0; i < phonemes.length; i++) {
193
+ const phoneme = phonemes[i];
194
+ let ipaSymbol = arpa_to_ipa_lookup_tables[phoneme];
195
+ if (ipaSymbol === undefined) {
196
+ console.log(`Invalid Arpabet phoneme: ${phoneme}`);
197
+ continue; // Skip invalid phonemes
198
+ }
199
+ ipaText+=ipaSymbol
200
+ }
201
+ return ipaText
202
+ }
203
+
204
+ // Function to convert Arpabet to IPA and extract syllable information
205
+ function arpa_to_ipa_with_syllables(arpa) {
206
+ arpa = arpa.toUpperCase();
207
+ const phonemes = arpa.split(' ');
208
+ let syllables = [];
209
+ let currentSyllable = { nucleus: null, ontop: "", coder:"", accent: -1 ,ontop_arpa:[]}; // Default accent is -1
210
+
211
+ for (let i = 0; i < phonemes.length; i++) {
212
+ const phoneme = phonemes[i];
213
+ let ipaSymbol = arpa_to_ipa_lookup_tables[phoneme];
214
+ if (ipaSymbol === undefined) {//for omitted vowel
215
+ ipaSymbol = arpa_to_ipa_lookup_tables[phoneme+"0"];
216
+ }
217
+
218
+ if (ipaSymbol === undefined) {
219
+ console.log(`Invalid Arpabet phoneme: ${phoneme}`);
220
+ continue; // Skip invalid phonemes
221
+ }
222
+
223
+ // Check for vowel (Corrected condition)
224
+ if (phoneme in vowels) {
225
+
226
+ let accent = -1; // Default accent is -1
227
+ const lastChar = phoneme.slice(-1);
228
+ if (!isNaN(lastChar)) { // Check if the last character is a number
229
+ accent = parseInt(lastChar, 10);
230
+ }
231
+
232
+ syllables.push(new Syllable(currentSyllable.ontop,ipaSymbol, currentSyllable.coder, accent,currentSyllable.ontop_arpa));
233
+ //}
234
+
235
+ currentSyllable = { nucleus: null, ontop: "", coder:"",accent: -1 ,ontop_arpa:[]};
236
+ } else {
237
+ currentSyllable.ontop += ipaSymbol;
238
+ currentSyllable.ontop_arpa.push(phoneme)
239
+ }
240
+ }
241
+
242
+
243
+ // Add the last syllable if it has content
244
+ if (currentSyllable.nucleus !== null || currentSyllable.ontop !== "") {
245
+ syllables.push(new Syllable(currentSyllable.ontop,currentSyllable.nucleus, currentSyllable.coder, currentSyllable.accent));
246
+ }
247
+
248
+ // merge last syallable
249
+ let last_syallable = syllables[syllables.length-1]
250
+ // move single last ontop to pre-coder
251
+ if (last_syallable.nucleus == null){
252
+ const pre_syallable = syllables[syllables.length-2]
253
+ pre_syallable.coder += last_syallable.ontop
254
+ syllables = syllables.slice(0,syllables.length-1)
255
+ }
256
+
257
+ for(let i=1;i<syllables.length;i++){
258
+ const result = splitCodaOnset(syllables[i].ontop_arpa, syllables[i-1].nucleus, syllables[i].nucleus)
259
+ const coder = arpas_symbol_to_ipa(result[0])
260
+ const onset = arpas_symbol_to_ipa(result[1])
261
+ syllables[i-1].coder = coder
262
+ syllables[i].ontop = onset
263
+ }
264
+
265
+
266
+
267
+
268
+ last_syallable = syllables[syllables.length-1]
269
+ if (last_syallable.nucleus!=null){
270
+ if (last_syallable.accent<1){
271
+ if(last_syallable.nucleus.endsWith("iː") && last_syallable.coder==""){
272
+ last_syallable.nucleus = last_syallable.nucleus.substring(0, last_syallable.nucleus.length-1)
273
+ }
274
+ else if(last_syallable.nucleus.endsWith("ɝː")){
275
+ last_syallable.nucleus = last_syallable.nucleus.substring(0, last_syallable.nucleus.length-1)
276
+ }
277
+ }
278
+ }
279
+
280
+ return syllables;
281
+ }
282
+
283
+ function syallablesToString(syllables,accent_mode=AccentMode.SIMPLIFIED_VOWEL_ALIGNED) {
284
+ let ipaString = "";
285
+
286
+
287
+ for (let i = 0; i < syllables.length; i++) {
288
+ const syllable = syllables[i];
289
+ //console.log(syllable.consonant)
290
+ const nucleus = (syllable.nucleus != null) ? syllable.nucleus : "";
291
+ let accent = ""
292
+
293
+ //console.log(ipaString)
294
+
295
+ if (syllable.accent === 1) {
296
+ accent = "ˈ";
297
+ } else if (syllable.accent === 2) {
298
+ accent = "ˌ";
299
+ } else if (syllable.accent === 0) {
300
+ //ipaString = "ˌ" + ipaString;
301
+ }
302
+ if (accent_mode == AccentMode.STANDARD){
303
+ ipaString += accent+syllable.ontop + nucleus+syllable.coder;
304
+ }else if (accent_mode == AccentMode.SIMPLIFIED_VOWEL_ALIGNED){
305
+ ipaString += syllable.ontop + accent+nucleus+syllable.coder;
306
+ }else{
307
+ ipaString += syllable.ontop + nucleus+syllable.coder;
308
+ }
309
+
310
+ }
311
+
312
+ return ipaString;
313
+ }
314
+
315
+ export { arpa_to_ipa };
js-esm/cmudict_loader.js ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //ver 0.1
2
+ async function loadCmudict(obj=cmudict,path='./cmudict-0.7b',splitter=" ") { //split double-space
3
+ return new Promise(async (resolve, reject) => {
4
+ try {
5
+ const response = await fetch(path);
6
+ const responseText = await response.text();
7
+
8
+ const lines = responseText.split('\n');
9
+
10
+ lines.forEach(line => {
11
+ let data = line.trim().split(splitter);
12
+ obj[data[0]] = data[1];
13
+ });
14
+
15
+ resolve(true);
16
+ } catch (error) {
17
+ console.error('Error:', error);
18
+ }
19
+ });
20
+ }
21
+
22
+ //let cmudictReady =loadCmudict();
23
+
24
+ function get_arpa(cmudict,word){
25
+ return cmudict[word.toUpperCase()]
26
+ }
27
+
28
+
29
+ function textToArpa(cmudict,text){
30
+ var keep_words = [",",".","!","?"]
31
+ let inputText = text.toUpperCase()
32
+ keep_words.forEach(function(key){
33
+ inputText = inputText.replaceAll(key," "+key+" ");
34
+ });
35
+ //console.log(`replaced ${inputText}`)
36
+
37
+ let result = []
38
+ let non_converted = []
39
+ var words = inputText.split(" ")
40
+
41
+ words.forEach(word => {
42
+
43
+ if (keep_words.includes(word)){//,.!? just keep
44
+ result.push(word)
45
+ }else if (word ==""){
46
+
47
+ }else{
48
+ const arpa = get_arpa(cmudict,word)
49
+
50
+ if (typeof arpa == "undefined"){
51
+ result.push("@"+word)
52
+ non_converted.push(word)
53
+ }else{
54
+ result.push(arpa)
55
+ }
56
+ }
57
+ });
58
+
59
+ return {"result":result,"non_converted":non_converted}
60
+ }
61
+
62
+ export { textToArpa, loadCmudict};
js-esm/matcha_tts_raw.js ADDED
@@ -0,0 +1,177 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const _pad = "_";
2
+ const _punctuation = ";:,.!?¡¿—…\"«»“” ";
3
+ const _letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
4
+ const _letters_ipa = "ɑɐɒæɓʙβɔɕçɗɖðʤəɘɚɛɜɝɞɟʄɡɠɢʛɦɧħɥʜɨɪʝɭɬɫɮʟɱɯɰŋɳɲɴøɵɸθœɶʘɹɺɾɻʀʁɽʂʃʈʧʉʊʋⱱʌɣɤʍχʎʏʑʐʒʔʡʕʢǀǁǂǃˈˌːˑʼʴʰʱʲʷˠˤ˞↓↑→↗↘'̩'ᵻ";
5
+
6
+ // below code called Spread syntax
7
+ const Symbols = [_pad, ..._punctuation, ..._letters, ..._letters_ipa];
8
+
9
+ const SpaceId = Symbols.indexOf(' ');
10
+
11
+ const symbolToId = {};
12
+ const idToSymbol = {};
13
+
14
+ // initialize symbolToId and idToSymbol
15
+ for (let i = 0; i < Symbols.length; i++) {
16
+ symbolToId[Symbols[i]] = i;
17
+ idToSymbol[i] = Symbols[i];
18
+ }
19
+
20
+ class MatchaTTSRaw {
21
+ constructor() {
22
+ this.processing = false
23
+ }
24
+ async load_model(model_path,options={}){
25
+ this.session = await ort.InferenceSession.create(model_path,options);
26
+ console.log(this.session)
27
+ const inputNames = this.session.inputNames;
28
+ this.need_spks = inputNames.includes("spks")
29
+ console.log(`this model need spks = ${this.need_spks}`);
30
+ return this.session
31
+ }
32
+
33
+ get_output_names_html(){
34
+ if (typeof this.session=='undefined'){
35
+ return null
36
+ }
37
+ let outputNamesString = '[outputNames]<br>';
38
+ const outputNames = this.session.outputNames;
39
+ for (let outputName of outputNames) {
40
+ console.log(outputName)
41
+ outputNamesString+=outputName+"<br>"
42
+ }
43
+ return outputNamesString.trim()
44
+ }
45
+
46
+ get_input_names_html(){
47
+ if (typeof this.session=='undefined'){
48
+ return null
49
+ }
50
+
51
+ let inputNamesString = '[inputNames]<br>';
52
+ const inputNames = this.session.inputNames;
53
+
54
+ for (let inputName of inputNames) {
55
+ console.log(inputName)
56
+ inputNamesString+=inputName+"<br>"
57
+ }
58
+ return inputNamesString.trim()
59
+ }
60
+
61
+
62
+ processText(text) {
63
+ const x = this.intersperse(this.textToSequence(text));
64
+ const x_phones = this.sequenceToText(x);
65
+ const textList = [];
66
+ for (let i = 1; i < x_phones.length; i += 2) {
67
+ textList.push(x_phones[i]);
68
+ }
69
+
70
+ return {
71
+ x: x,
72
+ x_length: x.length,
73
+ x_phones: x_phones,
74
+ x_phones_label: textList.join(""),
75
+ };
76
+ }
77
+
78
+
79
+ basicCleaners2(text, lowercase = false) {
80
+ if (lowercase) {
81
+ text = text.toLowerCase();
82
+ }
83
+ text = text.replace(/\s+/g, " ");
84
+ return text;
85
+ }
86
+
87
+ textToSequence(text) {
88
+ const sequenceList = [];
89
+ const clean_text = this.basicCleaners2(text);
90
+ for (let i = 0; i < clean_text.length; i++) {
91
+ const symbol = clean_text[i];
92
+ sequenceList.push(symbolToId[symbol]);
93
+ }
94
+ return sequenceList;
95
+ }
96
+
97
+ intersperse(sequence, item = 0) {
98
+ const sequenceList = [item];
99
+ for (let i = 0; i < sequence.length; i++) {
100
+ sequenceList.push(sequence[i]);
101
+ sequenceList.push(item);
102
+ }
103
+ return sequenceList;
104
+ }
105
+
106
+ sequenceToText(sequence) {
107
+ const textList = [];
108
+ for (let i = 0; i < sequence.length; i++) {
109
+ const symbol = idToSymbol[sequence[i]];
110
+ textList.push(symbol);
111
+ }
112
+ return textList.join("");
113
+ }
114
+
115
+ async infer(text, temperature, speed,spks=0) {
116
+ if(this.processing){
117
+ console.error("already processing")
118
+ return null
119
+ }
120
+ this.processing = true
121
+ try{
122
+
123
+
124
+ const dic = this.processText(text);
125
+ console.log(`x:${dic.x.join(", ")}`);
126
+ console.log(`x_length:${dic.x_length}`);
127
+ console.log(`x_phones_label:${dic.x_phones_label}`);
128
+ console.log(`temperature=${temperature} speed = ${speed} spks=${spks}`);
129
+
130
+
131
+ const dataX = new BigInt64Array(dic.x.length)
132
+ for (let i = 0; i < dic.x.length; i++) {
133
+ //console.log(dic.x[i])
134
+ dataX[i] = BigInt(dic.x[i]); // Convert each number to a BigInt
135
+ }
136
+ const data_x_length = new BigInt64Array(1)
137
+ data_x_length[0] = BigInt(dic.x_length)
138
+
139
+ //const dataX = Int32Array.from([dic.x_length])
140
+ const tensorX = new ort.Tensor('int64', dataX, [1, dic.x.length]);
141
+ // const data_x_length = Int32Array.from([dic.x_length])
142
+ const tensor_x_length = new ort.Tensor('int64', data_x_length, [1]);
143
+ const data_scale = Float32Array.from( [temperature, speed])
144
+ const tensor_scale = new ort.Tensor('float32', data_scale, [2]);
145
+
146
+
147
+ const send_data = {
148
+ x: tensorX,
149
+ x_lengths: tensor_x_length,
150
+ scales: tensor_scale,
151
+ }
152
+
153
+ //for vctk need speaker id
154
+ if (this.need_spks){
155
+ const data_spks = new BigInt64Array(1)
156
+ data_spks[0] = BigInt(spks)
157
+ const tensor_spks = new ort.Tensor('int64', data_spks, [1]);
158
+ send_data.spks = tensor_spks
159
+ }
160
+ // Run inference
161
+ const output = await this.session.run(send_data);
162
+ //If your onnx not connect hifigun difference output return (not tested)
163
+ const wav_array = output.wav.data;
164
+ const x_lengths_array = output.wav_lengths.data;
165
+
166
+ this.processing = false
167
+ return wav_array;
168
+ }catch (exception){
169
+ this.processing = false
170
+ return null
171
+ }
172
+ }
173
+
174
+
175
+ }
176
+
177
+ export { MatchaTTSRaw };
js-esm/ort-wasm-simd-threaded.mjs ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ var ortWasmThreaded = (() => {
3
+ var _scriptName = import.meta.url;
4
+
5
+ return (
6
+ async function(moduleArg = {}) {
7
+ var moduleRtn;
8
+
9
+ function aa(){g.buffer!=l.buffer&&m();return l}function n(){g.buffer!=l.buffer&&m();return ba}function r(){g.buffer!=l.buffer&&m();return ca}function u(){g.buffer!=l.buffer&&m();return da}function ea(){g.buffer!=l.buffer&&m();return fa}var w=Object.assign({},moduleArg),ha,x,ia=new Promise((a,b)=>{ha=a;x=b}),ja="object"==typeof window,A="function"==typeof importScripts,B="object"==typeof process&&"object"==typeof process.versions&&"string"==typeof process.versions.node,C=A&&"em-pthread"==self.name;
10
+ if(B){const {createRequire:a}=await import("module");var require=a(import.meta.url),D=require("worker_threads");global.Worker=D.Worker;C=(A=!D.lb)&&"em-pthread"==D.workerData}"use strict";w.mountExternalData=(a,b)=>{(w.Ua||(w.Ua=new Map)).set(a,b)};w.unmountExternalData=()=>{delete w.Ua};
11
+ var SharedArrayBuffer=globalThis.SharedArrayBuffer??(new WebAssembly.Memory({initial:0,maximum:0,shared:!0})).buffer.constructor,ka=Object.assign({},w),la="./this.program",E=(a,b)=>{throw b;},F="",ma,G,H;
12
+ if(B){var fs=require("fs"),na=require("path");F=require("url").fileURLToPath(new URL("./",import.meta.url));ma=(a,b)=>{a=oa(a)?new URL(a):na.normalize(a);return fs.readFileSync(a,b?void 0:"utf8")};H=a=>{a=ma(a,!0);a.buffer||(a=new Uint8Array(a));return a};G=(a,b,c,d=!0)=>{a=oa(a)?new URL(a):na.normalize(a);fs.readFile(a,d?void 0:"utf8",(f,h)=>{f?c(f):b(d?h.buffer:h)})};!w.thisProgram&&1<process.argv.length&&(la=process.argv[1].replace(/\\/g,"/"));process.argv.slice(2);E=(a,b)=>{process.exitCode=
13
+ a;throw b;}}else if(ja||A)A?F=self.location.href:"undefined"!=typeof document&&document.currentScript&&(F=document.currentScript.src),_scriptName&&(F=_scriptName),F.startsWith("blob:")?F="":F=F.substr(0,F.replace(/[?#].*/,"").lastIndexOf("/")+1),B||(ma=a=>{var b=new XMLHttpRequest;b.open("GET",a,!1);b.send(null);return b.responseText},A&&(H=a=>{var b=new XMLHttpRequest;b.open("GET",a,!1);b.responseType="arraybuffer";b.send(null);return new Uint8Array(b.response)}),G=(a,b,c)=>{var d=new XMLHttpRequest;
14
+ d.open("GET",a,!0);d.responseType="arraybuffer";d.onload=()=>{200==d.status||0==d.status&&d.response?b(d.response):c()};d.onerror=c;d.send(null)});B&&"undefined"==typeof performance&&(global.performance=require("perf_hooks").performance);var pa=console.log.bind(console),qa=console.error.bind(console);B&&(pa=(...a)=>fs.writeSync(1,a.join(" ")+"\n"),qa=(...a)=>fs.writeSync(2,a.join(" ")+"\n"));var ra=pa,I=qa;Object.assign(w,ka);ka=null;
15
+ if(C){var sa;if(B){var ta=D.parentPort;ta.on("message",b=>onmessage({data:b}));Object.assign(globalThis,{self:global,importScripts:()=>{},postMessage:b=>ta.postMessage(b),performance:global.performance||{now:Date.now}})}var ua=!1;I=function(...b){b=b.join(" ");B?fs.writeSync(2,b+"\n"):console.error(b)};self.alert=function(...b){postMessage({Za:"alert",text:b.join(" "),mb:K()})};w.instantiateWasm=(b,c)=>new Promise(d=>{sa=f=>{f=new WebAssembly.Instance(f,va());c(f);d()}});self.onunhandledrejection=
16
+ b=>{throw b.reason||b;};function a(b){try{var c=b.data,d=c.cmd;if("load"===d){let f=[];self.onmessage=h=>f.push(h);self.startWorker=()=>{postMessage({cmd:"loaded"});for(let h of f)a(h);self.onmessage=a};for(const h of c.handlers)if(!w[h]||w[h].proxy)w[h]=(...k)=>{postMessage({Za:"callHandler",kb:h,args:k})},"print"==h&&(ra=w[h]),"printErr"==h&&(I=w[h]);g=c.wasmMemory;m();sa(c.wasmModule)}else if("run"===d){wa(c.pthread_ptr,0,0,1,0,0);xa(c.pthread_ptr);ya();za();ua||=!0;try{Aa(c.start_routine,c.arg)}catch(f){if("unwind"!=
17
+ f)throw f;}}else"cancel"===d?K()&&Ba(-1):"setimmediate"!==c.target&&("checkMailbox"===d?ua&&Ca():d&&(I(`worker: received unknown command ${d}`),I(c)))}catch(f){throw Da(),f;}}self.onmessage=a}var L;w.wasmBinary&&(L=w.wasmBinary);var g,Ea,Fa=!1,M,l,ba,ca,da,N,fa;
18
+ function m(){var a=g.buffer;w.HEAP8=l=new Int8Array(a);w.HEAP16=new Int16Array(a);w.HEAPU8=ba=new Uint8Array(a);w.HEAPU16=new Uint16Array(a);w.HEAP32=ca=new Int32Array(a);w.HEAPU32=da=new Uint32Array(a);w.HEAPF32=new Float32Array(a);w.HEAPF64=fa=new Float64Array(a);w.HEAP64=N=new BigInt64Array(a);w.HEAPU64=new BigUint64Array(a)}
19
+ if(!C){g=new WebAssembly.Memory({initial:256,maximum:65536,shared:!0});if(!(g.buffer instanceof SharedArrayBuffer))throw I("requested a shared WebAssembly.Memory but the returned buffer is not a SharedArrayBuffer, indicating that while the browser has SharedArrayBuffer it does not have WebAssembly threads support - you may need to set a flag"),B&&I("(on node you may need: --experimental-wasm-threads --experimental-wasm-bulk-memory and/or recent version)"),Error("bad memory");m()}
20
+ var Ga=[],Ha=[],Ia=[],O=0,Ja=null,P=null;function Ka(){O--;if(0==O&&(null!==Ja&&(clearInterval(Ja),Ja=null),P)){var a=P;P=null;a()}}function La(a){a="Aborted("+a+")";I(a);Fa=!0;M=1;a=new WebAssembly.RuntimeError(a+". Build with -sASSERTIONS for more info.");x(a);throw a;}var Ma=a=>a.startsWith("data:application/octet-stream;base64,"),oa=a=>a.startsWith("file://"),Na;function Oa(a){if(a==Na&&L)return new Uint8Array(L);if(H)return H(a);throw"both async and sync fetching of the wasm failed";}
21
+ function Pa(a){if(!L&&(ja||A)){if("function"==typeof fetch&&!oa(a))return fetch(a,{credentials:"same-origin"}).then(b=>{if(!b.ok)throw`failed to load wasm binary file at '${a}'`;return b.arrayBuffer()}).catch(()=>Oa(a));if(G)return new Promise((b,c)=>{G(a,d=>b(new Uint8Array(d)),c)})}return Promise.resolve().then(()=>Oa(a))}function Qa(a,b,c){return Pa(a).then(d=>WebAssembly.instantiate(d,b)).then(c,d=>{I(`failed to asynchronously prepare wasm: ${d}`);La(d)})}
22
+ function Ra(a,b){var c=Na;return L||"function"!=typeof WebAssembly.instantiateStreaming||Ma(c)||oa(c)||B||"function"!=typeof fetch?Qa(c,a,b):fetch(c,{credentials:"same-origin"}).then(d=>WebAssembly.instantiateStreaming(d,a).then(b,function(f){I(`wasm streaming compile failed: ${f}`);I("falling back to ArrayBuffer instantiation");return Qa(c,a,b)}))}
23
+ function va(){Sa={j:Ta,b:Ua,E:Va,g:Wa,V:Xa,A:Ya,C:Za,W:$a,T:ab,L:bb,S:cb,o:db,B:eb,y:fb,U:gb,z:hb,_:ib,Z:jb,P:kb,w:lb,F:mb,k:nb,O:xa,Y:ob,I:pb,J:qb,K:rb,G:sb,H:tb,v:ub,q:vb,l:wb,p:xb,e:yb,X:zb,x:Ab,d:Bb,f:Cb,i:Db,u:Eb,t:Fb,s:Gb,Q:Hb,R:Ib,D:Jb,h:Kb,n:Lb,M:Mb,m:Nb,a:g,r:Ob,N:Pb,c:Qb};return{a:Sa}}
24
+ var Rb={821972:(a,b,c,d)=>{if("undefined"==typeof w||!w.Ua)return 1;a=Q(a>>>0);a.startsWith("./")&&(a=a.substring(2));a=w.Ua.get(a);if(!a)return 2;b>>>=0;c>>>=0;d>>>=0;if(b+c>a.byteLength)return 3;try{return n().set(a.subarray(b,b+c),d>>>0),0}catch{return 4}},822473:()=>"undefined"!==typeof wasmOffsetConverter};function Ta(){return"undefined"!==typeof wasmOffsetConverter}function Sb(a){this.name="ExitStatus";this.message=`Program terminated with exit(${a})`;this.status=a}
25
+ var Tb=a=>{a.terminate();a.onmessage=()=>{}},Wb=a=>{0==R.length&&(Ub(),Vb(R[0]));var b=R.pop();if(!b)return 6;S.push(b);T[a.Ra]=b;b.Ra=a.Ra;var c={cmd:"run",start_routine:a.cb,arg:a.ab,pthread_ptr:a.Ra};B&&b.unref();b.postMessage(c,a.ib);return 0},U=0,V=(a,b,...c)=>{for(var d=2*c.length,f=$b(),h=ac(8*d),k=h>>>3,q=0;q<c.length;q++){var y=c[q];"bigint"==typeof y?(N[k+2*q]=1n,N[k+2*q+1]=y):(N[k+2*q]=0n,ea()[k+2*q+1>>>0]=y)}a=bc(a,0,d,h,b);cc(f);return a};
26
+ function Ob(a){if(C)return V(0,1,a);M=a;if(!(0<U)){for(var b of S)Tb(b);for(b of R)Tb(b);R=[];S=[];T=[];Fa=!0}E(a,new Sb(a))}function dc(a){if(C)return V(1,0,a);Jb(a)}var Jb=a=>{M=a;if(C)throw dc(a),"unwind";Ob(a)},R=[],S=[],ec=[],T={};function fc(){for(var a=w.numThreads-1;a--;)Ub();Ga.unshift(()=>{O++;gc(()=>Ka())})}var ic=a=>{var b=a.Ra;delete T[b];R.push(a);S.splice(S.indexOf(a),1);a.Ra=0;hc(b)};function za(){ec.forEach(a=>a())}
27
+ var Vb=a=>new Promise(b=>{a.onmessage=h=>{h=h.data;var k=h.cmd;if(h.targetThread&&h.targetThread!=K()){var q=T[h.targetThread];q?q.postMessage(h,h.transferList):I(`Internal error! Worker sent a message "${k}" to target pthread ${h.targetThread}, but that thread no longer exists!`)}else if("checkMailbox"===k)Ca();else if("spawnThread"===k)Wb(h);else if("cleanupThread"===k)ic(T[h.thread]);else if("killThread"===k)h=h.thread,k=T[h],delete T[h],Tb(k),hc(h),S.splice(S.indexOf(k),1),k.Ra=0;else if("cancelThread"===
28
+ k)T[h.thread].postMessage({cmd:"cancel"});else if("loaded"===k)a.loaded=!0,B&&!a.Ra&&a.unref(),b(a);else if("alert"===k)alert(`Thread ${h.threadId}: ${h.text}`);else if("setimmediate"===h.target)a.postMessage(h);else if("callHandler"===k)w[h.handler](...h.args);else k&&I(`worker sent an unknown command ${k}`)};a.onerror=h=>{I(`${"worker sent an error!"} ${h.filename}:${h.lineno}: ${h.message}`);throw h;};B&&(a.on("message",h=>a.onmessage({data:h})),a.on("error",h=>a.onerror(h)));var c=[],d=[],f;for(f of d)w.hasOwnProperty(f)&&
29
+ c.push(f);a.postMessage({cmd:"load",handlers:c,wasmMemory:g,wasmModule:Ea})});function gc(a){C?a():Promise.all(R.map(Vb)).then(a)}function Ub(){var a=new Worker(new URL(import.meta.url),{type:"module",workerData:"em-pthread",name:"em-pthread"});R.push(a)}var jc=a=>{for(;0<a.length;)a.shift()(w)},ya=()=>{var a=K(),b=u()[a+52>>>2>>>0];a=u()[a+56>>>2>>>0];kc(b,b-a);cc(b)},lc=[],mc,Aa=(a,b)=>{U=0;var c=lc[a];c||(a>=lc.length&&(lc.length=a+1),lc[a]=c=mc.get(a));a=c(b);0<U?M=a:Ba(a)};
30
+ class nc{constructor(a){this.Xa=a-24}}var oc=0,pc=0;function Ua(a,b,c){a>>>=0;var d=new nc(a);b>>>=0;c>>>=0;u()[d.Xa+16>>>2>>>0]=0;u()[d.Xa+4>>>2>>>0]=b;u()[d.Xa+8>>>2>>>0]=c;oc=a;pc++;throw oc;}function qc(a,b,c,d){return C?V(2,1,a,b,c,d):Va(a,b,c,d)}
31
+ function Va(a,b,c,d){a>>>=0;b>>>=0;c>>>=0;d>>>=0;if("undefined"==typeof SharedArrayBuffer)return I("Current environment does not support SharedArrayBuffer, pthreads are not available!"),6;var f=[];if(C&&0===f.length)return qc(a,b,c,d);a={cb:c,Ra:a,ab:d,ib:f};return C?(a.Za="spawnThread",postMessage(a,f),0):Wb(a)}
32
+ var rc="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0,sc=(a,b,c)=>{b>>>=0;var d=b+c;for(c=b;a[c]&&!(c>=d);)++c;if(16<c-b&&a.buffer&&rc)return rc.decode(a.buffer instanceof SharedArrayBuffer?a.slice(b,c):a.subarray(b,c));for(d="";b<c;){var f=a[b++];if(f&128){var h=a[b++]&63;if(192==(f&224))d+=String.fromCharCode((f&31)<<6|h);else{var k=a[b++]&63;f=224==(f&240)?(f&15)<<12|h<<6|k:(f&7)<<18|h<<12|k<<6|a[b++]&63;65536>f?d+=String.fromCharCode(f):(f-=65536,d+=String.fromCharCode(55296|f>>
33
+ 10,56320|f&1023))}}else d+=String.fromCharCode(f)}return d},Q=(a,b)=>(a>>>=0)?sc(n(),a,b):"";function Wa(a,b,c){return C?V(3,1,a,b,c):0}function Xa(a,b){if(C)return V(4,1,a,b)}
34
+ var tc=a=>{for(var b=0,c=0;c<a.length;++c){var d=a.charCodeAt(c);127>=d?b++:2047>=d?b+=2:55296<=d&&57343>=d?(b+=4,++c):b+=3}return b},uc=(a,b,c,d)=>{c>>>=0;if(!(0<d))return 0;var f=c;d=c+d-1;for(var h=0;h<a.length;++h){var k=a.charCodeAt(h);if(55296<=k&&57343>=k){var q=a.charCodeAt(++h);k=65536+((k&1023)<<10)|q&1023}if(127>=k){if(c>=d)break;b[c++>>>0]=k}else{if(2047>=k){if(c+1>=d)break;b[c++>>>0]=192|k>>6}else{if(65535>=k){if(c+2>=d)break;b[c++>>>0]=224|k>>12}else{if(c+3>=d)break;b[c++>>>0]=240|k>>
35
+ 18;b[c++>>>0]=128|k>>12&63}b[c++>>>0]=128|k>>6&63}b[c++>>>0]=128|k&63}}b[c>>>0]=0;return c-f},W=(a,b,c)=>uc(a,n(),b,c);function Ya(a,b){if(C)return V(5,1,a,b)}function Za(a,b,c){if(C)return V(6,1,a,b,c)}function $a(a,b,c){return C?V(7,1,a,b,c):0}function ab(a,b){if(C)return V(8,1,a,b)}function bb(a,b,c){if(C)return V(9,1,a,b,c)}function cb(a,b,c,d){if(C)return V(10,1,a,b,c,d)}function db(a,b,c,d){if(C)return V(11,1,a,b,c,d)}function eb(a,b,c,d){if(C)return V(12,1,a,b,c,d)}
36
+ function fb(a){if(C)return V(13,1,a)}function gb(a,b){if(C)return V(14,1,a,b)}function hb(a,b,c){if(C)return V(15,1,a,b,c)}var ib=()=>{La("")},jb=()=>1;function kb(a){wa(a>>>0,!A,1,!ja,131072,!1);za()}function xa(a){a>>>=0;"function"===typeof Atomics.jb&&(Atomics.jb(r(),a>>>2,a).value.then(Ca),a+=128,Atomics.store(r(),a>>>2,1))}
37
+ var Ca=()=>{var a=K();if(a&&(xa(a),a=vc,!Fa))try{if(a(),!(0<U))try{C?Ba(M):Jb(M)}catch(b){b instanceof Sb||"unwind"==b||E(1,b)}}catch(b){b instanceof Sb||"unwind"==b||E(1,b)}};function lb(a,b){a>>>=0;a==b>>>0?setTimeout(Ca):C?postMessage({targetThread:a,cmd:"checkMailbox"}):(a=T[a])&&a.postMessage({cmd:"checkMailbox"})}var wc=[];function mb(a,b,c,d,f){b>>>=0;d/=2;wc.length=d;c=f>>>0>>>3;for(f=0;f<d;f++)wc[f]=N[c+2*f]?N[c+2*f+1]:ea()[c+2*f+1>>>0];return(b?Rb[b]:xc[a])(...wc)}
38
+ function nb(a){a>>>=0;C?postMessage({cmd:"cleanupThread",thread:a}):ic(T[a])}function ob(a){B&&T[a>>>0].ref()}
39
+ function pb(a,b){a=-9007199254740992>a||9007199254740992<a?NaN:Number(a);b>>>=0;a=new Date(1E3*a);r()[b>>>2>>>0]=a.getUTCSeconds();r()[b+4>>>2>>>0]=a.getUTCMinutes();r()[b+8>>>2>>>0]=a.getUTCHours();r()[b+12>>>2>>>0]=a.getUTCDate();r()[b+16>>>2>>>0]=a.getUTCMonth();r()[b+20>>>2>>>0]=a.getUTCFullYear()-1900;r()[b+24>>>2>>>0]=a.getUTCDay();a=(a.getTime()-Date.UTC(a.getUTCFullYear(),0,1,0,0,0,0))/864E5|0;r()[b+28>>>2>>>0]=a}
40
+ var X=a=>0===a%4&&(0!==a%100||0===a%400),yc=[0,31,60,91,121,152,182,213,244,274,305,335],zc=[0,31,59,90,120,151,181,212,243,273,304,334];
41
+ function qb(a,b){a=-9007199254740992>a||9007199254740992<a?NaN:Number(a);b>>>=0;a=new Date(1E3*a);r()[b>>>2>>>0]=a.getSeconds();r()[b+4>>>2>>>0]=a.getMinutes();r()[b+8>>>2>>>0]=a.getHours();r()[b+12>>>2>>>0]=a.getDate();r()[b+16>>>2>>>0]=a.getMonth();r()[b+20>>>2>>>0]=a.getFullYear()-1900;r()[b+24>>>2>>>0]=a.getDay();var c=(X(a.getFullYear())?yc:zc)[a.getMonth()]+a.getDate()-1|0;r()[b+28>>>2>>>0]=c;r()[b+36>>>2>>>0]=-(60*a.getTimezoneOffset());c=(new Date(a.getFullYear(),6,1)).getTimezoneOffset();
42
+ var d=(new Date(a.getFullYear(),0,1)).getTimezoneOffset();a=(c!=d&&a.getTimezoneOffset()==Math.min(d,c))|0;r()[b+32>>>2>>>0]=a}
43
+ function rb(a){a>>>=0;var b=new Date(r()[a+20>>>2>>>0]+1900,r()[a+16>>>2>>>0],r()[a+12>>>2>>>0],r()[a+8>>>2>>>0],r()[a+4>>>2>>>0],r()[a>>>2>>>0],0),c=r()[a+32>>>2>>>0],d=b.getTimezoneOffset(),f=(new Date(b.getFullYear(),6,1)).getTimezoneOffset(),h=(new Date(b.getFullYear(),0,1)).getTimezoneOffset(),k=Math.min(h,f);0>c?r()[a+32>>>2>>>0]=Number(f!=h&&k==d):0<c!=(k==d)&&(f=Math.max(h,f),b.setTime(b.getTime()+6E4*((0<c?k:f)-d)));r()[a+24>>>2>>>0]=b.getDay();c=(X(b.getFullYear())?yc:zc)[b.getMonth()]+
44
+ b.getDate()-1|0;r()[a+28>>>2>>>0]=c;r()[a>>>2>>>0]=b.getSeconds();r()[a+4>>>2>>>0]=b.getMinutes();r()[a+8>>>2>>>0]=b.getHours();r()[a+12>>>2>>>0]=b.getDate();r()[a+16>>>2>>>0]=b.getMonth();r()[a+20>>>2>>>0]=b.getYear();a=b.getTime();return BigInt(isNaN(a)?-1:a/1E3)}function sb(a,b,c,d,f,h,k){return C?V(16,1,a,b,c,d,f,h,k):-52}function tb(a,b,c,d,f,h){if(C)return V(17,1,a,b,c,d,f,h)}
45
+ function ub(a,b,c,d){a>>>=0;b>>>=0;c>>>=0;d>>>=0;var f=(new Date).getFullYear(),h=new Date(f,0,1),k=new Date(f,6,1);f=h.getTimezoneOffset();var q=k.getTimezoneOffset(),y=Math.max(f,q);u()[a>>>2>>>0]=60*y;r()[b>>>2>>>0]=Number(f!=q);a=v=>v.toLocaleTimeString(void 0,{hour12:!1,timeZoneName:"short"}).split(" ")[1];h=a(h);k=a(k);q<f?(W(h,c,17),W(k,d,17)):(W(h,d,17),W(k,c,17))}var Ac=[];
46
+ function vb(a,b,c){a>>>=0;b>>>=0;c>>>=0;Ac.length=0;for(var d;d=n()[b++>>>0];){var f=105!=d;f&=112!=d;c+=f&&c%8?4:0;Ac.push(112==d?u()[c>>>2>>>0]:106==d?N[c>>>3]:105==d?r()[c>>>2>>>0]:ea()[c>>>3>>>0]);c+=f?8:4}return Rb[a](...Ac)}var wb=()=>{},xb=()=>Date.now();function yb(a,b){return I(Q(a>>>0,b>>>0))}var zb=()=>{U+=1;throw"unwind";};function Ab(){return 4294901760}var Bb;Bb=()=>performance.timeOrigin+performance.now();var Cb=()=>B?require("os").cpus().length:navigator.hardwareConcurrency;
47
+ function Db(){La("Cannot use emscripten_pc_get_function without -sUSE_OFFSET_CONVERTER");return 0}function Eb(a){a>>>=0;var b=n().length;if(a<=b||4294901760<a)return!1;for(var c=1;4>=c;c*=2){var d=b*(1+.2/c);d=Math.min(d,a+100663296);var f=Math;d=Math.max(a,d);a:{f=(f.min.call(f,4294901760,d+(65536-d%65536)%65536)-g.buffer.byteLength+65535)/65536;try{g.grow(f);m();var h=1;break a}catch(k){}h=void 0}if(h)return!0}return!1}
48
+ var Bc=()=>{La("Cannot use convertFrameToPC (needed by __builtin_return_address) without -sUSE_OFFSET_CONVERTER");return 0},Y={},Cc=a=>{a.forEach(b=>{var c=Bc();c&&(Y[c]=b)})};function Fb(){var a=Error().stack.toString().split("\n");"Error"==a[0]&&a.shift();Cc(a);Y.$a=Bc();Y.bb=a;return Y.$a}
49
+ function Gb(a,b,c){a>>>=0;b>>>=0;if(Y.$a==a)var d=Y.bb;else d=Error().stack.toString().split("\n"),"Error"==d[0]&&d.shift(),Cc(d);for(var f=3;d[f]&&Bc()!=a;)++f;for(a=0;a<c&&d[a+f];++a)r()[b+4*a>>>2>>>0]=Bc();return a}
50
+ var Dc={},Fc=()=>{if(!Ec){var a={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:("object"==typeof navigator&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",_:la||"./this.program"},b;for(b in Dc)void 0===Dc[b]?delete a[b]:a[b]=Dc[b];var c=[];for(b in a)c.push(`${b}=${a[b]}`);Ec=c}return Ec},Ec;
51
+ function Hb(a,b){if(C)return V(18,1,a,b);a>>>=0;b>>>=0;var c=0;Fc().forEach((d,f)=>{var h=b+c;f=u()[a+4*f>>>2>>>0]=h;for(h=0;h<d.length;++h)aa()[f++>>>0]=d.charCodeAt(h);aa()[f>>>0]=0;c+=d.length+1});return 0}function Ib(a,b){if(C)return V(19,1,a,b);a>>>=0;b>>>=0;var c=Fc();u()[a>>>2>>>0]=c.length;var d=0;c.forEach(f=>d+=f.length+1);u()[b>>>2>>>0]=d;return 0}function Kb(a){return C?V(20,1,a):52}function Lb(a,b,c,d){return C?V(21,1,a,b,c,d):52}function Mb(a,b,c,d){return C?V(22,1,a,b,c,d):70}
52
+ var Gc=[null,[],[]];function Nb(a,b,c,d){if(C)return V(23,1,a,b,c,d);b>>>=0;c>>>=0;d>>>=0;for(var f=0,h=0;h<c;h++){var k=u()[b>>>2>>>0],q=u()[b+4>>>2>>>0];b+=8;for(var y=0;y<q;y++){var v=n()[k+y>>>0],z=Gc[a];0===v||10===v?((1===a?ra:I)(sc(z,0)),z.length=0):z.push(v)}f+=q}u()[d>>>2>>>0]=f;return 0}var Hc=[31,29,31,30,31,30,31,31,30,31,30,31],Ic=[31,28,31,30,31,30,31,31,30,31,30,31];function Jc(a){var b=Array(tc(a)+1);uc(a,b,0,b.length);return b}var Kc=(a,b)=>{aa().set(a,b>>>0)};
53
+ function Pb(a,b,c,d){function f(e,p,t){for(e="number"==typeof e?e.toString():e||"";e.length<p;)e=t[0]+e;return e}function h(e,p){return f(e,p,"0")}function k(e,p){function t(Xb){return 0>Xb?-1:0<Xb?1:0}var J;0===(J=t(e.getFullYear()-p.getFullYear()))&&0===(J=t(e.getMonth()-p.getMonth()))&&(J=t(e.getDate()-p.getDate()));return J}function q(e){switch(e.getDay()){case 0:return new Date(e.getFullYear()-1,11,29);case 1:return e;case 2:return new Date(e.getFullYear(),0,3);case 3:return new Date(e.getFullYear(),
54
+ 0,2);case 4:return new Date(e.getFullYear(),0,1);case 5:return new Date(e.getFullYear()-1,11,31);case 6:return new Date(e.getFullYear()-1,11,30)}}function y(e){var p=e.Sa;for(e=new Date((new Date(e.Ta+1900,0,1)).getTime());0<p;){var t=e.getMonth(),J=(X(e.getFullYear())?Hc:Ic)[t];if(p>J-e.getDate())p-=J-e.getDate()+1,e.setDate(1),11>t?e.setMonth(t+1):(e.setMonth(0),e.setFullYear(e.getFullYear()+1));else{e.setDate(e.getDate()+p);break}}t=new Date(e.getFullYear()+1,0,4);p=q(new Date(e.getFullYear(),
55
+ 0,4));t=q(t);return 0>=k(p,e)?0>=k(t,e)?e.getFullYear()+1:e.getFullYear():e.getFullYear()-1}a>>>=0;b>>>=0;c>>>=0;d>>>=0;var v=u()[d+40>>>2>>>0];d={gb:r()[d>>>2>>>0],fb:r()[d+4>>>2>>>0],Va:r()[d+8>>>2>>>0],Ya:r()[d+12>>>2>>>0],Wa:r()[d+16>>>2>>>0],Ta:r()[d+20>>>2>>>0],Qa:r()[d+24>>>2>>>0],Sa:r()[d+28>>>2>>>0],nb:r()[d+32>>>2>>>0],eb:r()[d+36>>>2>>>0],hb:v?Q(v):""};c=Q(c);v={"%c":"%a %b %d %H:%M:%S %Y","%D":"%m/%d/%y","%F":"%Y-%m-%d","%h":"%b","%r":"%I:%M:%S %p","%R":"%H:%M","%T":"%H:%M:%S","%x":"%m/%d/%y",
56
+ "%X":"%H:%M:%S","%Ec":"%c","%EC":"%C","%Ex":"%m/%d/%y","%EX":"%H:%M:%S","%Ey":"%y","%EY":"%Y","%Od":"%d","%Oe":"%e","%OH":"%H","%OI":"%I","%Om":"%m","%OM":"%M","%OS":"%S","%Ou":"%u","%OU":"%U","%OV":"%V","%Ow":"%w","%OW":"%W","%Oy":"%y"};for(var z in v)c=c.replace(new RegExp(z,"g"),v[z]);var Yb="Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" "),Zb="January February March April May June July August September October November December".split(" ");v={"%a":e=>Yb[e.Qa].substring(0,3),
57
+ "%A":e=>Yb[e.Qa],"%b":e=>Zb[e.Wa].substring(0,3),"%B":e=>Zb[e.Wa],"%C":e=>h((e.Ta+1900)/100|0,2),"%d":e=>h(e.Ya,2),"%e":e=>f(e.Ya,2," "),"%g":e=>y(e).toString().substring(2),"%G":y,"%H":e=>h(e.Va,2),"%I":e=>{e=e.Va;0==e?e=12:12<e&&(e-=12);return h(e,2)},"%j":e=>{for(var p=0,t=0;t<=e.Wa-1;p+=(X(e.Ta+1900)?Hc:Ic)[t++]);return h(e.Ya+p,3)},"%m":e=>h(e.Wa+1,2),"%M":e=>h(e.fb,2),"%n":()=>"\n","%p":e=>0<=e.Va&&12>e.Va?"AM":"PM","%S":e=>h(e.gb,2),"%t":()=>"\t","%u":e=>e.Qa||7,"%U":e=>h(Math.floor((e.Sa+
58
+ 7-e.Qa)/7),2),"%V":e=>{var p=Math.floor((e.Sa+7-(e.Qa+6)%7)/7);2>=(e.Qa+371-e.Sa-2)%7&&p++;if(p)53==p&&(t=(e.Qa+371-e.Sa)%7,4==t||3==t&&X(e.Ta)||(p=1));else{p=52;var t=(e.Qa+7-e.Sa-1)%7;(4==t||5==t&&X(e.Ta%400-1))&&p++}return h(p,2)},"%w":e=>e.Qa,"%W":e=>h(Math.floor((e.Sa+7-(e.Qa+6)%7)/7),2),"%y":e=>(e.Ta+1900).toString().substring(2),"%Y":e=>e.Ta+1900,"%z":e=>{e=e.eb;var p=0<=e;e=Math.abs(e)/60;return(p?"+":"-")+String("0000"+(e/60*100+e%60)).slice(-4)},"%Z":e=>e.hb,"%%":()=>"%"};c=c.replace(/%%/g,
59
+ "\x00\x00");for(z in v)c.includes(z)&&(c=c.replace(new RegExp(z,"g"),v[z](d)));c=c.replace(/\0\0/g,"%");z=Jc(c);if(z.length>b)return 0;Kc(z,a);return z.length-1}function Qb(a,b,c,d){return Pb(a>>>0,b>>>0,c>>>0,d>>>0)}C||fc();
60
+ var xc=[Ob,dc,qc,Wa,Xa,Ya,Za,$a,ab,bb,cb,db,eb,fb,gb,hb,sb,tb,Hb,Ib,Kb,Lb,Mb,Nb],Sa,Z=function(){function a(c,d){Z=c.exports;Z=Lc();ec.push(Z.Ea);mc=Z.Fa;Ha.unshift(Z.$);Ea=d;Ka();return Z}var b=va();O++;if(w.instantiateWasm)try{return w.instantiateWasm(b,a)}catch(c){I(`Module.instantiateWasm callback failed with error: ${c}`),x(c)}Na||=w.locateFile?Ma("ort-wasm-simd-threaded.wasm")?"ort-wasm-simd-threaded.wasm":w.locateFile?w.locateFile("ort-wasm-simd-threaded.wasm",F):F+"ort-wasm-simd-threaded.wasm":
61
+ (new URL("ort-wasm-simd-threaded.wasm",import.meta.url)).href;Ra(b,function(c){a(c.instance,c.module)}).catch(x);return{}}();w._OrtInit=(a,b)=>(w._OrtInit=Z.aa)(a,b);w._OrtGetLastError=(a,b)=>(w._OrtGetLastError=Z.ba)(a,b);w._OrtCreateSessionOptions=(a,b,c,d,f,h,k,q,y,v)=>(w._OrtCreateSessionOptions=Z.ca)(a,b,c,d,f,h,k,q,y,v);w._OrtAppendExecutionProvider=(a,b)=>(w._OrtAppendExecutionProvider=Z.da)(a,b);w._OrtAddFreeDimensionOverride=(a,b,c)=>(w._OrtAddFreeDimensionOverride=Z.ea)(a,b,c);
62
+ w._OrtAddSessionConfigEntry=(a,b,c)=>(w._OrtAddSessionConfigEntry=Z.fa)(a,b,c);w._OrtReleaseSessionOptions=a=>(w._OrtReleaseSessionOptions=Z.ga)(a);w._OrtCreateSession=(a,b,c)=>(w._OrtCreateSession=Z.ha)(a,b,c);w._OrtReleaseSession=a=>(w._OrtReleaseSession=Z.ia)(a);w._OrtGetInputOutputCount=(a,b,c)=>(w._OrtGetInputOutputCount=Z.ja)(a,b,c);w._OrtGetInputName=(a,b)=>(w._OrtGetInputName=Z.ka)(a,b);w._OrtGetOutputName=(a,b)=>(w._OrtGetOutputName=Z.la)(a,b);w._OrtFree=a=>(w._OrtFree=Z.ma)(a);
63
+ w._OrtCreateTensor=(a,b,c,d,f,h)=>(w._OrtCreateTensor=Z.na)(a,b,c,d,f,h);w._OrtGetTensorData=(a,b,c,d,f)=>(w._OrtGetTensorData=Z.oa)(a,b,c,d,f);w._OrtReleaseTensor=a=>(w._OrtReleaseTensor=Z.pa)(a);w._OrtCreateRunOptions=(a,b,c,d)=>(w._OrtCreateRunOptions=Z.qa)(a,b,c,d);w._OrtAddRunConfigEntry=(a,b,c)=>(w._OrtAddRunConfigEntry=Z.ra)(a,b,c);w._OrtReleaseRunOptions=a=>(w._OrtReleaseRunOptions=Z.sa)(a);w._OrtCreateBinding=a=>(w._OrtCreateBinding=Z.ta)(a);
64
+ w._OrtBindInput=(a,b,c)=>(w._OrtBindInput=Z.ua)(a,b,c);w._OrtBindOutput=(a,b,c,d)=>(w._OrtBindOutput=Z.va)(a,b,c,d);w._OrtClearBoundOutputs=a=>(w._OrtClearBoundOutputs=Z.wa)(a);w._OrtReleaseBinding=a=>(w._OrtReleaseBinding=Z.xa)(a);w._OrtRunWithBinding=(a,b,c,d,f)=>(w._OrtRunWithBinding=Z.ya)(a,b,c,d,f);w._OrtRun=(a,b,c,d,f,h,k,q)=>(w._OrtRun=Z.za)(a,b,c,d,f,h,k,q);w._OrtEndProfiling=a=>(w._OrtEndProfiling=Z.Aa)(a);var K=()=>(K=Z.Ba)();w._malloc=a=>(w._malloc=Z.Ca)(a);w._free=a=>(w._free=Z.Da)(a);
65
+ var wa=(a,b,c,d,f,h)=>(wa=Z.Ga)(a,b,c,d,f,h),Da=()=>(Da=Z.Ha)(),bc=(a,b,c,d,f)=>(bc=Z.Ia)(a,b,c,d,f),hc=a=>(hc=Z.Ja)(a),Ba=a=>(Ba=Z.Ka)(a),vc=()=>(vc=Z.La)(),kc=(a,b)=>(kc=Z.Ma)(a,b),cc=a=>(cc=Z.Na)(a),ac=a=>(ac=Z.Oa)(a),$b=()=>($b=Z.Pa)();w.___start_em_js=822530;w.___stop_em_js=822591;
66
+ function Lc(){var a=Z;a=Object.assign({},a);var b=d=>()=>d()>>>0,c=d=>f=>d(f)>>>0;a.Ba=b(a.Ba);a.Ca=c(a.Ca);a.emscripten_main_runtime_thread_id=b(a.emscripten_main_runtime_thread_id);a.Oa=c(a.Oa);a.Pa=b(a.Pa);return a}w.stackSave=()=>$b();w.stackRestore=a=>cc(a);w.stackAlloc=a=>ac(a);w.UTF8ToString=Q;w.stringToUTF8=W;w.lengthBytesUTF8=tc;var Mc;P=function Nc(){Mc||Oc();Mc||(P=Nc)};
67
+ function Oc(){0<O||(C?(ha(w),C||jc(Ha),startWorker(w)):(jc(Ga),0<O||Mc||(Mc=!0,w.calledRun=!0,Fa||(C||jc(Ha),ha(w),C||jc(Ia)))))}Oc();moduleRtn=ia;
68
+
69
+
70
+ return moduleRtn;
71
+ }
72
+ );
73
+ })();
74
+ export default ortWasmThreaded;
75
+ var isPthread = globalThis.self?.name === 'em-pthread';
76
+ var isNode = typeof globalThis.process?.versions?.node == 'string';
77
+ if (isNode) isPthread = (await import('worker_threads')).workerData === 'em-pthread';
78
+
79
+ // When running as a pthread, construct a new instance on startup
80
+ isPthread && ortWasmThreaded();
js-esm/ort-wasm-simd-threaded.wasm ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9a5219201ef1b107170a042bfe91ae128f9d6736b7b061a3eef299a23d813569
3
+ size 11018122
js-esm/ort.min.js ADDED
The diff for this file is too large to render. See raw diff
 
js-esm/ort.min.js.map ADDED
The diff for this file is too large to render. See raw diff
 
js-esm/text_to_arpa.js ADDED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { pipeline, env } from 'https://cdn.jsdelivr.net/npm/@xenova/transformers@2.17.2';
2
+
3
+
4
+ async function text2text_generation(words,convert_ipa=false) {
5
+ const generator = await pipeline('text2text-generation', 'mini-bart-g2p',{quantized: false});
6
+ const inputTexts = words;
7
+ const options = { max_new_tokens: 100 };
8
+ const outputs = await generator(inputTexts, options);
9
+
10
+ if (convert_ipa){
11
+ const ipas = []
12
+ outputs.forEach(output => {
13
+ const ipa = arpa_to_ipa(output.generated_text).replace(/\s/g, "")
14
+ ipas.push(ipa)
15
+ });
16
+ return ipas
17
+ }else{
18
+ return outputs //arpa
19
+ }
20
+
21
+ }
22
+
23
+
24
+ async function textToArpa(cmudict,text,replace_questions=false){
25
+ if (replace_questions){
26
+ text = text.replaceAll("!",".").replaceAll("?",".")
27
+ }
28
+ const cleanedString = text.replace(/[^a-zA-Z0-9.,!? ]/g, '');
29
+
30
+ const dict = wordsToArpa(cmudict,cleanedString)
31
+
32
+
33
+
34
+ const result = dict["result"]
35
+ const non_converted = dict["non_converted"]
36
+
37
+ let arpa_text = result.join(" ");
38
+
39
+ //console.log(non_converted.length)
40
+ if (non_converted.length > 0){
41
+ console.log("non_converted length = "+non_converted.length)
42
+ const arpas = await text2text_generation(non_converted)
43
+ console.log(arpas)
44
+ for (let i = 0; i < non_converted.length; i++) {
45
+ const word = non_converted[i]
46
+ const arpa = arpas[i].generated_text
47
+ console.log("@"+word,arpa)
48
+ arpa_text = arpa_text.replace("@"+word,arpa)
49
+ }
50
+ }
51
+ return arpa_text
52
+
53
+ }
54
+
55
+ function get_arpa(cmudict,word){
56
+ return cmudict[word.toUpperCase()]
57
+ }
58
+
59
+ function wordsToArpa(cmudict,text){
60
+ var keep_words = [",",".","!","?"]
61
+ let inputText = text.toUpperCase()
62
+ keep_words.forEach(function(key){
63
+ inputText = inputText.replaceAll(key," "+key+" ");
64
+ });
65
+ //console.log(`replaced ${inputText}`)
66
+
67
+ let result = []
68
+ let non_converted = []
69
+ var words = inputText.split(" ")
70
+
71
+ words.forEach(word => {
72
+
73
+ if (keep_words.includes(word)){//,.!? just keep
74
+ result.push(word)
75
+ }else if (word ==""){
76
+
77
+ }else{
78
+ const arpa = get_arpa(cmudict,word)
79
+
80
+ if (typeof arpa == "undefined"){
81
+ result.push("@"+word)
82
+ non_converted.push(word)
83
+ }else{
84
+ result.push(arpa)
85
+ }
86
+ }
87
+ });
88
+
89
+ return {"result":result,"non_converted":non_converted}
90
+ }
91
+
92
+ export{env,textToArpa}
js-esm/web_wav_play.js ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+
3
+ function webWavPlay(f32array){
4
+ const blob = float32ArrayToWav(f32array)
5
+ const url = createObjectUrlFromBlob(blob)
6
+ playAudioFromUrl(url)
7
+ return blob
8
+ }
9
+
10
+ function createObjectUrlFromBlob(blob) {
11
+ const url = URL.createObjectURL(blob);
12
+ return url;
13
+ }
14
+
15
+ function playAudioFromUrl(url) {
16
+ const audio = new Audio(url);
17
+ audio.play().catch(error => console.error('Failed to play audio:', error));
18
+ }
19
+
20
+
21
+ //I copied
22
+ //https://huggingface.co/spaces/k2-fsa/web-assembly-tts-sherpa-onnx-de/blob/main/app-tts.js
23
+ // this function is copied/modified from
24
+ // https://gist.github.com/meziantou/edb7217fddfbb70e899e
25
+ function float32ArrayToWav(floatSamples, sampleRate=22050) {
26
+ let samples = new Int16Array(floatSamples.length);
27
+ for (let i = 0; i < samples.length; ++i) {
28
+ let s = floatSamples[i];
29
+ if (s >= 1)
30
+ s = 1;
31
+ else if (s <= -1)
32
+ s = -1;
33
+
34
+ samples[i] = s * 32767;
35
+ }
36
+
37
+ let buf = new ArrayBuffer(44 + samples.length * 2);
38
+ var view = new DataView(buf);
39
+
40
+ // http://soundfile.sapp.org/doc/WaveFormat/
41
+ // F F I R
42
+ view.setUint32(0, 0x46464952, true); // chunkID
43
+ view.setUint32(4, 36 + samples.length * 2, true); // chunkSize
44
+ // E V A W
45
+ view.setUint32(8, 0x45564157, true); // format
46
+ //
47
+ // t m f
48
+ view.setUint32(12, 0x20746d66, true); // subchunk1ID
49
+ view.setUint32(16, 16, true); // subchunk1Size, 16 for PCM
50
+ view.setUint32(20, 1, true); // audioFormat, 1 for PCM
51
+ view.setUint16(22, 1, true); // numChannels: 1 channel
52
+ view.setUint32(24, sampleRate, true); // sampleRate
53
+ view.setUint32(28, sampleRate * 2, true); // byteRate
54
+ view.setUint16(32, 2, true); // blockAlign
55
+ view.setUint16(34, 16, true); // bitsPerSample
56
+ view.setUint32(36, 0x61746164, true); // Subchunk2ID
57
+ view.setUint32(40, samples.length * 2, true); // subchunk2Size
58
+
59
+ let offset = 44;
60
+ for (let i = 0; i < samples.length; ++i) {
61
+ view.setInt16(offset, samples[i], true);
62
+ offset += 2;
63
+ }
64
+
65
+ return new Blob([view], {type: 'audio/wav'});
66
+ }
67
+
68
+ export { webWavPlay };
matcha_tts_speak_en001.html ADDED
@@ -0,0 +1,123 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <title>Match-TTS Onnx En001-English</title>
6
+ </head>
7
+ <body>
8
+ <h1>Match-TTS Onnx En001-English(Faster GPU Version)</h1>
9
+ <div>this example using Quantized version(lowquality and slow) because of Github Page 100MB limitation</div>
10
+ <p><a href = "https://huggingface.co/Akjava/matcha_tts_common_voice_01_en_001">common_voice_01_en_001</a> - my trained model.you can create too!</p>
11
+ <br>
12
+ <script src="https://cdn.jsdelivr.net/npm/onnxruntime-web/dist/ort.webgpu.min.js" ></script>
13
+
14
+
15
+ <script type="module">
16
+ import { MatchaTTSRaw } from "./js-esm/matcha_tts_raw.js";
17
+ import { webWavPlay } from "./js-esm/web_wav_play.js";
18
+ import { arpa_to_ipa } from "./js-esm/arpa_to_ipa.js";
19
+ import { loadCmudict } from "./js-esm/cmudict_loader.js";
20
+ import { env,textToArpa} from "./js-esm/text_to_arpa.js";
21
+
22
+ env.allowLocalModels = true;
23
+ env.localModelPath = "./models/";
24
+ env.backends.onnx.logLevel = "fatal";
25
+
26
+ let matcha_tts_raw
27
+ let cmudict ={}
28
+ let speaking = false
29
+ async function main() {
30
+ if (speaking){
31
+ console.log("speaking return")
32
+ }
33
+ speaking = true
34
+ console.log("main called")
35
+ if(!matcha_tts_raw){
36
+ matcha_tts_raw = new MatchaTTSRaw()
37
+ console.time("load model");
38
+ await matcha_tts_raw.load_model('./models/matcha-tts/en001_ep6399_univ_simplify_q8.onnx',{ executionProviders: ['webgpu','wasm'] });
39
+
40
+ console.timeEnd("load model");
41
+
42
+ let cmudictReady = loadCmudict(cmudict,'./dictionaries/cmudict-0.7b')
43
+ await cmudictReady
44
+
45
+ }else{
46
+ console.log("session exist skip load model")
47
+ }
48
+ const text = document.getElementById('textInput').value
49
+ const arpa_text = await textToArpa(cmudict,text)
50
+ const ipa_text = arpa_to_ipa(arpa_text).replace(/\s/g, "");
51
+ console.log(ipa_text)
52
+
53
+ const spks = 0
54
+ const speed = document.getElementById('speed').value
55
+ const tempature = document.getElementById('temperature').value
56
+
57
+ console.time("infer");
58
+ const result = await matcha_tts_raw.infer(ipa_text, tempature, speed,spks);
59
+ console.timeEnd("infer");
60
+ if (result!=null){
61
+ webWavPlay(result)
62
+
63
+ }
64
+
65
+ speaking = false
66
+ }
67
+ function update_range(){
68
+ const value = document.getElementById('spks').value
69
+ let formattedNumber = value.toString().padStart(3, '0');
70
+ document.getElementById('spks_label').textContent = formattedNumber
71
+ }
72
+ function update_range2(){
73
+ const value = document.getElementById('temperature').value
74
+ //let formattedNumber = value.toString().padStart(3, '0');
75
+ document.getElementById('tempature_label').textContent = value//formattedNumber
76
+ }
77
+ function update_range3(){
78
+ const value = document.getElementById('speed').value
79
+ //let formattedNumber = value.toString().padStart(3, '0');
80
+ document.getElementById('speed_label').textContent = value//sformattedNumber
81
+ }
82
+
83
+ window.onload = async function(){
84
+ document.getElementById('textInput').onchange = main;
85
+ document.getElementById('myButton').onclick = main;
86
+
87
+ document.getElementById('temperature').onchange = update_range2
88
+ document.getElementById('speed').onchange = update_range3
89
+ }
90
+
91
+
92
+ </script>
93
+
94
+ <input type="text" id="textInput" value ="Hello." placeholder="Enter some text here...">
95
+
96
+ <button id="myButton">Text To Speak</button><br>
97
+
98
+
99
+ <label for ="temperature" style="width: 110px;display: inline-block;">Temperature</label>
100
+ <input type="range" id="temperature" min="0" max="1.0" value="0.5" step="0.1"/>
101
+ <label for ="temperature" id="tempature_label">0.5</label><br>
102
+
103
+ <label for ="speed" style="width: 110px;display: inline-block;">Speed</label>
104
+ <input type="range" id="speed" min="0.1" max="2.0" value="1.0" step="0.1"/>
105
+ <label for ="speed" id="speed_label">1.0</label>
106
+ <br>
107
+ <br>
108
+ <div id="footer">
109
+ <b>Credits</b><br>
110
+ <a href="https://github.com/akjava/Matcha-TTS-Japanese" style="font-size: 9px" target="link">Matcha-TTS-Japanese</a> |
111
+ <a href = "http://www.udialogue.org/download/cstr-vctk-corpus.html" style="font-size: 9px" target="link">CSTR VCTK Corpus</a> |
112
+ <a href = "https://github.com/cmusphinx/cmudict" style="font-size: 9px" target="link">CMUDict</a> |
113
+ <a href = "https://huggingface.co/docs/transformers.js/index" style="font-size: 9px" target="link">Transformer.js</a> |
114
+ <a href = "https://huggingface.co/cisco-ai/mini-bart-g2p" style="font-size: 9px" target="link">mini-bart-g2p</a> |
115
+ <a href = "https://onnxruntime.ai/docs/get-started/with-javascript/web.html" style="font-size: 9px" target="link">ONNXRuntime-Web</a> |
116
+ <a href = "https://github.com/akjava/English-To-IPA-Collections" style="font-size: 9px" target="link">English-To-IPA-Collections</a> |
117
+ <a href ="https://huggingface.co/papers/2309.03199" style="font-size: 9px" target="link">Matcha-TTS Paper</a>
118
+ </div>
119
+
120
+
121
+
122
+ </body>
123
+ </html>
models/matcha-tts/en001_ep6399_univ_simplify_q8.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:099b031fbd30e993268800f94996c3b6eca6b1bd99762dae65a9ab246178c505
3
+ size 40571491
models/matcha-tts/ljspeech_sim_q8.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:68a5a21d82e2a759bc9217e8ed989142943839feb1355c72b59e73b4b0f638e8
3
+ size 40571490
models/matcha-tts/vctk_t2_simplify.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e246cf870d0d2b3eebda1679a6041a1cce6e18891675dd5d9db75675e344168c
3
+ size 129268532
models/matcha-tts/vctk_t2_simplify_q8.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0c3a8587e792275725ad42f72992a16b89eeff6ad9b83b48368c2ca0f9cd7585
3
+ size 43168516
models/matcha-tts/vctk_univ_simplify.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1a70a6eca480c62f851e5508947fdb3a61d98666a9ad98ca77f7193aca376fd2
3
+ size 129268532
models/matcha-tts/vctk_univ_simplify_q8.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:84753ce259d950725007de2a40af23d3fb52331b7167f7f816a2f2c0d202ea3a
3
+ size 43168515
models/mini-bart-g2p/LICENSE ADDED
@@ -0,0 +1,201 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
models/mini-bart-g2p/config.json ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "outputs_config_10",
3
+ "activation_dropout": 0.1,
4
+ "activation_function": "gelu",
5
+ "add_cross_attention": true,
6
+ "architectures": [
7
+ "BartForConditionalGeneration"
8
+ ],
9
+ "attention_dropout": 0.1,
10
+ "bos_token_id": 0,
11
+ "classifier_dropout": 0.0,
12
+ "cross_attention_hidden_size": 256,
13
+ "d_model": 256,
14
+ "decoder_attention_heads": 4,
15
+ "decoder_ffn_dim": 512,
16
+ "decoder_layerdrop": 0.1,
17
+ "decoder_layers": 3,
18
+ "decoder_start_token_id": 2,
19
+ "dropout": 0.3,
20
+ "encoder_attention_heads": 4,
21
+ "encoder_ffn_dim": 512,
22
+ "encoder_layerdrop": 0.1,
23
+ "encoder_layers": 3,
24
+ "eos_token_id": 2,
25
+ "forced_eos_token_id": 2,
26
+ "id2label": {
27
+ "0": "LABEL_0",
28
+ "1": "LABEL_1",
29
+ "2": "LABEL_2"
30
+ },
31
+ "init_std": 0.02,
32
+ "is_encoder_decoder": true,
33
+ "label2id": {
34
+ "LABEL_0": 0,
35
+ "LABEL_1": 1,
36
+ "LABEL_2": 2
37
+ },
38
+ "max_length": 128,
39
+ "max_position_embeddings": 128,
40
+ "model_type": "bart",
41
+ "num_hidden_layers": 3,
42
+ "pad_token_id": 1,
43
+ "scale_embedding": true,
44
+ "transformers_version": "4.28.0.dev0",
45
+ "use_cache": true,
46
+ "vocab_size": 103
47
+ }
models/mini-bart-g2p/decoder_model_merged.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:dfdbe66a7c5876074c6fe12d50fb5ddfd8134f7c424cc7bb544d0cb46a2e3c7b
3
+ size 10090299
models/mini-bart-g2p/encoder_model.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8d9aae528c64a7d81d793a394b4b71ea22106cc01ff5efd13c3fd19bc6854927
3
+ size 6629277
models/mini-bart-g2p/generation_config.json ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token_id": 0,
3
+ "decoder_start_token_id": 2,
4
+ "eos_token_id": 2,
5
+ "forced_eos_token_id": 2,
6
+ "max_length": 128,
7
+ "pad_token_id": 1,
8
+ "transformers_version": "4.28.0.dev0"
9
+ }
models/mini-bart-g2p/onnx/decoder_model_merged.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:dfdbe66a7c5876074c6fe12d50fb5ddfd8134f7c424cc7bb544d0cb46a2e3c7b
3
+ size 10090299
models/mini-bart-g2p/onnx/encoder_model.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8d9aae528c64a7d81d793a394b4b71ea22106cc01ff5efd13c3fd19bc6854927
3
+ size 6629277
models/mini-bart-g2p/tokenizer.json ADDED
@@ -0,0 +1,191 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "version": "1.0",
3
+ "truncation": {
4
+ "direction": "Right",
5
+ "max_length": 128,
6
+ "strategy": "LongestFirst",
7
+ "stride": 0
8
+ },
9
+ "padding": null,
10
+ "added_tokens": [
11
+ {
12
+ "id": 0,
13
+ "content": "<s>",
14
+ "single_word": false,
15
+ "lstrip": false,
16
+ "rstrip": false,
17
+ "normalized": false,
18
+ "special": true
19
+ },
20
+ {
21
+ "id": 1,
22
+ "content": "<pad>",
23
+ "single_word": false,
24
+ "lstrip": false,
25
+ "rstrip": false,
26
+ "normalized": false,
27
+ "special": true
28
+ },
29
+ {
30
+ "id": 2,
31
+ "content": "</s>",
32
+ "single_word": false,
33
+ "lstrip": false,
34
+ "rstrip": false,
35
+ "normalized": false,
36
+ "special": true
37
+ },
38
+ {
39
+ "id": 3,
40
+ "content": "<unk>",
41
+ "single_word": false,
42
+ "lstrip": false,
43
+ "rstrip": false,
44
+ "normalized": false,
45
+ "special": true
46
+ },
47
+ {
48
+ "id": 4,
49
+ "content": "<mask>",
50
+ "single_word": false,
51
+ "lstrip": true,
52
+ "rstrip": false,
53
+ "normalized": false,
54
+ "special": true
55
+ }
56
+ ],
57
+ "normalizer": {
58
+ "type": "Lowercase"
59
+ },
60
+ "pre_tokenizer": {
61
+ "type": "Split",
62
+ "pattern": {
63
+ "String": ""
64
+ },
65
+ "behavior": "Removed",
66
+ "invert": false
67
+ },
68
+ "post_processor": {
69
+ "type": "RobertaProcessing",
70
+ "sep": [
71
+ "</s>",
72
+ 2
73
+ ],
74
+ "cls": [
75
+ "<s>",
76
+ 0
77
+ ],
78
+ "trim_offsets": true,
79
+ "add_prefix_space": false
80
+ },
81
+ "decoder": null,
82
+ "model": {
83
+ "type": "WordLevel",
84
+ "vocab": {
85
+ "<s>": 0,
86
+ "<pad>": 1,
87
+ "</s>": 2,
88
+ "<unk>": 3,
89
+ "<mask>": 4,
90
+ "e": 5,
91
+ "a": 6,
92
+ "s": 7,
93
+ "i": 8,
94
+ "r": 9,
95
+ "n": 10,
96
+ "AH0": 11,
97
+ "o": 12,
98
+ "N": 13,
99
+ "t": 14,
100
+ "l": 15,
101
+ "S": 16,
102
+ "L": 17,
103
+ "T": 18,
104
+ "R": 19,
105
+ "K": 20,
106
+ "c": 21,
107
+ "d": 22,
108
+ "D": 23,
109
+ "u": 24,
110
+ "IH0": 25,
111
+ "m": 26,
112
+ "M": 27,
113
+ "Z": 28,
114
+ "h": 29,
115
+ "g": 30,
116
+ "p": 31,
117
+ "ER0": 32,
118
+ "IY0": 33,
119
+ "b": 34,
120
+ "B": 35,
121
+ "P": 36,
122
+ "EH1": 37,
123
+ "AE1": 38,
124
+ "AA1": 39,
125
+ "y": 40,
126
+ "k": 41,
127
+ "IH1": 42,
128
+ "F": 43,
129
+ "f": 44,
130
+ "G": 45,
131
+ "w": 46,
132
+ "V": 47,
133
+ "v": 48,
134
+ "NG": 49,
135
+ "'": 50,
136
+ "IY1": 51,
137
+ "EY1": 52,
138
+ "HH": 53,
139
+ "W": 54,
140
+ "SH": 55,
141
+ "OW1": 56,
142
+ "AO1": 57,
143
+ "OW0": 58,
144
+ "AH1": 59,
145
+ "UW1": 60,
146
+ "AY1": 61,
147
+ "JH": 62,
148
+ "z": 63,
149
+ "CH": 64,
150
+ "Y": 65,
151
+ "AA0": 66,
152
+ "ER1": 67,
153
+ "EH2": 68,
154
+ "IH2": 69,
155
+ "TH": 70,
156
+ "AY2": 71,
157
+ "AE2": 72,
158
+ "EY2": 73,
159
+ "AA2": 74,
160
+ "EH0": 75,
161
+ "j": 76,
162
+ "AW1": 77,
163
+ "OW2": 78,
164
+ "x": 79,
165
+ "IY2": 80,
166
+ "UW0": 81,
167
+ "AO2": 82,
168
+ "UH1": 83,
169
+ "AE0": 84,
170
+ "q": 85,
171
+ "AO0": 86,
172
+ "AH2": 87,
173
+ "UW2": 88,
174
+ "AY0": 89,
175
+ "OY1": 90,
176
+ "-": 91,
177
+ "EY0": 92,
178
+ "DH": 93,
179
+ "AW2": 94,
180
+ "ER2": 95,
181
+ "ZH": 96,
182
+ "UH2": 97,
183
+ "AW0": 98,
184
+ "UH0": 99,
185
+ "OY2": 100,
186
+ "OY0": 101,
187
+ ".": 102
188
+ },
189
+ "unk_token": "<unk>"
190
+ }
191
+ }
models/mini-bart-g2p/tokenizer_config.json ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_prefix_space": false,
3
+ "bos_token": "<s>",
4
+ "clean_up_tokenization_spaces": true,
5
+ "cls_token": "<s>",
6
+ "eos_token": "</s>",
7
+ "errors": "replace",
8
+ "mask_token": "<mask>",
9
+ "model_max_length": 1000000000000000019884624838656,
10
+ "pad_token": "<pad>",
11
+ "sep_token": "</s>",
12
+ "special_tokens_map_file": null,
13
+ "tokenizer_class": "BartTokenizer",
14
+ "trim_offsets": true,
15
+ "unk_token": "<unk>"
16
+ }