@jambonz/speech-utils 0.1.2 → 0.1.4

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.
@@ -0,0 +1,3 @@
1
+ npm audit
2
+ npm run jslint:fix || true
3
+ npm test
@@ -0,0 +1,140 @@
1
+ const promise = require('eslint-plugin-promise');
2
+ const globals = require('globals');
3
+
4
+
5
+ module.exports = [
6
+ {
7
+ files: ['**/*.js', '*.js'],
8
+ languageOptions: {
9
+
10
+ ecmaVersion: 2020,
11
+ parserOptions: {
12
+ 'node': true,
13
+ 'es6': true,
14
+ ecmaFeatures: {
15
+ jsx: false,
16
+ modules: false,
17
+ }
18
+ },
19
+ sourceType: 'module',
20
+ globals: {
21
+ ...globals.node,
22
+ 'DTRACE_HTTP_CLIENT_REQUEST': false,
23
+ 'LTTNG_HTTP_CLIENT_REQUEST': false,
24
+ 'COUNTER_HTTP_CLIENT_REQUEST': false,
25
+ 'DTRACE_HTTP_CLIENT_RESPONSE': false,
26
+ 'LTTNG_HTTP_CLIENT_RESPONSE': false,
27
+ 'COUNTER_HTTP_CLIENT_RESPONSE': false,
28
+ 'DTRACE_HTTP_SERVER_REQUEST': false,
29
+ 'LTTNG_HTTP_SERVER_REQUEST': false,
30
+ 'COUNTER_HTTP_SERVER_REQUEST': false,
31
+ 'DTRACE_HTTP_SERVER_RESPONSE': false,
32
+ 'LTTNG_HTTP_SERVER_RESPONSE': false,
33
+ 'COUNTER_HTTP_SERVER_RESPONSE': false,
34
+ 'DTRACE_NET_STREAM_END': false,
35
+ 'LTTNG_NET_STREAM_END': false,
36
+ 'COUNTER_NET_SERVER_CONNECTION_CLOSE': false,
37
+ 'DTRACE_NET_SERVER_CONNECTION': false,
38
+ 'LTTNG_NET_SERVER_CONNECTION': false,
39
+ 'COUNTER_NET_SERVER_CONNECTION': false
40
+ },
41
+
42
+ },
43
+ 'plugins': {
44
+ promise
45
+ },
46
+ 'rules': {
47
+ 'promise/always-return': 'error',
48
+ 'promise/no-return-wrap': 'error',
49
+ 'promise/param-names': 'error',
50
+ 'promise/catch-or-return': 'error',
51
+ 'promise/no-native': 'off',
52
+ 'promise/no-nesting': 'warn',
53
+ 'promise/no-promise-in-callback': 'warn',
54
+ 'promise/no-callback-in-promise': 'warn',
55
+ 'promise/no-return-in-finally': 'warn',
56
+
57
+ // Possible Errors
58
+ // http://eslint.org/docs/rules/#possible-errors
59
+ 'comma-dangle': [2, 'only-multiline'],
60
+ 'no-control-regex': 2,
61
+ 'no-debugger': 2,
62
+ 'no-dupe-args': 2,
63
+ 'no-dupe-keys': 2,
64
+ 'no-duplicate-case': 2,
65
+ 'no-empty-character-class': 2,
66
+ 'no-ex-assign': 2,
67
+ 'no-extra-boolean-cast': 2,
68
+ 'no-extra-parens': [2, 'functions'],
69
+ 'no-extra-semi': 2,
70
+ 'no-func-assign': 2,
71
+ 'no-invalid-regexp': 2,
72
+ 'no-irregular-whitespace': 2,
73
+ 'no-negated-in-lhs': 2,
74
+ 'no-obj-calls': 2,
75
+ 'no-proto': 2,
76
+ 'no-unexpected-multiline': 2,
77
+ 'no-unreachable': 2,
78
+ 'use-isnan': 2,
79
+ 'valid-typeof': 2,
80
+
81
+ // Best Practices
82
+ // http://eslint.org/docs/rules/#best-practices
83
+ 'no-fallthrough': 2,
84
+ 'no-octal': 2,
85
+ 'no-redeclare': 2,
86
+ 'no-self-assign': 2,
87
+ 'no-unused-labels': 2,
88
+
89
+ // Strict Mode
90
+ // http://eslint.org/docs/rules/#strict-mode
91
+ 'strict': [2, 'never'],
92
+
93
+ // Variables
94
+ // http://eslint.org/docs/rules/#variables
95
+ 'no-delete-var': 2,
96
+ 'no-undef': 2,
97
+ 'no-unused-vars': [2, { 'args': 'none' }],
98
+
99
+ // Node.js and CommonJS
100
+ // http://eslint.org/docs/rules/#nodejs-and-commonjs
101
+ 'no-mixed-requires': 2,
102
+ 'no-new-require': 2,
103
+ 'no-path-concat': 2,
104
+ 'no-restricted-modules': [2, 'sys', '_linklist'],
105
+
106
+ // Stylistic Issues
107
+ // http://eslint.org/docs/rules/#stylistic-issues
108
+ 'comma-spacing': 2,
109
+ 'eol-last': 2,
110
+ 'indent': [2, 2, { 'SwitchCase': 1 }],
111
+ 'keyword-spacing': 2,
112
+ 'max-len': [2, 120, 2],
113
+ 'new-parens': 2,
114
+ 'no-mixed-spaces-and-tabs': 2,
115
+ 'no-multiple-empty-lines': [2, { 'max': 2 }],
116
+ 'no-trailing-spaces': [2, { 'skipBlankLines': false }],
117
+ 'quotes': [2, 'single', 'avoid-escape'],
118
+ 'semi': 2,
119
+ 'space-before-blocks': [2, 'always'],
120
+ 'space-before-function-paren': [2, 'never'],
121
+ 'space-in-parens': [2, 'never'],
122
+ 'space-infix-ops': 2,
123
+ 'space-unary-ops': 2,
124
+
125
+ // ECMAScript 6
126
+ // http://eslint.org/docs/rules/#ecmascript-6
127
+ 'arrow-parens': [2, 'always'],
128
+ 'arrow-spacing': [2, { 'before': true, 'after': true }],
129
+ 'constructor-super': 2,
130
+ 'no-class-assign': 2,
131
+ 'no-confusing-arrow': 2,
132
+ 'no-const-assign': 2,
133
+ 'no-dupe-class-members': 2,
134
+ 'no-new-symbol': 2,
135
+ 'no-this-before-super': 2,
136
+ 'prefer-const': 2
137
+ },
138
+ 'ignores': []
139
+ }
140
+ ];
package/lib/config.js CHANGED
@@ -3,7 +3,8 @@ const JAMBONES_DISABLE_TTS_STREAMING = process.env.JAMBONES_DISABLE_TTS_STREAMIN
3
3
 
