sentifyd-bot 1.2.0 → 1.3.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sentifyd-bot",
3
- "version": "1.2.0",
3
+ "version": "1.3.1",
4
4
  "description": "Sentifyd conversational AI chatbot with 3D avatar - npm package for React, Vue, and modern web frameworks",
5
5
  "type": "module",
6
6
  "main": "dist/index.es.js",
@@ -17,15 +17,21 @@
17
17
  "import": "./src/react/index.js",
18
18
  "default": "./src/react/index.js"
19
19
  },
20
+ "./vite-plugin": {
21
+ "import": "./src/vite-plugin.js",
22
+ "default": "./src/vite-plugin.js"
23
+ },
20
24
  "./package.json": "./package.json"
21
25
  },
22
26
  "files": [
23
27
  "dist/**/*",
24
28
  "src/react/**/*",
29
+ "src/vite-plugin.js",
25
30
  "src/index.d.ts",
26
31
  "src/react/index.d.ts",
27
32
  "README.md",
28
- "LICENSE.md"
33
+ "LICENSE.md",
34
+ "CHANGELOG.md"
29
35
  ],
30
36
  "keywords": [
31
37
  "chatbot",
@@ -42,6 +48,11 @@
42
48
  "bugs": {
43
49
  "email": "info@sentifyd.io"
44
50
  },
51
+ "repository": {
52
+ "type": "git",
53
+ "url": "git+https://github.com/Sentifyd/Sentifyd-frontend.git",
54
+ "directory": "npm-package"
55
+ },
45
56
  "author": "Sentifyd <info@sentifyd.io>",
46
57
  "license": "SEE LICENSE IN LICENSE.md",
47
58
  "homepage": "https://sentifyd.io",
@@ -59,12 +70,12 @@
59
70
  "js-cookie": "^3.0.5",
60
71
  "jwt-decode": "^4.0.0",
61
72
  "lit": "^3.3.1",
62
- "microsoft-cognitiveservices-speech-sdk": "^1.46.0",
73
+ "microsoft-cognitiveservices-speech-sdk": "^1.47.0",
63
74
  "socket.io-client": "^4.8.1",
64
- "three": "^0.180.0",
75
+ "@met4citizen/talkinghead": "^1.7.0",
65
76
  "toastify-js": "^1.12.0",
66
77
  "uuid": "^13.0.0",
67
- "xstate": "^5.23.0"
78
+ "xstate": "^5.25.0"
68
79
  },
