@met4citizen/headtts 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/modules/headtts.mjs +4 -2
- package/modules/language.mjs +5 -2
- package/package.json +3 -3
package/modules/headtts.mjs
CHANGED
|
@@ -516,7 +516,7 @@ class HeadTTS {
|
|
|
516
516
|
while( this.queueOut.length ) {
|
|
517
517
|
const item = this.queueOut[0];
|
|
518
518
|
this.queueOut.shift();
|
|
519
|
-
this.items.delete( item.message.
|
|
519
|
+
this.items.delete( item.message.ref );
|
|
520
520
|
clearItem(item);
|
|
521
521
|
}
|
|
522
522
|
|
|
@@ -824,6 +824,7 @@ class HeadTTS {
|
|
|
824
824
|
// Marked ready and add to output queue
|
|
825
825
|
item.status = 2;
|
|
826
826
|
this.items.set( item.message.id, item );
|
|
827
|
+
item.message.ref = item.message.id;
|
|
827
828
|
this.queueOut.push(item);
|
|
828
829
|
|
|
829
830
|
// Emit start event, if out queue was empty
|
|
@@ -837,6 +838,7 @@ class HeadTTS {
|
|
|
837
838
|
|
|
838
839
|
// Add to output queue to wait for response
|
|
839
840
|
this.items.set( item.message.id, item );
|
|
841
|
+
item.message.ref = item.message.id;
|
|
840
842
|
this.queueOut.push(item);
|
|
841
843
|
|
|
842
844
|
|
|
@@ -1004,7 +1006,7 @@ class HeadTTS {
|
|
|
1004
1006
|
const item = this.queueOut[0];
|
|
1005
1007
|
if ( item.status < 2 ) break; // First item not yet ready
|
|
1006
1008
|
this.queueOut.shift();
|
|
1007
|
-
this.items.delete( item.message.
|
|
1009
|
+
this.items.delete( item.message.ref );
|
|
1008
1010
|
|
|
1009
1011
|
const message = item.message;
|
|
1010
1012
|
Object.assign(message.data, item.metadata || {});
|
package/modules/language.mjs
CHANGED
|
@@ -68,6 +68,9 @@ class LanguageBase {
|
|
|
68
68
|
"-": "-", "'": "'", ".": ".", ",": ","
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
+
// Grapheme segmenter
|
|
72
|
+
this.segmenter = new Intl.Segmenter('en', { granularity: 'grapheme' });
|
|
73
|
+
|
|
71
74
|
if ( this.settings.trace ) {
|
|
72
75
|
utils.trace( 'Language base module initiated.' );
|
|
73
76
|
}
|
|
@@ -166,7 +169,7 @@ class LanguageBase {
|
|
|
166
169
|
splitText(s) {
|
|
167
170
|
|
|
168
171
|
const parts = [];
|
|
169
|
-
const chars =
|
|
172
|
+
const chars = Array.from(this.segmenter.segment(s), seg => seg.segment);
|
|
170
173
|
const len = chars.length;
|
|
171
174
|
let i = 0;
|
|
172
175
|
let lastType = 0; // 0=unknown, 1=whitespace, 2=other
|
|
@@ -204,7 +207,7 @@ class LanguageBase {
|
|
|
204
207
|
*/
|
|
205
208
|
normalizeUpper(s) {
|
|
206
209
|
const norm = [];
|
|
207
|
-
const chars =
|
|
210
|
+
const chars = Array.from(this.segmenter.segment(s.toUpperCase()), seg => seg.segment);
|
|
208
211
|
const len = chars.length;
|
|
209
212
|
let i=0;
|
|
210
213
|
while( i<len ) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@met4citizen/headtts",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "HeadTTS: A free Javascript text-to-speech with timestamps and visemes.",
|
|
5
5
|
"main": "modules/headtts.mjs",
|
|
6
6
|
"type": "module",
|
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
"dictionaries/"
|
|
13
13
|
],
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@huggingface/transformers": "^3.
|
|
16
|
-
"ws": "^8.18.
|
|
15
|
+
"@huggingface/transformers": "^3.7.2",
|
|
16
|
+
"ws": "^8.18.3"
|
|
17
17
|
},
|
|
18
18
|
"scripts": {
|
|
19
19
|
"start": "node ./modules/headtts-node.mjs",
|