4
4
  const JAMBONES_HTTP_PROXY_IP = process.env.JAMBONES_HTTP_PROXY_IP;
5
5
  const JAMBONES_HTTP_PROXY_PORT = process.env.JAMBONES_HTTP_PROXY_PORT;
6
- const JAMBONES_TTS_CACHE_DURATION_MINS = (parseInt(process.env.JAMBONES_TTS_CACHE_DURATION_MINS) || 4 * 60) * 60; // cache tts for 4 hours
6
+ const JAMBONES_TTS_CACHE_DURATION_MINS =
7
+ (parseInt(process.env.JAMBONES_TTS_CACHE_DURATION_MINS) || 4 * 60) * 60; // cache tts for 4 hours
7
8
 
8
9
  const TMP_FOLDER = '/tmp';
9
10
 
@@ -194,7 +194,7 @@ async function synthAudio(client, createHash, retrieveHash, logger, stats, { acc
194
194
  case 'microsoft':
195
195
  vendorLabel = 'microsoft';
196
196
  audioBuffer = await synthMicrosoft(logger, {credentials, stats, language, voice, text, deploymentId,
197
- filePath, renderForCaching, disableTtsStreaming});
197
+ filePath, renderForCaching, disableTtsStreaming});
198
198
  break;
199
199
  case 'nuance':
200
200
  model = model || 'enhanced';
@@ -212,21 +212,21 @@ async function synthAudio(client, createHash, retrieveHash, logger, stats, { acc
212
212
  case 'elevenlabs':
213
213
  audioBuffer = await synthElevenlabs(logger, {
214
214
  credentials, options, stats, language, voice, text, renderForCaching, disableTtsStreaming, filePath
215
- });
215
+ });
216
216
  break;
217
217
  case 'playht':
218
218
  audioBuffer = await synthPlayHT(logger, {
219
219
  credentials, options, stats, language, voice, text, renderForCaching, disableTtsStreaming, filePath
220
- });
220
+ });
221
221
  break;
222
222
  case 'rimelabs':
