utilitas 1995.0.21 → 1995.0.22

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/lib/manifest.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  const manifest = {
2
2
  "name": "utilitas",
3
3
  "description": "Just another common utility for JavaScript.",
4
- "version": "1995.0.21",
4
+ "version": "1995.0.22",
5
5
  "private": false,
6
6
  "homepage": "https://github.com/Leask/utilitas",
7
7
  "main": "index.mjs",
@@ -17,7 +17,7 @@ const manifest = {
17
17
  },
18
18
  "dependencies": {
19
19
  "file-type": "^18.5.0",
20
- "mathjs": "^11.9.0",
20
+ "mathjs": "^11.9.1",
21
21
  "uuid": "^9.0.0"
22
22
  },
23
23
  "devDependencies": {
@@ -40,7 +40,7 @@ const manifest = {
40
40
  "lorem-ipsum": "^2.0.8",
41
41
  "mailgun.js": "^9.2.0",
42
42
  "mysql2": "^3.5.2",
43
- "node-mailjet": "^6.0.3",
43
+ "node-mailjet": "^6.0.4",
44
44
  "node-polyfill-webpack-plugin": "^2.0.1",
45
45
  "office-text-extractor": "^3.0.1",
46
46
  "ping": "^0.4.4",
package/lib/speech.mjs CHANGED
@@ -4,7 +4,7 @@ import { getApiKeyCredentials, hash } from './encryption.mjs';
4
4
  import { getFfmpeg } from './media.mjs';
5
5
 
6
6
  import {
7
- call, countKeys, ignoreErrFunc, log as _log, need, throwError
7
+ call, countKeys, ignoreErrFunc, inBrowser, log as _log, need, throwError
8
8
  } from './utilitas.mjs';
9
9
 
10
10
  import {
@@ -126,6 +126,11 @@ const ttsSay = async (text, options) => {
126
126
  return file;
127
127
  };
128
128
 
129
+ const ttsBrowser = async (text) => {
130
+ assert(text, 'Text is required.', 400);
131
+ return speechSynthesis.speak(new SpeechSynthesisUtterance(text));
132
+ };
133
+
129
134
  const sttGoogle = async (audio, options) => {
130
135
  assert(clients.stt, 'Speech-to-Text API has not been initialized.', 500);
131
136
  const content = await convert(audio, {
@@ -165,7 +170,8 @@ const sttWhisper = async (audio, options) => {
165
170
 
166
171
  const tts = async (text, options) => {
167
172
  let engine;
168
- if (clients?.tts) { engine = ttsGoogle; }
173
+ if (inBrowser()) { engine = ttsBrowser }
174
+ else if (clients?.tts) { engine = ttsGoogle; }
169
175
  else if (await checkSay()) { engine = ttsSay; }
170
176
  else { throwError('Text-to-Speech engine has not been initialized.', 500); }
171
177
  return await engine(text, options);
package/lib/utilitas.mjs CHANGED
@@ -699,7 +699,7 @@ const analyzeModule = (obj) => {
699
699
  };
700
700
 
701
701
  const need = async (name, options) => {
702
- assert(name, 'Module name is required.', 500);
702
+ assert(name, `Module \`${name}\` is required.`, 500);
703
703
  modules[name] || (modules[name] = await import(name));
704
704
  return !options?.raw && modules[name].default
705
705
  ? modules[name].default : modules[name];
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "utilitas",
3
3
  "description": "Just another common utility for JavaScript.",
4
- "version": "1995.0.21",
4
+ "version": "1995.0.22",
5
5
  "private": false,
6
6
  "homepage": "https://github.com/Leask/utilitas",
7
7
  "main": "index.mjs",
@@ -28,7 +28,7 @@
28
28
  },
29
29
  "dependencies": {
30
30
  "file-type": "^18.5.0",
31
- "mathjs": "^11.9.0",
31
+ "mathjs": "^11.9.1",
32
32
  "uuid": "^9.0.0"
33
33
  },
34
34
  "devDependencies": {
@@ -51,7 +51,7 @@
51
51
  "lorem-ipsum": "^2.0.8",
52
52
  "mailgun.js": "^9.2.0",
53
53
  "mysql2": "^3.5.2",
54
- "node-mailjet": "^6.0.3",
54
+ "node-mailjet": "^6.0.4",
55
55
  "node-polyfill-webpack-plugin": "^2.0.1",
56
56
  "office-text-extractor": "^3.0.1",
57
57
  "ping": "^0.4.4",