69
80
  "peerDependencies": {
70
81
  "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
@@ -16,7 +16,7 @@ import { registerSentifydBot } from 'sentifyd-bot';
16
16
  *
17
17
  * @example
18
18
  * ```jsx
19
- * import { SentifydBot } from 'sentifyd-frontend/react';
19
+ * import { SentifydBot } from 'sentifyd-bot/react';
20
20
  *
21
21
  * function App() {
22
22
  * return (
@@ -0,0 +1,161 @@
1
+ /**
2
+ * Vite plugin for sentifyd-bot to handle @met4citizen/talkinghead module compatibility.
3
+ *
4
+ * The talkinghead library uses dynamic imports and Audio Worklets which require
5
+ * special handling in Vite's dev server. This plugin ensures the necessary files
6
+ * are available and properly served.
7
+ *
8
+ * Usage in consumer's vite.config.js:
9
+ *
10
+ * ```javascript
11
+ * import { sentifydBotPlugin } from 'sentifyd-bot/vite-plugin';
12
+ *
13
+ * export default defineConfig({
14
+ * plugins: [sentifydBotPlugin()]
15
+ * });
16
+ * ```
17
+ */
18
+
19
+ import { createRequire } from 'node:module';
20
+ import fs from 'node:fs';
21
+ import path from 'node:path';
22
+
23
+ /**
24
+ * Resolves the path to talkinghead's modules directory
25
+ * @returns {string} Path to modules directory
26
+ */
27
+ function getTalkingHeadModulesPath() {
28
+ const require = createRequire(import.meta.url);
29
+ try {
30
+ // Try to resolve from the consumer's node_modules first
31
+ const talkingheadPath = require.resolve('@met4citizen/talkinghead');
32
+ return path.join(path.dirname(talkingheadPath), '..', 'modules');
33
+ } catch {
34
+ // Fallback: look in parent directories
35
+ let currentDir = process.cwd();
36
+ while (currentDir !== path.dirname(currentDir)) {
37
+ const modulesPath = path.join(currentDir, 'node_modules', '@met4citizen', 'talkinghead', 'modules');
38
+ if (fs.existsSync(modulesPath)) {
39
+ return modulesPath;
40
+ }
41
+ currentDir = path.dirname(currentDir);
42
+ }
43
+ throw new Error('Could not find @met4citizen/talkinghead package. Please install it.');
44
+ }
45
+ }
46
+
47
+ /**
48
+ * Files from talkinghead that need special handling
49
+ */
50
+ const TALKINGHEAD_FILES = [
51
+ 'playback-worklet.js',
52
+ 'lipsync-de.mjs',
53
+ 'lipsync-en.mjs',
54
+ 'lipsync-fi.mjs',
55
+ 'lipsync-fr.mjs',
56
+ 'lipsync-lt.mjs',
57
+ ];
58
+
59
+ /**
60
+ * Vite plugin that handles talkinghead's dynamic modules and audio worklet
61
+ * @param {Object} options - Plugin options
62
+ * @param {string[]} [options.languages] - Which lipsync languages to include (default: all)
63
+ * @returns {import('vite').Plugin}
64
+ */
65
+ export function sentifydBotPlugin(options = {}) {
66
+ const { languages } = options;
67
+
68
+ // Filter files based on languages option
69
+ const filesToCopy = TALKINGHEAD_FILES.filter(file => {
70
+ if (file === 'playback-worklet.js') return true;
71
+ if (!languages) return true;
72
+ const lang = file.match(/lipsync-(\w+)\.mjs/)?.[1];
73
+ return lang && languages.includes(lang);
74
+ });
75
+
76
+ let modulesPath;
77
+ let isServe = false;
78
+
79
+ return {
80
+ name: 'sentifyd-bot-plugin',
81
+
82
+ configResolved(config) {
83
+ isServe = config.command === 'serve';
84
+ try {
85
+ modulesPath = getTalkingHeadModulesPath();
86
+ } catch (e) {
87
+ console.warn('[sentifyd-bot] Warning:', e.message);
88
+ }
89
+ },
90
+
91
+ config(config) {
92
+ // Ensure talkinghead is excluded from dependency pre-bundling
93
+ // so it can load worklets via file URLs
94
+ return {
95
+ optimizeDeps: {
96
+ exclude: [...(config.optimizeDeps?.exclude || []), '@met4citizen/talkinghead'],
97
+ },
98
+ server: {
99
+ fs: {
100
+ // Allow serving files from node_modules/@met4citizen/talkinghead
101
+ allow: [...(config.server?.fs?.allow || []), '..', 'node_modules/@met4citizen/talkinghead'],
102
+ },
103
+ },
104
+ };
105
+ },
106
+
107
+ configureServer(server) {
108
+ if (!modulesPath) return;
109
+
110
+ // Serve talkinghead module files directly during development
111
+ server.middlewares.use((req, res, next) => {
112
+ const url = req.url || '';
113
+
114
+ // Handle requests for lipsync modules and worklet
115
+ for (const file of filesToCopy) {
116
+ if (url.endsWith(file) || url.includes(`/${file}`)) {
117
+ const filePath = path.join(modulesPath, file);
118
+ if (fs.existsSync(filePath)) {
119
+ const content = fs.readFileSync(filePath);
120
+ const contentType = file.endsWith('.mjs') ? 'application/javascript' : 'text/javascript';
121
+ res.setHeader('Content-Type', contentType);
122
+ res.setHeader('Cache-Control', 'no-cache');
123
+ res.end(content);
124
+ return;
125
+ }
126
+ }
127
+ }
128
+ next();
129
+ });
130
+ },
131
+
132
+ async buildStart() {
133
+ if (!modulesPath) {
134
+ try {
135
+ modulesPath = getTalkingHeadModulesPath();
136
+ } catch (e) {
137
+ this.warn(e.message);
138
+ }
139
+ }
140
+ },
141
+
142
+ generateBundle(_, bundle) {
143
+ if (!modulesPath) return;
144
+
145
+ // Copy talkinghead files to output during production build
146
+ for (const file of filesToCopy) {
147
+ const filePath = path.join(modulesPath, file);
148
+ if (fs.existsSync(filePath)) {
149
+ const content = fs.readFileSync(filePath);
150
+ this.emitFile({
151
+ type: 'asset',
152
+ fileName: file,
153
+ source: content,
154
+ });
155
+ }
156
+ }
157
+ },
158
+ };
159
+ }
160
+
161
+ export default sentifydBotPlugin;
@@ -1 +0,0 @@
1
- class e{constructor(){this.rules={A:["[AH]=aa","[AU]=aa U","[AI]=aa I","[AE]=E","[A]H=aa","[A]U=aa U","[A]I=aa I"," [AN] =aa nn"," [AM] =aa PP","[ARR]=aa RR","[AR]=aa RR"," [ALS]=aa nn SS","[AL]=aa nn","[AUCH]=aa U kk","[ABER]=aa PP E RR","[A]=aa"],"Ä":["[Ä]H=E","[ÄU]=O","[Ä]=E"],B:["[B]=PP"],C:["[CH]S=kk SS","[CH]=kk"," [CH]=kk","#[CH]=kk","[CK]=kk","[C]H=kk","[C]=kk"],D:[" [DAS] =DD aa SS"," [DEN] =DD E nn"," [DER] =DD E RR"," [DIE] =DD I"," [DU] =DD U"," [DURCH]=DD U RR kk","[D]=DD"],E:["[EI]=aa I","[EU]=O","[EH]=E"," [ER] =E RR"," [ES] =E SS"," [EIN] =aa I nn"," [EINE]=aa I nn aa","[ER]#=E","[ER]=E RR","[EN]#=aa nn","[E]=E"],F:["[F]=FF"],G:["[G]=kk"],H:[" [HAT] =I aa DD"," [HABEN]=I aa PP aa nn"," [HIER]=I I RR"," [HEUTE]=I O DD aa","[H]="],I:[" [ICH] =I kk"," [IHR] =I RR"," [IN] =I nn"," [IST] =I SS DD"," [IM] =I PP","[IE]=I","[IH]=I","[I]=I"],J:["[J]=I"],K:["[K]=kk"],L:["[L]=nn"],M:[" [MIT] =PP I DD"," [MAN] =PP aa nn"," [MEHR]=PP E RR"," [MICH]=PP I kk","[M]=PP"],N:[" [NICHT]=nn I kk DD"," [NUR] =nn U RR"," [NACH]=nn aa kk"," [NOCH]=nn aa kk","[NG]=nn kk","[N]=nn"],O:["[OO]=U","[OH]=O","[OU]=aa U"," [ODER]=O DD E RR"," [OHNE]=O nn aa","[Ö]=E","[O]=aa"],"Ö":["[ÖH]=E","[Ö]=E"],P:["[PF]=FF FF","[PH]=FF","[P]=PP"],Q:["[QU]=kk FF","[Q]=kk"],R:["[R]=RR"],S:["[SCH]=SS","[SP]=SS PP","[ST]=SS DD","[SS]=SS","[S]=SS"],"ß":["[ß]=SS"],T:["[TZ]=DD SS","[TH]=DD","[T]=DD"],U:[" [UND] =U nn DD"," [UM] =U PP"," [UNTER]=U nn DD E RR"," [UNS] =U nn SS","[UH]=U","[ÜH]=I U","[Ü]=I U","[U]=U"],"Ü":["[ÜH]=I U","[Ü]=I U"],V:[" [VON] =FF aa nn"," [VOR] =FF aa RR"," [VIEL]=FF I nn","[V]=FF"],W:[" [WAS] =FF aa SS"," [WIR] =FF I RR"," [WIE] =FF I"," [WENN]=FF E nn"," [WILL]=FF I nn"," [WO] =FF aa"," [WIEDER]=FF I DD E RR","[W]=FF"],X:["[X]=kk SS"],Y:["[Y]=I"],Z:[" [ZU] =DD SS U"," [ZUM] =DD SS U PP"," [ZUR] =DD SS U RR"," [ZEIT]=DD SS aa I DD","[Z]=DD SS"]};const e={"#":"[AEIOUÄÖÜ]+",".":"[BDVGJLMNRWZ]","%":"(?:ER|E|ES|ED|ING|ELY|EN|TE|ST)","&":"(?:[SCGZXJ]|CH|SCH|TZ)","@":"(?:[TSRDLZNJ]|TH|CH|SCH)","^":"[BCDFGHJKLMNPQRSTVWXYZß]","+":"[EIY]",":":"[BCDFGHJKLMNPQRSTVWXYZß]*"," ":"\\b"};Object.keys(this.rules).forEach((n=>{this.rules[n]=this.rules[n].map((n=>{const s=n.indexOf("["),t=n.indexOf("]"),i=n.indexOf("="),a=n.substring(0,s),r=n.substring(s+1,t),o=n.substring(t+1,i),h=n.substring(i+1),D={regex:"",move:0,visemes:[]};let u="";u+=[...a].map((n=>e[n]||n)).join("");const E=[...r];return E[0]=E[0].toLowerCase(),u+=E.join(""),D.move=E.length,u+=[...o].map((n=>e[n]||n)).join(""),D.regex=new RegExp(u),h.length&&h.split(" ").forEach((e=>{D.visemes.push(e)})),D}))})),this.visemeDurations={aa:1,E:.85,I:.9,O:1.05,U:1,PP:1.15,SS:1.2,TH:1,DD:1.1,FF:1.05,kk:1.25,nn:.85,RR:.9,sil:1},this.specialDurations={" ":1,",":3,"-":.5,"'":.5,".":4,"!":3,"?":3},this.digits=["null","eins","zwei","drei","vier","fünf","sechs","sieben","acht","neun"],this.ones=["","ein","zwei","drei","vier","fünf","sechs","sieben","acht","neun"],this.tens=["","","zwanzig","dreißig","vierzig","fünfzig","sechzig","siebzig","achtzig","neunzig"],this.teens=["zehn","elf","zwölf","dreizehn","vierzehn","fünfzehn","sechzehn","siebzehn","achtzehn","neunzehn"],this.symbols={"%":"prozent","€":"euro","&":"und","+":"plus",$:"dollar","=":"gleich","@":"at","#":"hashtag"},this.symbolsReg=/[%€&\+\$=@#]/g}convert_digit_by_digit(e){e=String(e).split("");let n="";for(let s=0;s<e.length;s++)n+=this.digits[e[s]]+" ";return n=n.substring(0,n.length-1),n}convert_millions(e){if(e>=1e6){const n=Math.floor(e/1e6),s=e%1e6;let t=this.convert_thousands(n);return t+=1===n?" million ":" millionen ",s>0&&(t+=this.convert_thousands(s)),t}return this.convert_thousands(e)}convert_thousands(e){if(e>=1e3){const n=Math.floor(e/1e3),s=e%1e3;let t="";return t=1===n?"eintausend":this.convert_hundreds(n)+"tausend",s>0&&(t+=this.convert_hundreds(s)),t}return this.convert_hundreds(e)}convert_hundreds(e){if(e>99){const n=Math.floor(e/100),s=e%100;let t="";return t=1===n?"einhundert":this.ones[n]+"hundert",s>0&&(t+=this.convert_tens(s)),t}return this.convert_tens(e)}convert_tens(e){if(e<10)return this.ones[Number(e)]||"";if(e>=10&&e<20)return this.teens[e-10];{const n=Math.floor(e/10),s=e%10;return 0===s?this.tens[n]:this.ones[s]+"und"+this.tens[n]}}convertNumberToWords(e){const n=String(e);return"0"==e?"null":n.startsWith("0")||4===n.length&&(e<1e3||e>2100)?this.convert_digit_by_digit(e):this.convert_millions(Number(e))}preProcessText(e){return e.replace(/[#_*\":;]/g,"").replace(this.symbolsReg,(e=>" "+this.symbols[e]+" ")).replace(/(\d)\.(\d)/g,"$1 komma $2").replace(/(\d),(\d)/g,"$1 komma $2").replace(/\d+/g,this.convertNumberToWords.bind(this)).replace(/(\D)\1\1+/g,"$1$1").replace(/\s+/g," ").toLowerCase().trim()}wordsToVisemes(e){let n={words:e.toUpperCase(),visemes:[],times:[],durations:[],i:0},s=0;const t=[...n.words];for(;n.i<t.length;){const e=t[n.i],i=this.rules[e];if(i){let t=!1;for(let a=0;a<i.length;a++){const r=i[a];if((n.words.substring(0,n.i)+e.toLowerCase()+n.words.substring(n.i+1)).match(r.regex)){r.visemes.forEach((e=>{if(n.visemes.length&&n.visemes[n.visemes.length-1]===e){const t=.7*(this.visemeDurations[e]||1);n.durations[n.durations.length-1]+=t,s+=t}else{const t=this.visemeDurations[e]||1;n.visemes.push(e),n.times.push(s),n.durations.push(t),s+=t}})),n.i+=r.move,t=!0;break}}t||(n.i++,s+=this.specialDurations[e]||0)}else n.i++,s+=this.specialDurations[e]||0}return n}}export{e as LipsyncDe};
@@ -1 +0,0 @@
1
- class t{constructor(){this.rules={A:["[A] =aa"," [ARE] =aa RR"," [AR]O=aa RR","[AR]#=E RR"," ^[AS]#=E SS","[A]WA=aa","[AW]=aa"," :[ANY]=E nn I","[A]^+#=E","#:[ALLY]=aa nn I"," [AL]#=aa nn","[AGAIN]=aa kk E nn","#:[AG]E=I kk","[A]^+:#=aa",":[A]^+ =E","[A]^%=E"," [ARR]=aa RR","[ARR]=aa RR"," :[AR] =aa RR","[AR] =E","[AR]=aa RR","[AIR]=E RR","[AI]=E","[AY]=E","[AU]=aa","#:[AL] =aa nn","#:[ALS] =aa nn SS","[ALK]=aa kk","[AL]^=aa nn"," :[ABLE]=E PP aa nn","[ABLE]=aa PP aa nn","[ANG]+=E nn kk","[A]=aa"],B:[" [BE]^#=PP I","[BEING]=PP I I nn"," [BOTH] =PP O TH"," [BUS]#=PP I SS","[BUIL]=PP I nn","[B]=PP"],C:[" [CH]^=kk","^E[CH]=kk","[CH]=CH"," S[CI]#=SS aa","[CI]A=SS","[CI]O=SS","[CI]EN=SS","[C]+=SS","[CK]=kk","[COM]%=kk aa PP","[C]=kk"],D:["#:[DED] =DD I DD",".E[D] =DD","#^:E[D] =DD"," [DE]^#=DD I"," [DO] =DD U"," [DOES]=DD aa SS"," [DOING]=DD U I nn"," [DOW]=DD aa","[DU]A=kk U","[D]=DD"],E:["#:[E] =","'^:[E] ="," :[E] =I","#[ED] =DD","#:[E]D =","[EV]ER=E FF","[E]^%=I","[ERI]#=I RR I","[ERI]=E RR I","#:[ER]#=E","[ER]#=E RR","[ER]=E"," [EVEN]=I FF E nn","#:[E]W=","@[EW]=U","[EW]=I U","[E]O=I","#:&[ES] =I SS","#:[E]S =","#:[ELY] =nn I","#:[EMENT]=PP E nn DD","[EFUL]=FF U nn","[EE]=I","[EARN]=E nn"," [EAR]^=E","[EAD]=E DD","#:[EA] =I aa","[EA]SU=E","[EA]=I","[EIGH]=E","[EI]=I"," [EYE]=aa","[EY]=I","[EU]=I U","[E]=E"],F:["[FUL]=FF U nn","[F]=FF"],G:["[GIV]=kk I FF"," [G]I^=kk","[GE]T=kk E","SU[GGES]=kk kk E SS","[GG]=kk"," B#[G]=kk","[G]+=kk","[GREAT]=kk RR E DD","#[GH]=","[G]=kk"],H:[" [HAV]=I aa FF"," [HERE]=I I RR"," [HOUR]=aa EE","[HOW]=I aa","[H]#=I","[H]="],I:[" [IN]=I nn"," [I] =aa","[IN]D=aa nn","[IER]=I E","#:R[IED] =I DD","[IED] =aa DD","[IEN]=I E nn","[IE]T=aa E"," :[I]%=aa","[I]%=I","[IE]=I","[I]^+:#=I","[IR]#=aa RR","[IZ]%=aa SS","[IS]%=aa SS","[I]D%=aa","+^[I]^+=I","[I]T%=aa","#^:[I]^+=I","[I]^+=aa","[IR]=E","[IGH]=aa","[ILD]=aa nn DD","[IGN] =aa nn","[IGN]^=aa nn","[IGN]%=aa nn","[IQUE]=I kk","[I]=I"],J:["[J]=kk"],K:[" [K]N=","[K]=kk"],L:["[LO]C#=nn O","L[L]=","#^:[L]%=aa nn","[LEAD]=nn I DD","[L]=nn"],M:["[MOV]=PP U FF","[M]=PP"],N:["E[NG]+=nn kk","[NG]R=nn kk","[NG]#=nn kk","[NGL]%=nn kk aa nn","[NG]=nn","[NK]=nn kk"," [NOW] =nn aa","[N]=nn"],O:["[OF] =aa FF","[OROUGH]=E O","#:[OR] =E","#:[ORS] =E SS","[OR]=aa RR"," [ONE]=FF aa nn","[OW]=O"," [OVER]=O FF E","[OV]=aa FF","[O]^%=O","[O]^EN=O","[O]^I#=O","[OL]D=O nn","[OUGHT]=aa DD","[OUGH]=aa FF"," [OU]=aa","H[OU]S#=aa","[OUS]=aa SS","[OUR]=aa RR","[OULD]=U DD","^[OU]^L=aa","[OUP]=U OO","[OU]=aa","[OY]=O","[OING]=O I nn","[OI]=O","[OOR]=aa RR","[OOK]=U kk","[OOD]=U DD","[OO]=U","[O]E=O","[O] =O","[OA]=O"," [ONLY]=O nn nn I"," [ONCE]=FF aa nn SS","[ON'T]=O nn DD","C[O]N=aa","[O]NG=aa"," ^:[O]N=aa","I[ON]=aa nn","#:[ON] =aa nn","#^[ON]=aa nn","[O]ST =O","[OF]^=aa FF","[OTHER]=aa TH E","[OSS] =aa SS","#^:[OM]=aa PP","[O]=aa"],P:["[PH]=FF","[PEOP]=PP I PP","[POW]=PP aa","[PUT] =PP U DD","[P]=PP"],Q:["[QUAR]=kk FF aa RR","[QU]=kk FF","[Q]=kk"],R:[" [RE]^#=RR I","[R]=RR"],S:["[SH]=SS","#[SION]=SS aa nn","[SOME]=SS aa PP","#[SUR]#=SS E","[SUR]#=SS E","#[SU]#=SS U","#[SSU]#=SS U","#[SED] =SS DD","#[S]#=SS","[SAID]=SS E DD","^[SION]=SS aa nn","[S]S=",".[S] =SS","#:.E[S] =SS","#^:##[S] =SS","#^:#[S] =SS","U[S] =SS"," :#[S] =SS"," [SCH]=SS kk","[S]C+=","#[SM]=SS PP","#[SN]'=SS aa nn","[S]=SS"],T:[" [THE] =TH aa","[TO] =DD U","[THAT] =TH aa DD"," [THIS] =TH I SS"," [THEY]=TH E"," [THERE]=TH E RR","[THER]=TH E","[THEIR]=TH E RR"," [THAN] =TH aa nn"," [THEM] =TH E PP","[THESE] =TH I SS"," [THEN]=TH E nn","[THROUGH]=TH RR U","[THOSE]=TH O SS","[THOUGH] =TH O"," [THUS]=TH aa SS","[TH]=TH","#:[TED] =DD I DD","S[TI]#N=CH","[TI]O=SS","[TI]A=SS","[TIEN]=SS aa nn","[TUR]#=CH E","[TU]A=CH U"," [TWO]=DD U","[T]=DD"],U:[" [UN]I=I U nn"," [UN]=aa nn"," [UPON]=aa PP aa nn","@[UR]#=U RR","[UR]#=I U RR","[UR]=E","[U]^ =aa","[U]^^=aa","[UY]=aa"," G[U]#=","G[U]%=","G[U]#=FF","#N[U]=I U","@[U]=I","[U]=I U"],V:["[VIEW]=FF I U","[V]=FF"],W:[" [WERE]=FF E","[WA]S=FF aa","[WA]T=FF aa","[WHERE]=FF E RR","[WHAT]=FF aa DD","[WHOL]=I O nn","[WHO]=I U","[WH]=FF","[WAR]=FF aa RR","[WOR]^=FF E","[WR]=RR","[W]=FF"],X:[" [X]=SS","[X]=kk SS"],Y:["[YOUNG]=I aa nn"," [YOU]=I U"," [YES]=I E SS"," [Y]=I","#^:[Y] =I","#^:[Y]I=I"," :[Y] =aa"," :[Y]#=aa"," :[Y]^+:#=I"," :[Y]^#=I","[Y]=I"],Z:["[Z]=SS"]};const t={"#":"[AEIOUY]+",".":"[BDVGJLMNRWZ]","%":"(?:ER|E|ES|ED|ING|ELY)","&":"(?:[SCGZXJ]|CH|SH)","@":"(?:[TSRDLZNJ]|TH|CH|SH)","^":"[BCDFGHJKLMNPQRSTVWXZ]","+":"[EIY]",":":"[BCDFGHJKLMNPQRSTVWXZ]*"," ":"\\b"};Object.keys(this.rules).forEach((e=>{this.rules[e]=this.rules[e].map((e=>{const n=e.indexOf("["),s=e.indexOf("]"),a=e.indexOf("="),i=e.substring(0,n),r=e.substring(n+1,s),o=e.substring(s+1,a),S=e.substring(a+1),E={regex:"",move:0,visemes:[]};let h="";h+=[...i].map((e=>t[e]||e)).join("");const I=[...r];return I[0]=I[0].toLowerCase(),h+=I.join(""),E.move=I.length,h+=[...o].map((e=>t[e]||e)).join(""),E.regex=new RegExp(h),S.length&&S.split(" ").forEach((t=>{E.visemes.push(t)})),E}))})),this.visemeDurations={aa:.95,E:.9,I:.92,O:.96,U:.95,PP:1.08,SS:1.23,TH:1,DD:1.05,FF:1,kk:1.21,nn:.88,RR:.88,DD:1.05,sil:1},this.specialDurations={" ":1,",":3,"-":.5,"'":.5},this.digits=["oh","one","two","three","four","five","six","seven","eight","nine"],this.ones=["","one","two","three","four","five","six","seven","eight","nine"],this.tens=["","","twenty","thirty","forty","fifty","sixty","seventy","eighty","ninety"],this.teens=["ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen"],this.decades={20:"twenties",30:"thirties",40:"forties",50:"fifties",60:"sixties",70:"seventies",80:"eighties",90:"nineties"},this.ordinals={1:"first",2:"second",3:"third",4:"fourth",5:"fifth",6:"sixth",7:"seventh",8:"eighth",9:"ninth",10:"tenth",11:"eleventh",12:"twelfth",13:"thirteenth",14:"fourteenth",15:"fifteenth",16:"sixteenth",17:"seventeeth",18:"eighteenth",19:"nineteenth",20:"twentieth",30:"thirtieth",40:"fortieth",50:"fiftieth",60:"sixtieth",70:"seventieth",80:"eightieth",90:"ninetieth"},this.symbols={"%":"percent","€":"euros","&":"and","+":"plus",$:"dollars"},this.symbolsReg=/[%€&\+\$]/g}convert_digit_by_digit(t){t=String(t).split("");let e="";for(let n=0;n<t.length;n++)e+=this.digits[t[n]]+" ";return e=e.substring(0,e.length-1),e}convert_sets_of_two(t){let e=String(t).substring(0,2),n=String(t).substring(2,4),s=this.convert_tens(e);return s+=" "+this.convert_tens(n),s}convert_millions(t){return t>=1e6?this.convert_millions(Math.floor(t/1e6))+" million "+this.convert_thousands(t%1e6):this.convert_thousands(t)}convert_thousands(t){return t>=1e3?this.convert_hundreds(Math.floor(t/1e3))+" thousand "+this.convert_hundreds(t%1e3):this.convert_hundreds(t)}convert_hundreds(t){return t>99?this.ones[Math.floor(t/100)]+" hundred "+this.convert_tens(t%100):this.convert_tens(t)}convert_tens(t){return t<10?(0!=Number(t)&&t.toString().startsWith("0")?"oh ":"")+this.ones[Number(t)]:t>=10&&t<20?this.teens[t-10]:(this.tens[Math.floor(t/10)]+" "+this.ones[t%10]).trim()}convertNumberToWords(t,e=!1){const n=parseFloat(t);if("0"==t)return"zero";if(t<0)return" minus "+this.convertNumberToWords(Math.abs(t).toString(),e).trim();if(n&&!Number.isInteger(n)){const t=n.toString().split(".");return this.convertNumberToWords(t[0],e).trim()+" point "+this.convert_digit_by_digit(t[1]).trim()}return t.toString().startsWith("0")||!e&&(t<1e3&&t>99&&t%100!=0||t>1e4&&t<1e6)?this.convert_digit_by_digit(t).trim():!e&&(t>1e3&&t<2e3||t>2009&&t<3e3)?t%100!=0?this.convert_sets_of_two(t).trim():this.convert_tens(t.toString().substring(0,2)).trim()+" hundred":this.convert_millions(t).trim()}convertDecade(t){const e=parseInt(t),n=!isNaN(e)&&2===t.length,s=!isNaN(e)&&t.length>2&&e>0&&e<=3e3,a=s&&e%1e3==0?Math.floor(e/1e3):null,i=s&&!a?Math.floor(e/100):null,r=n||s?10*Math.floor(e%100/10):null;let o=[];return a?o.push(this.convertNumberToWords(a).trim(),"thousands"):(i&&o.push(this.convertNumberToWords(i).trim()),r?o.push(this.decades[r]||this.convertNumberToWords(r).trim()+"s"):i?o.push("hundreds"):o.push(t)),o.join(" ")}convertOrdinal(t){if(this.ordinals.hasOwnProperty(t))return this.ordinals[t];const e=Math.floor(t/100),n=10*Math.floor(t%100/10),s=t%10;let a=[];return e&&(a.push(this.convertNumberToWords(e).trim()),n||s?a.push("hundred"):a.push("hundredth")),n&&(s?a.push(this.convertNumberToWords(n).trim()):a.push(this.ordinals[n])),s&&a.push(this.ordinals[s]),a.join(" ")}preProcessText(t){let e=t.replace('/[#_*":;]/g',"");return e=e.replace(this.symbolsReg,(t=>" "+this.symbols[t]+" ")),/\d/.test(e)&&(e=e.replace(/\b(\d{2,4})[''']?\s?[sS](?=\s|[.,!?;:]|$)/g,((t,e)=>{const n=this.convertDecade(e);return n===e?t:n})),e=e.replace(/\b(\d+)\s*(st|nd|rd|th)(?=\s|[.,!?;:]|$)/gi,((t,e)=>this.convertOrdinal(Number(e)))),e=e.replace(/\b(\w*?)(\d+)([A-Za-z]+)\b/g,((t,e,n,s)=>`${e}${this.convertNumberToWords(n)} ${s}`)).replace(/\b([A-Za-z]+)(\d+)(\w*?)\b/g,((t,e,n,s)=>`${e} ${this.convertNumberToWords(n)}${s}`)),e=e.replace(/-?(?:\d{1,3}(?:,\d{3})+|\d+)(\.\d+)?/g,((t,e)=>{let n=t,s=!1;return/,/.test(n)&&(n=n.replace(/,/g,""),s=!0),e&&(s=!0),this.convertNumberToWords(n,s)}))),e=e.replace(/(\D)\1\1+/g,"$1$1").replaceAll(" "," ").normalize("NFD").replace(/[\u0300-\u036f]/g,"").normalize("NFC").trim(),e}wordsToVisemes(t){let e={words:t.toUpperCase(),visemes:[],times:[],durations:[],i:0},n=0;const s=[...e.words];for(;e.i<s.length;){const t=s[e.i],a=this.rules[t];if(a)for(let s=0;s<a.length;s++){const i=a[s];if((e.words.substring(0,e.i)+t.toLowerCase()+e.words.substring(e.i+1)).match(i.regex)){i.visemes.forEach((t=>{if(e.visemes.length&&e.visemes[e.visemes.length-1]===t){const s=.7*(this.visemeDurations[t]||1);e.durations[e.durations.length-1]+=s,n+=s}else{const s=this.visemeDurations[t]||1;e.visemes.push(t),e.times.push(n),e.durations.push(s),n+=s}})),e.i+=i.move;break}}else e.i++,n+=this.specialDurations[t]||0}return e}}export{t as LipsyncEn};
@@ -1 +0,0 @@
1
- class s{constructor(){this.visemes={a:"aa",e:"E",i:"I",o:"O",u:"U",y:"U","ä":"aa","ö":"O","å":"O",b:"PP",c:"SS",d:"DD",f:"FF",g:"kk",h:"kk",j:"I",k:"kk",l:"nn",m:"PP",n:"nn",p:"PP",q:"kk",r:"RR",s:"SS",t:"DD",v:"FF",w:"FF",x:"SS",z:"SS"},this.visemeDurations={aa:.95,E:.9,I:.92,O:.96,U:.95,PP:1.08,SS:1.23,DD:1.05,FF:1,kk:1.21,nn:.88,RR:.88,DD:1.05,sil:1},this.specialDurations={" ":1,",":3,"-":.5},this.numbers=["nolla","yksi","kaksi","kolme","neljä","viisi","kuusi","seitsemän","kahdeksan","yhdeksän","kymmenen","yksitoista","kaksitoista","kolmetoista","neljätoista","viisitoista","kuusitoista","seitsemäntoista","kahdeksantoista","yhdeksäntoista"],this.symbols={"%":"prosenttia","€":"euroa","&":"ja","+":"plus",$:"dollaria"},this.symbolsReg=/[%€&\+\$]/g}numberToFinnishWords(s){const e=[];let t=parseFloat(s);if(void 0===t)return s;let i=(s,t,i,a,n)=>{if(s<t)return s;const o=Math.floor(s/t);return e.push(i+(1===o?a:this.numberToFinnishWords(o.toString())+n)),s-o*t};if(t<0&&(e.push("miinus "),t=Math.abs(t)),t=i(t,1e9," ","miljardi"," miljardia"),t=i(t,1e6," ","miljoona"," miljoonaa"),t=i(t,1e3,"","tuhat","tuhatta"),t=i(t,100," ","sata","sataa"),t>20&&(t=i(t,10,"","","kymmentä")),t>=1){let s=Math.floor(t);e.push(this.numbers[s]),t-=s}if(t>=0&&Math.abs(parseFloat(s))<1&&e.push("nolla"),t>0){let t=s.split(".");if(t.length>1){e.push(" pilkku");let s=[...t[t.length-1]];for(let t=0;t<s.length;t++)e.push(" "+this.numbers[s[t]])}}return e.join("").trim()}preProcessText(s){return s.replace(/[#_*\'\":;]/g,"").replace(this.symbolsReg,(s=>" "+this.symbols[s]+" ")).replace(/(\d)\,(\d)/g,"$1 pilkku $2").replace(/\d+/g,this.numberToFinnishWords.bind(this)).replaceAll(" "," ").normalize("NFD").replace(/[\u0300-\u0307\u0309\u030b-\u036f]/g,"").normalize("NFC").trim()}wordsToVisemes(s){let e={words:s,visemes:[],times:[],durations:[]},t=0;const i=[...s];for(let a=0;a<i.length;a++){const s=this.visemes[i[a].toLowerCase()];if(s)if(e.visemes.length&&e.visemes[e.visemes.length-1]===s){const i=.7*(this.visemeDurations[s]||1);e.durations[e.durations.length-1]+=i,t+=i}else{const i=this.visemeDurations[s]||1;e.visemes.push(s),e.times.push(t),e.durations.push(i),t+=i}else t+=this.specialDurations[i[a]]||0}return e}}export{s as LipsyncFi};
@@ -1 +0,0 @@
1
- class n{constructor(){this.rules={A:["[AN]C=aa nn","[AN]G=aa nn","[AN]T=aa nn","[AN]D=aa nn","[AN] =aa nn","[AN]$=aa nn","[AM]P=aa nn","[AM]B=aa nn","[AM] =aa nn","[AM]$=aa nn","[AI]N=E nn","[AIM]=E nn","[AIN]=E nn","[AU]=O","[AUX]=O","[AUT]=O","[AI]=E","[AY]=E","[A]=aa"],"À":["[À]=aa"],"Â":["[Â]=aa"],B:[" [B] =PP","[BB]=PP","[B]=PP"],C:["[C]E=SS","[C]I=SS","[C]Y=SS","[C]È=SS","[C]É=SS","[C]Ê=SS","[CH]=SS","[C]A=kk","[C]O=kk","[C]U=kk","[C]L=kk","[C]R=kk","[CK]=kk","[C]=kk"],"Ç":["[Ç]=SS"],D:["[D]=DD"],E:["[EN]C=aa nn","[EN]T=aa nn","[EN]D=aa nn","[EN] =aa nn","[EN]$=aa nn","[EM]P=aa nn","[EM]B=aa nn","[EM] =aa nn","[EM]$=aa nn","[EAU]=O","[EAU]X=O","[EU]=U","[EUX]=U","[EUR]=U RR","[EI]=E","[EIN]=E nn","[ER] =E","[ER]$=E","[EZ] =E","[EZ]$=E","[ED] =E","[ED]$=E"," [E] =","[E] =","[E]$=","[E]S =","[E]S$=","[E]NT =","[E]NT$=","[È]=E","[É]=E","[Ê]=E","[Ë]=E","[E]=E"],"È":["[È]=E"],"É":["[É]=E"],"Ê":["[Ê]=E"],"Ë":["[Ë]=E"],F:["[FF]=FF","[F]=FF","[PH]=FF"],G:["[G]E=SS","[G]I=SS","[G]Y=SS","[G]È=SS","[G]É=SS","[G]Ê=SS","[GN]=nn I","[GN]E=nn","[GN]A=nn aa","[GN]O=nn O","[GU]E=kk","[GU]I=kk","[GU]A=kk FF aa","[GU]O=kk FF O","[G]A=kk","[G]O=kk","[G]U=kk","[G]L=kk","[G]R=kk","[GG]=kk","[G]=kk"],H:["[H]="],I:["[IN]C=E nn","[IN]T=E nn","[IN]D=E nn","[IN] =E nn","[IN]$=E nn","[IM]P=E nn","[IM]B=E nn","[IM] =E nn","[IM]$=E nn","[IEN]=I E nn","[IER]=I E","[IEU]=I U","[IEZ]=I E","[ILL]E=I","[ILLE]=I","[ILL]=I","[Î]=I","[Ï]=I","[I]=I"],"Î":["[Î]=I"],"Ï":["[Ï]=I"],J:["[J]=SS"],K:["[K]=kk"],L:["[LL]E=","[LLE]=","[LL]A=I aa","[LL]O=I O","[LL]U=I U","[LL]I=I","[LL]=I","[L]=nn"],M:["[MM]=PP","[M]=PP"],N:["[NN]=nn","[N]=nn"],O:["[ON]C=O nn","[ON]T=O nn","[ON]D=O nn","[ON] =O nn","[ON]$=O nn","[OM]P=O nn","[OM]B=O nn","[OM] =O nn","[OM]$=O nn","[OI]N=FF E nn","[OI]G=FF aa","[OI]S=FF aa","[OI]T=FF aa","[OI]X=FF aa","[OI]=FF aa","[OU]=U","[OÙ]=U","[OÛ]=U","[OEU]=U","[OEUR]=U RR","[OUGH]=U FF","[OUGH]T=U","[Ô]=O","[O]=O"],"Ô":["[Ô]=O"],"Ù":["[Ù]=U"],"Û":["[Û]=U"],P:["[PH]=FF","[PP]=PP","[P]=PP"],Q:["[QU]=kk","[Q]=kk"],R:["[RR]=RR","[R]=RR"],S:["#[S]#=SS"," [S]=SS","[SS]=SS","[S] =","[S]$=","[SC]E=SS","[SC]I=SS","[SC]Y=SS","[S]=SS"],T:["[TI]A=SS I aa","[TI]E=SS I E","[TI]O=SS I O","[TI]ON=SS I O nn","[TH]=DD","[TT]=DD","[T] =","[T]$=","[T]=DD"],U:["[UN]C=U nn","[UN]T=U nn","[UN]D=U nn","[UN] =U nn","[UN]$=U nn","[UM]=U nn","[UE]=I","[UEI]=I E","[UEIL]=I I","[UILL]=I","[Ù]=U","[Û]=U","[Ü]=I U","[U]=I U"],"Ü":["[Ü]=I U"],V:["[V]=FF"],W:["[W]=FF"],X:["[X] =","[X]$=","#[X]#=kk SS"," [X]=kk SS","[X]=kk SS"],Y:["[Y]=I"," [Y]=I","[YE]=I E","[YA]=I aa","[YO]=I O","[YU]=I U"],Z:["[Z]=SS"]};const n={"#":"[AEIOUYÀÂÈÉÊËÎÏÔÙÛÜ]+",".":"[BDVGJLMNRWZ]","%":"(?:ER|E|ES|ÉS|ÈS|ÊS|ENT|MENT|TION|SION)","&":"(?:[SCGZXJ]|CH|SH|GN)","@":"(?:[TSRDLZNJ]|TH|CH|SH|GN)","^":"[BCDFGHJKLMNPQRSTVWXZÇ]+","+":"[EIYÈÉÊËÎÏ]",":":"[BCDFGHJKLMNPQRSTVWXZÇ]*"," ":"\\b",$:"$"};Object.keys(this.rules).forEach((e=>{this.rules[e]=this.rules[e].map((e=>{const t=e.indexOf("["),s=e.indexOf("]"),i=e.indexOf("="),r=e.substring(0,t),a=e.substring(t+1,s),o=e.substring(s+1,i),E=e.substring(i+1),S={regex:"",move:0,visemes:[]};let u="";u+=[...r].map((e=>n[e]||e)).join("");const I=[...a];return I[0]=I[0].toLowerCase(),u+=I.join(""),S.move=I.length,u+=[...o].map((e=>n[e]||e)).join(""),S.regex=new RegExp(u,"i"),E.length&&E.split(" ").forEach((n=>{n&&S.visemes.push(n)})),S}))})),this.visemeDurations={aa:1,E:.95,I:.9,O:1.05,U:.95,PP:1.1,SS:1.25,TH:1,DD:1.05,FF:1,kk:1.2,nn:.88,RR:1.15,sil:1},this.specialDurations={" ":1,",":2.5,".":3.5,";":2.8,":":2.2,"!":3.2,"?":3.2,"-":.8,"'":.3,'"':.3,"(":1.5,")":1.5},this.digits=["zéro","un","deux","trois","quatre","cinq","six","sept","huit","neuf"],this.ones=["","un","deux","trois","quatre","cinq","six","sept","huit","neuf"],this.teens=["dix","onze","douze","treize","quatorze","quinze","seize","dix-sept","dix-huit","dix-neuf"],this.tens=["","dix","vingt","trente","quarante","cinquante","soixante","soixante-dix","quatre-vingts","quatre-vingt-dix"],this.symbols={"%":"pourcent","€":"euros","&":"et","+":"plus",$:"dollars","=":"égale","@":"arobase","#":"dièse","°":"degrés"},this.symbolsReg=/[%€&\+\$=@#°]/g}convert_digit_by_digit(n){n=String(n).split("");let e="";for(let t=0;t<n.length;t++)e+=this.digits[n[t]]+" ";return e=e.substring(0,e.length-1),e}convert_tens(n){if(n<10)return this.ones[n]||"";if(n>=10&&n<20)return this.teens[n-10];if(n>=70&&n<80){const e=n-60;return 11===e?"soixante et onze":"soixante-"+this.teens[e-10]}if(n>=90){const e=n-80;return 11===e?"quatre-vingt-onze":"quatre-vingt-"+this.teens[e-10]}{const e=Math.floor(n/10),t=n%10;return 8===e&&0===t?"quatre-vingts":8===e?"quatre-vingt-"+this.ones[t]:2!==e&&3!==e&&4!==e&&5!==e&&6!==e||1!==t?0===t?this.tens[e]:this.tens[e]+"-"+this.ones[t]:this.tens[e]+" et un"}}convert_hundreds(n){if(n>=100){const e=Math.floor(n/100),t=n%100;let s="";return 1===e?s="cent":(s=this.ones[e]+" cent",0===t&&(s+="s")),t>0&&(s+=" "+this.convert_tens(t)),s}return this.convert_tens(n)}convert_thousands(n){if(n>=1e3){const e=Math.floor(n/1e3),t=n%1e3;let s="";return s=1===e?"mille":this.convert_hundreds(e)+" mille",t>0&&(s+=" "+this.convert_hundreds(t)),s}return this.convert_hundreds(n)}convert_millions(n){if(n>=1e6){const e=Math.floor(n/1e6),t=n%1e6;let s="";return s=1===e?"un million":this.convert_hundreds(e)+" millions",t>0&&(s+=" "+this.convert_thousands(t)),s}return this.convert_thousands(n)}convertNumberToWords(n){const e=String(n);return"0"===n||0===n?"zéro":e.startsWith("0")?this.convert_digit_by_digit(n):this.convert_millions(Number(n))}preProcessText(n){return n.replace(/[#_*\":;]/g,"").replace(this.symbolsReg,(n=>" "+this.symbols[n]+" ")).replace(/(\d)[,.](\d)/g,"$1 virgule $2").replace(/\d+/g,this.convertNumberToWords.bind(this)).replace(/(\D)\1\1+/g,"$1$1").replace(/\s+/g," ").replace(/'/g,"'").trim()}wordsToVisemes(n){let e={words:n.toUpperCase(),visemes:[],times:[],durations:[],i:0},t=0;const s=[...e.words];for(;e.i<s.length;){const n=s[e.i],i=this.rules[n];if(i){let s=!1;for(let r=0;r<i.length;r++){const a=i[r];if((e.words.substring(0,e.i)+n.toLowerCase()+e.words.substring(e.i+1)).match(a.regex)){a.visemes.forEach((n=>{if(e.visemes.length&&e.visemes[e.visemes.length-1]===n){const s=.7*(this.visemeDurations[n]||1);e.durations[e.durations.length-1]+=s,t+=s}else{const s=this.visemeDurations[n]||1;e.visemes.push(n),e.times.push(t),e.durations.push(s),t+=s}})),e.i+=a.move,s=!0;break}}s||(e.i++,t+=this.specialDurations[n]||0)}else e.i++,t+=this.specialDurations[n]||0}return e}}export{n as LipsyncFr};
@@ -1 +0,0 @@
1
- class e{constructor(){this.visemes={a:"aa","ą":"O",e:"E","ę":"E","ė":"E",i:"I","į":"I",o:"O",u:"U","ū":"U","ų":"U",y:"I",b:"PP",c:"SS","č":"SS",d:"DD",f:"FF",g:"kk",h:"kk",j:"I",k:"kk",l:"nn",m:"PP",n:"nn",p:"PP",q:"kk",r:"RR",s:"SS","š":"CH",t:"DD",v:"FF",w:"FF",x:"SS",z:"SS","ž":"SS"},this.durations={a:.95,"ą":1.5,e:.9,"ę":1.5,"ė":1.5,i:.92,"į":1.5,o:.96,u:.95,"ū":1.5,"ų":1.5,y:1.5,b:1.08,c:1.23,d:1.05,f:1,g:1.21,h:1.21,j:.92,k:1.21,l:.88,m:1.08,n:.88,p:1.08,q:1.21,r:.88,s:1.23,"š":1.23,t:1.05,v:1,w:1,x:1.23,z:1.23,"ž":1.23},this.pauses={" ":1,",":3,"-":.5},this.numbers=["nulis","vienas","du","trys","keturi","penki","šeši","septyni","aštuoni","devyni","dešimt","vienuolika","dvylika","trylika","keturiolika","penkiolika","šešiolika","septyniolika","aštuoniolika","devyniolika"],this.tens=[this.numbers[0],this.numbers[10],"dvidešimt","trisdešimt","keturiasdešimt","penkiasdešimt","šešiasdešimt","septyniasdešimt","aštuoniasdešimt","devyniasdešimt"]}numberToLithuanianWords(e){const i=[];let s=parseFloat(e);if(void 0===s)return e;let t=(e,s,t,l,a)=>{if(e<s)return e;const r=Math.floor(e/s);return 1===r?i.push(this.numbers[1]):i.push(this.numberToLithuanianWords(r.toString())),r%10==1?i.push(t):r%10==0||r%100>10&&r%100<20?i.push(a):i.push(l),e-r*s};s<0&&(i.push("minus"),s=Math.abs(s)),s=t(s,1e9,"milijardas","milijardai","milijardų"),s=t(s,1e6,"milijonas","milijonai","milijonų"),s=t(s,1e3,"tūkstantis","tūkstančiai","tūkstančių"),s=t(s,100,"šimtas","šimtai","šimtų");for(let l=this.tens.length-1;l>=1;l--)if(s>=10*l){i.push(this.tens[l]),s-=10*l;break}if(s>=1){let e=Math.floor(s);i.push(this.numbers[e]),s-=e}if(s>=0&&Math.abs(parseFloat(e))<1&&i.push(this.numbers[0]),s>0){let s=e.split(".");if(s.length>1){i.push("kablelis");let e=[...s[s.length-1]];for(let s=0;s<e.length;s++)i.push(this.numbers[e[s]])}}return i.join(" ").trim()}preProcessText(e){return e.replace("/[#_*'\":;]/g","").replaceAll("0 %","0 procentų ").replaceAll("1 %","1 procentas ").replaceAll("%"," procentai ").replaceAll("0 €","0 eurų ").replaceAll("1 €","1 euras ").replaceAll("€"," eurai ").replaceAll("0 $","0 dolerių ").replaceAll("1 $","1 doleris ").replaceAll("$"," doleriai ").replaceAll("&"," ir ").replaceAll("+"," pliusas ").replace(/(\d)\,(\d)/g,"$1 kablelis $2").replace(/\d+/g,this.numberToLithuanianWords.bind(this)).replace(/(\D)\1\1+/g,"$1$1").replaceAll(" "," ").normalize("NFD").replace(/[\u0300-\u0303\u0305\u0306\u0308-\u0327\u0329-\u036f]/g,"").normalize("NFC").trim()}wordsToVisemes(e){let i={words:e,visemes:[],times:[],durations:[]},s=0;const t=[...e];for(let l=0;l<t.length;l++){const e=t[l].toLowerCase(),a=this.visemes[e];if(a)if(i.visemes.length&&i.visemes[i.visemes.length-1]===a){const t=.7*(this.durations[e]||1);i.durations[i.durations.length-1]+=t,s+=t}else{const t=this.durations[e]||1;i.visemes.push(a),i.times.push(s),i.durations.push(t),s+=t}else s+=this.pauses[t[l]]||0}return i}}export{e as LipsyncLt};