223
223
  audioBuffer = await synthRimelabs(logger, {
224
224
  credentials, options, stats, language, voice, text, renderForCaching, disableTtsStreaming, filePath
225
- });
225
+ });
226
226
  break;
227
227
  case 'whisper':
228
228
  audioBuffer = await synthWhisper(logger, {
229
- credentials, stats, voice, text, renderForCaching, disableTtsStreaming});
229
+ credentials, stats, voice, text, renderForCaching, disableTtsStreaming});
230
230
  break;
231
231
  case 'verbio':
232
232
  audioBuffer = await synthVerbio(client, logger, {
@@ -235,7 +235,7 @@ async function synthAudio(client, createHash, retrieveHash, logger, stats, { acc
235
235
  break;
236
236
  case 'deepgram':
237
237
  audioBuffer = await synthDeepgram(logger, {credentials, stats, model, text,
238
- renderForCaching, disableTtsStreaming});
238
+ renderForCaching, disableTtsStreaming});
239
239
  break;
240
240
  case vendor.startsWith('custom') ? vendor : 'cant_match_value':
241
241
  ({ audioBuffer, filePath } = await synthCustomVendor(logger,
@@ -244,7 +244,7 @@ async function synthAudio(client, createHash, retrieveHash, logger, stats, { acc
244
244
  default:
245
245
  assert(`synthAudio: unsupported speech vendor ${vendor}`);
246
246
  }
247
- if('filePath' in audioBuffer) return audioBuffer;
247
+ if ('filePath' in audioBuffer) return audioBuffer;
248
248
  const diff = process.hrtime(startAt);
249
249
  const time = diff[0] * 1e3 + diff[1] * 1e-6;
250
250
  rtt = time.toFixed(0);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jambonz/speech-utils",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "description": "TTS-related speech utilities for jambonz",
5
5
  "main": "index.js",
6
6
  "author": "Dave Horton",
@@ -12,8 +12,9 @@
12
12
  "test": "NODE_ENV=test node test/ ",
13
13
  "coverage": "nyc --reporter html --report-dir ./coverage npm run test",
14
14
  "jslint": "eslint index.js lib",
15
- "jslint:fix": "eslint --fix '**/*.js'",
16
- "build": "./build_stubs.sh"
15
+ "jslint:fix": "npm run jslint --fix",
16
+ "build": "./build_stubs.sh",
17
+ "prepare": "husky"
17
18
  },
18
19
  "repository": {
19
20
  "type": "git",
@@ -40,11 +41,12 @@
40
41
  "undici": "^6.4.0"
41
42
  },
42
43
  "devDependencies": {
43
- "config": "^3.3.10",
44
- "eslint": "^8.56.0",
45
- "eslint-plugin-promise": "^6.1.1",
44
+ "config": "^3.3.11",
45
+ "eslint": "^9.3.0",
46
+ "eslint-plugin-promise": "^6.2.0",
47
+ "husky": "^9.0.11",
46
48
  "nyc": "^15.1.0",
47
- "pino": "^8.17.0",
48
- "tape": "^5.7.3"
49
+ "pino": "^9.1.0",
50
+ "tape": "^5.7.5"
49
51
  }
50
52
  }
package/.eslintignore DELETED
@@ -1 +0,0 @@
1
- test/*
package/.eslintrc.json DELETED
@@ -1,126 +0,0 @@
1
- {
2
- "env": {
3
- "node": true,
4
- "es6": true
5
- },
6
- "parserOptions": {
7
- "ecmaFeatures": {
8
- "jsx": false,
9
- "modules": false
10
- },
11
- "ecmaVersion": 2020
12
- },
13
- "plugins": ["promise"],
14
- "rules": {
15
- "promise/always-return": "error",
16
- "promise/no-return-wrap": "error",
17
- "promise/param-names": "error",
18
- "promise/catch-or-return": "error",
19
- "promise/no-native": "off",
20
- "promise/no-nesting": "warn",
21
- "promise/no-promise-in-callback": "warn",
22
- "promise/no-callback-in-promise": "warn",
23
- "promise/no-return-in-finally": "warn",
24
-
25
- // Possible Errors
26
- // http://eslint.org/docs/rules/#possible-errors
27
- "comma-dangle": [2, "only-multiline"],
28
- "no-control-regex": 2,
29
- "no-debugger": 2,
30
- "no-dupe-args": 2,
31
- "no-dupe-keys": 2,
32
- "no-duplicate-case": 2,
33
- "no-empty-character-class": 2,
34
- "no-ex-assign": 2,
35
- "no-extra-boolean-cast" : 2,
36
- "no-extra-parens": [2, "functions"],
37
- "no-extra-semi": 2,
38
- "no-func-assign": 2,
39
- "no-invalid-regexp": 2,
40
- "no-irregular-whitespace": 2,
41
- "no-negated-in-lhs": 2,
42
- "no-obj-calls": 2,
43
- "no-proto": 2,
44
- "no-unexpected-multiline": 2,
45
- "no-unreachable": 2,
46
- "use-isnan": 2,
47
- "valid-typeof": 2,
48
-
49
- // Best Practices
50
- // http://eslint.org/docs/rules/#best-practices
51
- "no-fallthrough": 2,
52
- "no-octal": 2,
53
- "no-redeclare": 2,
54
- "no-self-assign": 2,
55
- "no-unused-labels": 2,
56
-
57
- // Strict Mode
58
- // http://eslint.org/docs/rules/#strict-mode
59
- "strict": [2, "never"],
60
-
61
- // Variables
62
- // http://eslint.org/docs/rules/#variables
63
- "no-delete-var": 2,
64
- "no-undef": 2,
65
- "no-unused-vars": [2, {"args": "none"}],
66
-
67
- // Node.js and CommonJS
68
- // http://eslint.org/docs/rules/#nodejs-and-commonjs
69
- "no-mixed-requires": 2,
70
- "no-new-require": 2,
71
- "no-path-concat": 2,
72
- "no-restricted-modules": [2, "sys", "_linklist"],
73
-
74
- // Stylistic Issues
75
- // http://eslint.org/docs/rules/#stylistic-issues
76
- "comma-spacing": 2,
77
- "eol-last": 2,
78
- "indent": [2, 2, {"SwitchCase": 1}],
79
- "keyword-spacing": 2,
80
- "max-len": [2, 120, 2],
81
- "new-parens": 2,
82
- "no-mixed-spaces-and-tabs": 2,
83
- "no-multiple-empty-lines": [2, {"max": 2}],
84
- "no-trailing-spaces": [2, {"skipBlankLines": false }],
85
- "quotes": [2, "single", "avoid-escape"],
86
- "semi": 2,
87
- "space-before-blocks": [2, "always"],
88
- "space-before-function-paren": [2, "never"],
89
- "space-in-parens": [2, "never"],
90
- "space-infix-ops": 2,
91
- "space-unary-ops": 2,
92
-
93
- // ECMAScript 6
94
- // http://eslint.org/docs/rules/#ecmascript-6
95
- "arrow-parens": [2, "always"],
96
- "arrow-spacing": [2, {"before": true, "after": true}],
97
- "constructor-super": 2,
98
- "no-class-assign": 2,
99
- "no-confusing-arrow": 2,
100
- "no-const-assign": 2,
101
- "no-dupe-class-members": 2,
102
- "no-new-symbol": 2,
103
- "no-this-before-super": 2,
104
- "prefer-const": 2
105
- },
106
- "globals": {
107
- "DTRACE_HTTP_CLIENT_REQUEST" : false,
108
- "LTTNG_HTTP_CLIENT_REQUEST" : false,
109
- "COUNTER_HTTP_CLIENT_REQUEST" : false,
110
- "DTRACE_HTTP_CLIENT_RESPONSE" : false,
111
- "LTTNG_HTTP_CLIENT_RESPONSE" : false,
112
- "COUNTER_HTTP_CLIENT_RESPONSE" : false,
113
- "DTRACE_HTTP_SERVER_REQUEST" : false,
114
- "LTTNG_HTTP_SERVER_REQUEST" : false,
115
- "COUNTER_HTTP_SERVER_REQUEST" : false,
116
- "DTRACE_HTTP_SERVER_RESPONSE" : false,
117
- "LTTNG_HTTP_SERVER_RESPONSE" : false,
118
- "COUNTER_HTTP_SERVER_RESPONSE" : false,
119
- "DTRACE_NET_STREAM_END" : false,
120
- "LTTNG_NET_STREAM_END" : false,
121
- "COUNTER_NET_SERVER_CONNECTION_CLOSE" : false,
122
- "DTRACE_NET_SERVER_CONNECTION" : false,
123
- "LTTNG_NET_SERVER_CONNECTION" : false,
124
- "COUNTER_NET_SERVER_CONNECTION" : false
125
- }
126
- }