mirror of
https://github.com/jambonz/speech-utils.git
synced 2026-10-03 23:33:59 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b1b9c182a9 | ||
|
|
15c77626fc | ||
|
|
76126ec0b3 | ||
|
|
55431ee511 | ||
|
|
1c76f74b4a | ||
|
|
62ad8abb8e | ||
|
|
92734aaedb | ||
|
|
fe4ccfe7d7 | ||
|
|
ab05976032 | ||
|
|
babd8abc51 | ||
|
|
91f85e16b2 | ||
|
|
8a0c5e3dbd | ||
|
|
d40e012138 | ||
|
|
49b23f5240 | ||
|
|
043642ea5f | ||
|
|
91ea9820f9 | ||
|
|
fad0f57b13 | ||
|
|
2608e149a8 | ||
|
|
d21289acd6 | ||
|
|
a7b19e1d8a | ||
|
|
09c7aa9a5f | ||
|
|
f311c21327 | ||
|
|
535d0191da | ||
|
|
c00d4f9be4 | ||
|
|
db135ee5ad | ||
|
|
5eac4c2ad8 | ||
|
|
e23a1a6d09 | ||
|
|
3a78300a08 | ||
|
|
1d7390e7ae | ||
|
|
3c0940f657 | ||
|
|
6fb6195b16 | ||
|
|
2ff8587601 | ||
|
|
925bd26a70 | ||
|
|
ddea485f5f | ||
|
|
49de25feb8 | ||
|
|
08b55b8d79 | ||
|
|
59bca302b9 | ||
|
|
0d98f73c43 | ||
|
|
36670e0080 | ||
|
|
61672f9868 | ||
|
|
ddeca8eb99 | ||
|
|
6e8271b2f6 | ||
|
|
74a4938eb6 | ||
|
|
cb50f603cd | ||
|
|
9a524f00bc | ||
|
|
545df0b770 | ||
|
|
9409405769 | ||
|
|
7dc3bbdb01 | ||
|
|
f8f9de2645 | ||
|
|
467d7ede26 | ||
|
|
fc211ab2e7 | ||
|
|
536f8aab31 | ||
|
|
69b3fdffbe | ||
|
|
53fe72d89e | ||
|
|
e79c15c5da | ||
|
|
a4a427e174 | ||
|
|
b697bc5268 | ||
|
|
d35d7f0aec | ||
|
|
ed1c564fa2 | ||
|
|
7189d471c1 | ||
|
|
04080cc5ec | ||
|
|
3e5ab4af27 | ||
|
|
f06dddd2f7 | ||
|
|
7b4a71f55d | ||
|
|
d552b65618 | ||
|
|
f701b50244 | ||
|
|
199e502fbe | ||
|
|
6769779189 | ||
|
|
4b43c3986c | ||
|
|
e1292772e6 | ||
|
|
37fb045431 | ||
|
|
c328df67a2 | ||
|
|
877cba7065 | ||
|
|
35a178b468 | ||
|
|
7327190471 | ||
|
|
e5b5e3d0c6 | ||
|
|
3760be088b | ||
|
|
5cb52eb8ec | ||
|
|
8a390a8edf | ||
|
|
d96ab5cdf3 | ||
|
|
3bf74671c6 | ||
|
|
a47ef6d7c4 | ||
|
|
84089fa528 | ||
|
|
72be44eea2 | ||
|
|
05d6c4b32d | ||
|
|
0c7e15d0a2 | ||
|
|
63efecf9d9 | ||
|
|
153ac3f1a4 | ||
|
|
115faa9f89 | ||
|
|
f183852961 | ||
|
|
34c3e01729 | ||
|
|
9b2b16199e | ||
|
|
9112c5f0ea | ||
|
|
50783dfd0a | ||
|
|
ca0ef76fe1 | ||
|
|
7c91c537e4 | ||
|
|
9747526664 | ||
|
|
31a0c7b02c | ||
|
|
c18fbacd1b | ||
|
|
b0fee6bbf1 | ||
|
|
f6cead6e92 | ||
|
|
05fc96edc0 | ||
|
|
6794a0b3be | ||
|
|
1a04fd736c | ||
|
|
1846203807 | ||
|
|
75be8658c1 | ||
|
|
91a5eebbaf | ||
|
|
c96f1e86ee | ||
|
|
8016c0886a | ||
|
|
8f216e64d8 | ||
|
|
e1f4486e01 | ||
|
|
b0d6272974 | ||
|
|
ef23b0807a | ||
|
|
ab7e25243d | ||
|
|
bf0ea14423 | ||
|
|
305dabd84b | ||
|
|
b6a3fa5081 | ||
|
|
73feadc4c4 | ||
|
|
aad0f4d62c | ||
|
|
602b0cc60e | ||
|
|
8511e762c8 | ||
|
|
b75d3068c9 | ||
|
|
461178e726 | ||
|
|
e0e4d47340 | ||
|
|
a595faa378 | ||
|
|
7fd1e1a3c3 | ||
|
|
7f6a3d349c | ||
|
|
50429ff535 | ||
|
|
3bf0ef8ea3 | ||
|
|
e9a5e83e36 | ||
|
|
86a64ac091 | ||
|
|
97e06b3ab3 | ||
|
|
09e833d910 | ||
|
|
8c4e12e54f | ||
|
|
2642bd71a4 | ||
|
|
c4feac916f | ||
|
|
2ec56f564e | ||
|
|
9399ddcb58 | ||
|
|
aebf4eda30 | ||
|
|
6b0bdfdf2f | ||
|
|
d214c3184f | ||
|
|
c335a508a3 | ||
|
|
d7797d5691 | ||
|
|
b81f3313cb | ||
|
|
49fe64744c | ||
|
|
106238cca5 | ||
|
|
01735ccf2f | ||
|
|
ce81cb8d24 | ||
|
|
c9d7a9046f | ||
|
|
a9ba383667 | ||
|
|
06b97bcb0f | ||
|
|
90152b36ef | ||
|
|
92484b7441 | ||
|
|
398904785b | ||
|
|
531fa21f88 | ||
|
|
904495d819 | ||
|
|
f13fc84853 | ||
|
|
e099bbb58f | ||
|
|
e60a2d2ba3 | ||
|
|
39d54050cc | ||
|
|
7618d334db | ||
|
|
71f20178d3 | ||
|
|
cb6ab2479f | ||
|
|
2212be341b | ||
|
|
5d2d921f31 | ||
|
|
acb2d0c7ce | ||
|
|
90d6048f52 | ||
|
|
e5985620c0 | ||
|
|
eb57f4d290 | ||
|
|
f0a1ab139c | ||
|
|
79289a7249 | ||
|
|
5998eebdca | ||
|
|
e6a7017b55 | ||
|
|
c8571af129 | ||
|
|
6144a9c164 | ||
|
|
68a7f2b0d4 | ||
|
|
0d1cd37097 | ||
|
|
3de8e5ff57 | ||
|
|
b4aad7991b | ||
|
|
8a5c5c1966 | ||
|
|
08a56d1a40 | ||
|
|
ba61f20334 | ||
|
|
10316d786e | ||
|
|
38cdc106cc | ||
|
|
410b99ef24 | ||
|
|
51db63f992 | ||
|
|
c86dceadde | ||
|
|
f56f98f40f | ||
|
|
12a36593aa | ||
|
|
8382491477 | ||
|
|
545d559e27 | ||
|
|
cc8963802f | ||
|
|
282d87f922 | ||
|
|
6a288c1db0 | ||
|
|
8650328e64 | ||
|
|
85fa6da5b5 | ||
|
|
e54e913fdd | ||
|
|
b088c0d7d9 | ||
|
|
f154a40692 | ||
|
|
0471b94ebe | ||
|
|
8279891dff | ||
|
|
f546ca998d | ||
|
|
bf229d0ab0 | ||
|
|
f08fedb8ca | ||
|
|
f3cc38089c | ||
|
|
fbed59e5de | ||
|
|
4f1685a365 | ||
|
|
2701af102a | ||
|
|
7f939b96d2 | ||
|
|
4d58ca6daf | ||
|
|
16dd7a2805 | ||
|
|
8f3e930004 | ||
|
|
3f4c444d82 | ||
|
|
fd7d8b8bcd | ||
|
|
46f833c7fa | ||
|
|
4eabfbe4b7 | ||
|
|
f3ab2baa6a | ||
|
|
fb412e2ddf | ||
|
|
f06f96a6f0 | ||
|
|
2988e800b1 | ||
|
|
dbfabeaddf | ||
|
|
c3188e40bb | ||
|
|
d0dfd07204 | ||
|
|
04a2466f54 | ||
|
|
0f9a9edc4d | ||
|
|
31a54f595b | ||
|
|
3560a6d4d9 | ||
|
|
be8053db4f | ||
|
|
4ffae38a3f | ||
|
|
9e74760c39 | ||
|
|
ced1a0ef0d | ||
|
|
1609d0b205 | ||
|
|
ef8ada2793 | ||
|
|
444ad2522f | ||
|
|
1caea60803 | ||
|
|
97c3588cfd | ||
|
|
da3aa5aadb | ||
|
|
2fe89f132c | ||
|
|
4bca840ba2 | ||
|
|
f858ccb781 | ||
|
|
3cf9894b44 | ||
|
|
436b15d648 | ||
|
|
c3b7ea4cd1 |
@@ -1 +0,0 @@
|
||||
test/*
|
||||
-126
@@ -1,126 +0,0 @@
|
||||
{
|
||||
"env": {
|
||||
"node": true,
|
||||
"es6": true
|
||||
},
|
||||
"parserOptions": {
|
||||
"ecmaFeatures": {
|
||||
"jsx": false,
|
||||
"modules": false
|
||||
},
|
||||
"ecmaVersion": 2020
|
||||
},
|
||||
"plugins": ["promise"],
|
||||
"rules": {
|
||||
"promise/always-return": "error",
|
||||
"promise/no-return-wrap": "error",
|
||||
"promise/param-names": "error",
|
||||
"promise/catch-or-return": "error",
|
||||
"promise/no-native": "off",
|
||||
"promise/no-nesting": "warn",
|
||||
"promise/no-promise-in-callback": "warn",
|
||||
"promise/no-callback-in-promise": "warn",
|
||||
"promise/no-return-in-finally": "warn",
|
||||
|
||||
// Possible Errors
|
||||
// http://eslint.org/docs/rules/#possible-errors
|
||||
"comma-dangle": [2, "only-multiline"],
|
||||
"no-control-regex": 2,
|
||||
"no-debugger": 2,
|
||||
"no-dupe-args": 2,
|
||||
"no-dupe-keys": 2,
|
||||
"no-duplicate-case": 2,
|
||||
"no-empty-character-class": 2,
|
||||
"no-ex-assign": 2,
|
||||
"no-extra-boolean-cast" : 2,
|
||||
"no-extra-parens": [2, "functions"],
|
||||
"no-extra-semi": 2,
|
||||
"no-func-assign": 2,
|
||||
"no-invalid-regexp": 2,
|
||||
"no-irregular-whitespace": 2,
|
||||
"no-negated-in-lhs": 2,
|
||||
"no-obj-calls": 2,
|
||||
"no-proto": 2,
|
||||
"no-unexpected-multiline": 2,
|
||||
"no-unreachable": 2,
|
||||
"use-isnan": 2,
|
||||
"valid-typeof": 2,
|
||||
|
||||
// Best Practices
|
||||
// http://eslint.org/docs/rules/#best-practices
|
||||
"no-fallthrough": 2,
|
||||
"no-octal": 2,
|
||||
"no-redeclare": 2,
|
||||
"no-self-assign": 2,
|
||||
"no-unused-labels": 2,
|
||||
|
||||
// Strict Mode
|
||||
// http://eslint.org/docs/rules/#strict-mode
|
||||
"strict": [2, "never"],
|
||||
|
||||
// Variables
|
||||
// http://eslint.org/docs/rules/#variables
|
||||
"no-delete-var": 2,
|
||||
"no-undef": 2,
|
||||
"no-unused-vars": [2, {"args": "none"}],
|
||||
|
||||
// Node.js and CommonJS
|
||||
// http://eslint.org/docs/rules/#nodejs-and-commonjs
|
||||
"no-mixed-requires": 2,
|
||||
"no-new-require": 2,
|
||||
"no-path-concat": 2,
|
||||
"no-restricted-modules": [2, "sys", "_linklist"],
|
||||
|
||||
// Stylistic Issues
|
||||
// http://eslint.org/docs/rules/#stylistic-issues
|
||||
"comma-spacing": 2,
|
||||
"eol-last": 2,
|
||||
"indent": [2, 2, {"SwitchCase": 1}],
|
||||
"keyword-spacing": 2,
|
||||
"max-len": [2, 120, 2],
|
||||
"new-parens": 2,
|
||||
"no-mixed-spaces-and-tabs": 2,
|
||||
"no-multiple-empty-lines": [2, {"max": 2}],
|
||||
"no-trailing-spaces": [2, {"skipBlankLines": false }],
|
||||
"quotes": [2, "single", "avoid-escape"],
|
||||
"semi": 2,
|
||||
"space-before-blocks": [2, "always"],
|
||||
"space-before-function-paren": [2, "never"],
|
||||
"space-in-parens": [2, "never"],
|
||||
"space-infix-ops": 2,
|
||||
"space-unary-ops": 2,
|
||||
|
||||
// ECMAScript 6
|
||||
// http://eslint.org/docs/rules/#ecmascript-6
|
||||
"arrow-parens": [2, "always"],
|
||||
"arrow-spacing": [2, {"before": true, "after": true}],
|
||||
"constructor-super": 2,
|
||||
"no-class-assign": 2,
|
||||
"no-confusing-arrow": 2,
|
||||
"no-const-assign": 2,
|
||||
"no-dupe-class-members": 2,
|
||||
"no-new-symbol": 2,
|
||||
"no-this-before-super": 2,
|
||||
"prefer-const": 2
|
||||
},
|
||||
"globals": {
|
||||
"DTRACE_HTTP_CLIENT_REQUEST" : false,
|
||||
"LTTNG_HTTP_CLIENT_REQUEST" : false,
|
||||
"COUNTER_HTTP_CLIENT_REQUEST" : false,
|
||||
"DTRACE_HTTP_CLIENT_RESPONSE" : false,
|
||||
"LTTNG_HTTP_CLIENT_RESPONSE" : false,
|
||||
"COUNTER_HTTP_CLIENT_RESPONSE" : false,
|
||||
"DTRACE_HTTP_SERVER_REQUEST" : false,
|
||||
"LTTNG_HTTP_SERVER_REQUEST" : false,
|
||||
"COUNTER_HTTP_SERVER_REQUEST" : false,
|
||||
"DTRACE_HTTP_SERVER_RESPONSE" : false,
|
||||
"LTTNG_HTTP_SERVER_RESPONSE" : false,
|
||||
"COUNTER_HTTP_SERVER_RESPONSE" : false,
|
||||
"DTRACE_NET_STREAM_END" : false,
|
||||
"LTTNG_NET_STREAM_END" : false,
|
||||
"COUNTER_NET_SERVER_CONNECTION_CLOSE" : false,
|
||||
"DTRACE_NET_SERVER_CONNECTION" : false,
|
||||
"LTTNG_NET_SERVER_CONNECTION" : false,
|
||||
"COUNTER_NET_SERVER_CONNECTION" : false
|
||||
}
|
||||
}
|
||||
@@ -8,11 +8,16 @@ jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/setup-node@v3
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: lts/*
|
||||
- run: npm install
|
||||
- name: Install Docker Compose
|
||||
run: |
|
||||
sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
|
||||
sudo chmod +x /usr/local/bin/docker-compose
|
||||
docker-compose --version
|
||||
- run: npm run jslint
|
||||
- run: sudo apt update && sudo apt install -y squid
|
||||
- run: sudo cp test/squid.conf /etc/squid/squid.conf
|
||||
@@ -32,5 +37,7 @@ jobs:
|
||||
ELEVENLABS_API_KEY: ${{ secrets.ELEVENLABS_API_KEY }}
|
||||
ELEVENLABS_VOICE_ID: ${{ secrets.ELEVENLABS_VOICE_ID }}
|
||||
ELEVENLABS_MODEL_ID: ${{ secrets.ELEVENLABS_MODEL_ID }}
|
||||
PLAYHT_USER_ID: ${{ secrets.PLAYHT_USER_ID }}
|
||||
PLAYHT_API_KEY: ${{ secrets.PLAYHT_API_KEY }}
|
||||
JAMBONES_HTTP_PROXY_IP: 127.0.0.1
|
||||
JAMBONES_HTTP_PROXY_PORT: 3128
|
||||
|
||||
@@ -39,3 +39,5 @@ node_modules
|
||||
examples/*
|
||||
|
||||
.vscode
|
||||
|
||||
.env
|
||||
@@ -0,0 +1,3 @@
|
||||
#npm audit
|
||||
npm run jslint:fix || true
|
||||
npm test
|
||||
@@ -0,0 +1,140 @@
|
||||
const promise = require('eslint-plugin-promise');
|
||||
const globals = require('globals');
|
||||
|
||||
|
||||
module.exports = [
|
||||
{
|
||||
files: ['**/*.js', '*.js'],
|
||||
languageOptions: {
|
||||
|
||||
ecmaVersion: 2020,
|
||||
parserOptions: {
|
||||
'node': true,
|
||||
'es6': true,
|
||||
ecmaFeatures: {
|
||||
jsx: false,
|
||||
modules: false,
|
||||
}
|
||||
},
|
||||
sourceType: 'module',
|
||||
globals: {
|
||||
...globals.node,
|
||||
'DTRACE_HTTP_CLIENT_REQUEST': false,
|
||||
'LTTNG_HTTP_CLIENT_REQUEST': false,
|
||||
'COUNTER_HTTP_CLIENT_REQUEST': false,
|
||||
'DTRACE_HTTP_CLIENT_RESPONSE': false,
|
||||
'LTTNG_HTTP_CLIENT_RESPONSE': false,
|
||||
'COUNTER_HTTP_CLIENT_RESPONSE': false,
|
||||
'DTRACE_HTTP_SERVER_REQUEST': false,
|
||||
'LTTNG_HTTP_SERVER_REQUEST': false,
|
||||
'COUNTER_HTTP_SERVER_REQUEST': false,
|
||||
'DTRACE_HTTP_SERVER_RESPONSE': false,
|
||||
'LTTNG_HTTP_SERVER_RESPONSE': false,
|
||||
'COUNTER_HTTP_SERVER_RESPONSE': false,
|
||||
'DTRACE_NET_STREAM_END': false,
|
||||
'LTTNG_NET_STREAM_END': false,
|
||||
'COUNTER_NET_SERVER_CONNECTION_CLOSE': false,
|
||||
'DTRACE_NET_SERVER_CONNECTION': false,
|
||||
'LTTNG_NET_SERVER_CONNECTION': false,
|
||||
'COUNTER_NET_SERVER_CONNECTION': false
|
||||
},
|
||||
|
||||
},
|
||||
'plugins': {
|
||||
promise
|
||||
},
|
||||
'rules': {
|
||||
'promise/always-return': 'error',
|
||||
'promise/no-return-wrap': 'error',
|
||||
'promise/param-names': 'error',
|
||||
'promise/catch-or-return': 'error',
|
||||
'promise/no-native': 'off',
|
||||
'promise/no-nesting': 'warn',
|
||||
'promise/no-promise-in-callback': 'warn',
|
||||
'promise/no-callback-in-promise': 'warn',
|
||||
'promise/no-return-in-finally': 'warn',
|
||||
|
||||
// Possible Errors
|
||||
// http://eslint.org/docs/rules/#possible-errors
|
||||
'comma-dangle': [2, 'only-multiline'],
|
||||
'no-control-regex': 2,
|
||||
'no-debugger': 2,
|
||||
'no-dupe-args': 2,
|
||||
'no-dupe-keys': 2,
|
||||
'no-duplicate-case': 2,
|
||||
'no-empty-character-class': 2,
|
||||
'no-ex-assign': 2,
|
||||
'no-extra-boolean-cast': 2,
|
||||
'no-extra-parens': [2, 'functions'],
|
||||
'no-extra-semi': 2,
|
||||
'no-func-assign': 2,
|
||||
'no-invalid-regexp': 2,
|
||||
'no-irregular-whitespace': 2,
|
||||
'no-negated-in-lhs': 2,
|
||||
'no-obj-calls': 2,
|
||||
'no-proto': 2,
|
||||
'no-unexpected-multiline': 2,
|
||||
'no-unreachable': 2,
|
||||
'use-isnan': 2,
|
||||
'valid-typeof': 2,
|
||||
|
||||
// Best Practices
|
||||
// http://eslint.org/docs/rules/#best-practices
|
||||
'no-fallthrough': 2,
|
||||
'no-octal': 2,
|
||||
'no-redeclare': 2,
|
||||
'no-self-assign': 2,
|
||||
'no-unused-labels': 2,
|
||||
|
||||
// Strict Mode
|
||||
// http://eslint.org/docs/rules/#strict-mode
|
||||
'strict': [2, 'never'],
|
||||
|
||||
// Variables
|
||||
// http://eslint.org/docs/rules/#variables
|
||||
'no-delete-var': 2,
|
||||
'no-undef': 2,
|
||||
'no-unused-vars': [2, { 'args': 'none' }],
|
||||
|
||||
// Node.js and CommonJS
|
||||
// http://eslint.org/docs/rules/#nodejs-and-commonjs
|
||||
'no-mixed-requires': 2,
|
||||
'no-new-require': 2,
|
||||
'no-path-concat': 2,
|
||||
'no-restricted-modules': [2, 'sys', '_linklist'],
|
||||
|
||||
// Stylistic Issues
|
||||
// http://eslint.org/docs/rules/#stylistic-issues
|
||||
'comma-spacing': 2,
|
||||
'eol-last': 2,
|
||||
'indent': [2, 2, { 'SwitchCase': 1 }],
|
||||
'keyword-spacing': 2,
|
||||
'max-len': [2, 120, 2],
|
||||
'new-parens': 2,
|
||||
'no-mixed-spaces-and-tabs': 2,
|
||||
'no-multiple-empty-lines': [2, { 'max': 2 }],
|
||||
'no-trailing-spaces': [2, { 'skipBlankLines': false }],
|
||||
'quotes': [2, 'single', 'avoid-escape'],
|
||||
'semi': 2,
|
||||
'space-before-blocks': [2, 'always'],
|
||||
'space-before-function-paren': [2, 'never'],
|
||||
'space-in-parens': [2, 'never'],
|
||||
'space-infix-ops': 2,
|
||||
'space-unary-ops': 2,
|
||||
|
||||
// ECMAScript 6
|
||||
// http://eslint.org/docs/rules/#ecmascript-6
|
||||
'arrow-parens': [2, 'always'],
|
||||
'arrow-spacing': [2, { 'before': true, 'after': true }],
|
||||
'constructor-super': 2,
|
||||
'no-class-assign': 2,
|
||||
'no-confusing-arrow': 2,
|
||||
'no-const-assign': 2,
|
||||
'no-dupe-class-members': 2,
|
||||
'no-new-symbol': 2,
|
||||
'no-this-before-super': 2,
|
||||
'prefer-const': 2
|
||||
},
|
||||
'ignores': []
|
||||
}
|
||||
];
|
||||
@@ -13,10 +13,11 @@ module.exports = (opts, logger) => {
|
||||
getTtsSize: require('./lib/get-tts-size').bind(null, client, logger),
|
||||
purgeTtsCache: require('./lib/purge-tts-cache').bind(null, client, logger),
|
||||
addFileToCache: require('./lib/add-file-to-cache').bind(null, client, logger),
|
||||
synthAudio: require('./lib/synth-audio').bind(null, client, logger),
|
||||
synthAudio: require('./lib/synth-audio').bind(null, client, createHash, retrieveHash, logger),
|
||||
getVerbioAccessToken: require('./lib/get-verbio-token').bind(null, client, logger),
|
||||
getNuanceAccessToken: require('./lib/get-nuance-access-token').bind(null, client, logger),
|
||||
getIbmAccessToken: require('./lib/get-ibm-access-token').bind(null, client, logger),
|
||||
getAwsAuthToken: require('./lib/get-aws-sts-token').bind(null, logger, createHash, retrieveHash),
|
||||
getTtsVoices: require('./lib/get-tts-voices').bind(null, client, logger),
|
||||
getTtsVoices: require('./lib/get-tts-voices').bind(null, client, createHash, retrieveHash, logger),
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1,29 +1,61 @@
|
||||
const fs = require('fs/promises');
|
||||
const {noopLogger, makeSynthKey} = require('./utils');
|
||||
const EXPIRES = (process.env.JAMBONES_TTS_CACHE_DURATION_MINS || 4 * 60) * 60; // cache tts for 4 hours
|
||||
const {JAMBONES_TTS_CACHE_DURATION_MINS} = require('./config');
|
||||
const EXPIRES = JAMBONES_TTS_CACHE_DURATION_MINS;
|
||||
|
||||
function getExtensionAndSampleRate(path) {
|
||||
const match = path.match(/\.([^.]*)$/);
|
||||
if (!match) {
|
||||
//default should be wav file.
|
||||
return ['wav', 8000];
|
||||
}
|
||||
|
||||
const extension = match[1];
|
||||
const sampleRateMap = {
|
||||
r8: 8000,
|
||||
r16: 16000,
|
||||
r24: 24000,
|
||||
r44: 44100,
|
||||
r48: 48000,
|
||||
r96: 96000,
|
||||
};
|
||||
|
||||
const sampleRate = sampleRateMap[extension] || 8000;
|
||||
return [extension, sampleRate];
|
||||
}
|
||||
|
||||
async function addFileToCache(client, logger, path,
|
||||
{account_sid, vendor, language, voice, deploymentId, engine, text}) {
|
||||
{account_sid, vendor, language, voice, deploymentId, engine, model, text, instructions}) {
|
||||
let key;
|
||||
logger = logger || noopLogger;
|
||||
|
||||
try {
|
||||
const key = makeSynthKey({
|
||||
key = makeSynthKey({
|
||||
account_sid,
|
||||
vendor,
|
||||
language: language || '',
|
||||
voice: voice || deploymentId,
|
||||
engine,
|
||||
model,
|
||||
text,
|
||||
instructions
|
||||
});
|
||||
const audioBuffer = fs.readFile(path);
|
||||
await client.setex(key, EXPIRES, audioBuffer.toString('base64'));
|
||||
const [extension, sampleRate] = getExtensionAndSampleRate(path);
|
||||
const audioBuffer = await fs.readFile(path);
|
||||
await client.setex(key, EXPIRES, JSON.stringify(
|
||||
{
|
||||
audioContent: audioBuffer.toString('base64'),
|
||||
extension,
|
||||
sampleRate
|
||||
}
|
||||
));
|
||||
} catch (err) {
|
||||
logger.error(err, 'addFileToCache: Error');
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
|
||||
logger.debug(`addFileToCache: added ${path} to cache`);
|
||||
return true;
|
||||
logger.debug(`addFileToCache: added ${path} to cache with key ${key}`);
|
||||
return key;
|
||||
}
|
||||
|
||||
module.exports = addFileToCache;
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
const JAMBONES_TTS_TRIM_SILENCE = process.env.JAMBONES_TTS_TRIM_SILENCE;
|
||||
const JAMBONES_DISABLE_TTS_STREAMING = process.env.JAMBONES_DISABLE_TTS_STREAMING;
|
||||
const JAMBONES_DISABLE_AZURE_TTS_STREAMING = process.env.JAMBONES_DISABLE_AZURE_TTS_STREAMING;
|
||||
const JAMBONES_EAGERLY_PRE_CACHE_AUDIO = process.env.JAMBONES_EAGERLY_PRE_CACHE_AUDIO;
|
||||
const JAMBONES_AZURE_ENABLE_SSML = process.env.JAMBONES_AZURE_ENABLE_SSML;
|
||||
|
||||
const JAMBONES_HTTP_PROXY_IP = process.env.JAMBONES_HTTP_PROXY_IP;
|
||||
const JAMBONES_HTTP_PROXY_PORT = process.env.JAMBONES_HTTP_PROXY_PORT;
|
||||
const JAMBONES_TTS_CACHE_DURATION_MINS =
|
||||
(parseInt(process.env.JAMBONES_TTS_CACHE_DURATION_MINS) || 4 * 60) * 60; // cache tts for 4 hours
|
||||
|
||||
const TMP_FOLDER = process.env.JAMBONES_TMP_FOLDER || '/tmp';
|
||||
|
||||
const HTTP_TIMEOUT = 5000;
|
||||
|
||||
module.exports = {
|
||||
JAMBONES_TTS_TRIM_SILENCE,
|
||||
JAMBONES_DISABLE_TTS_STREAMING,
|
||||
JAMBONES_DISABLE_AZURE_TTS_STREAMING,
|
||||
JAMBONES_HTTP_PROXY_IP,
|
||||
JAMBONES_HTTP_PROXY_PORT,
|
||||
JAMBONES_TTS_CACHE_DURATION_MINS,
|
||||
JAMBONES_EAGERLY_PRE_CACHE_AUDIO,
|
||||
TMP_FOLDER,
|
||||
HTTP_TIMEOUT,
|
||||
JAMBONES_AZURE_ENABLE_SSML
|
||||
};
|
||||
+52
-19
@@ -1,38 +1,71 @@
|
||||
const { STSClient, GetSessionTokenCommand } = require('@aws-sdk/client-sts');
|
||||
const { STSClient, GetSessionTokenCommand, AssumeRoleCommand } = require('@aws-sdk/client-sts');
|
||||
const {makeAwsKey, noopLogger} = require('./utils');
|
||||
const debug = require('debug')('jambonz:speech-utils');
|
||||
const EXPIRY = 3600;
|
||||
const EXPIRY = process.env.AWS_STS_SESSION_DURATION || 3600;
|
||||
// by default reset aws session before expiry time 10 mins
|
||||
const CACHE_EXPIRY = process.env.AWS_STS_SESSION_RESET_EXPIRY || (EXPIRY - 600);
|
||||
|
||||
async function getAwsAuthToken(
|
||||
logger,
|
||||
createHash, retrieveHash,
|
||||
awsAccessKeyId, awsSecretAccessKey, awsRegion) {
|
||||
logger, createHash, retrieveHash,
|
||||
{speech_credential_sid, accessKeyId, secretAccessKey, region, roleArn}) {
|
||||
logger = logger || noopLogger;
|
||||
try {
|
||||
const key = makeAwsKey(awsAccessKeyId);
|
||||
// if incase instance profile is used, speech_credential_sid will be used as key to lookup cache
|
||||
const key = makeAwsKey(roleArn || accessKeyId || speech_credential_sid);
|
||||
const obj = await retrieveHash(key);
|
||||
if (obj) return {...obj, servedFromCache: true};
|
||||
|
||||
/* access token not found in cache, so generate it using STS */
|
||||
const stsClient = new STSClient({
|
||||
region: awsRegion,
|
||||
credentials: {
|
||||
accessKeyId: awsAccessKeyId,
|
||||
secretAccessKey: awsSecretAccessKey,
|
||||
let data;
|
||||
let expiry = CACHE_EXPIRY;
|
||||
if (roleArn) {
|
||||
const stsClient = new STSClient({ region });
|
||||
const roleToAssume = { RoleArn: roleArn, RoleSessionName: 'Jambonz_Speech', DurationSeconds: EXPIRY};
|
||||
const command = new AssumeRoleCommand(roleToAssume);
|
||||
|
||||
data = await stsClient.send(command);
|
||||
} else if (accessKeyId) {
|
||||
const stsClient = new STSClient({
|
||||
region,
|
||||
credentials: {
|
||||
accessKeyId,
|
||||
secretAccessKey,
|
||||
}
|
||||
});
|
||||
const command = new GetSessionTokenCommand({DurationSeconds: EXPIRY});
|
||||
data = await stsClient.send(command);
|
||||
} else {
|
||||
// instance profile is used.
|
||||
const stsClient = new STSClient({ region });
|
||||
const cred = await stsClient.config.credentials();
|
||||
// method in the AWS SDK automatically fetches credentials using the default credential
|
||||
// provider chain. If the credentials come from an instance profile or an environment
|
||||
// variable, their expiration is controlled by AWS and not explicitly by our code.
|
||||
if (cred && cred.expiration) {
|
||||
const currentTime = new Date();
|
||||
const expiryTime = new Date(cred.expiration);
|
||||
const remainingTimeInSeconds = Math.round((expiryTime - currentTime) / 1000);
|
||||
expiry = remainingTimeInSeconds;
|
||||
}
|
||||
});
|
||||
const command = new GetSessionTokenCommand({DurationSeconds: EXPIRY});
|
||||
const data = await stsClient.send(command);
|
||||
data = {
|
||||
Credentials: {
|
||||
AccessKeyId: cred.accessKeyId,
|
||||
SecretAccessKey: cred.secretAccessKey,
|
||||
SessionToken: cred.sessionToken
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
const credentials = {
|
||||
accessKeyId: data.Credentials.AccessKeyId,
|
||||
secretAccessKey: data.Credentials.SecretAccessKey,
|
||||
sessionToken: data.Credentials.SessionToken,
|
||||
securityToken: data.Credentials.SessionToken
|
||||
};
|
||||
|
||||
/* expire 10 minutes before the hour, so we don't lose the use of it during a call */
|
||||
createHash(key, credentials, EXPIRY - 600)
|
||||
.catch((err) => logger.error(err, `Error saving hash for key ${key}`));
|
||||
// Only cache if expiry is good
|
||||
if (expiry > 0) {
|
||||
createHash(key, credentials, expiry)
|
||||
.catch((err) => logger.error(err, `Error saving hash for key ${key}`));
|
||||
}
|
||||
|
||||
return {...credentials, servedFromCache: false};
|
||||
} catch (err) {
|
||||
|
||||
@@ -2,8 +2,8 @@ const formurlencoded = require('form-urlencoded');
|
||||
const {Pool} = require('undici');
|
||||
const pool = new Pool('https://iam.cloud.ibm.com');
|
||||
const {makeIbmKey, noopLogger} = require('./utils');
|
||||
const { HTTP_TIMEOUT } = require('./config');
|
||||
const debug = require('debug')('jambonz:realtimedb-helpers');
|
||||
const HTTP_TIMEOUT = 5000;
|
||||
|
||||
async function getIbmAccessToken(client, logger, apiKey) {
|
||||
logger = logger || noopLogger;
|
||||
|
||||
@@ -2,8 +2,8 @@ const formurlencoded = require('form-urlencoded');
|
||||
const {Pool} = require('undici');
|
||||
const pool = new Pool('https://auth.crt.nuance.com');
|
||||
const {makeNuanceKey, makeBasicAuthHeader, noopLogger} = require('./utils');
|
||||
const { HTTP_TIMEOUT } = require('./config');
|
||||
const debug = require('debug')('jambonz:realtimedb-helpers');
|
||||
const HTTP_TIMEOUT = 5000;
|
||||
|
||||
async function getNuanceAccessToken(client, logger, clientId, secret, scope) {
|
||||
logger = logger || noopLogger;
|
||||
|
||||
+54
-12
@@ -1,11 +1,16 @@
|
||||
const assert = require('assert');
|
||||
const {noopLogger, createNuanceClient, createKryptonClient} = require('./utils');
|
||||
const getNuanceAccessToken = require('./get-nuance-access-token');
|
||||
const getVerbioAccessToken = require('./get-verbio-token');
|
||||
const {GetVoicesRequest, Voice} = require('../stubs/nuance/synthesizer_pb');
|
||||
const TextToSpeechV1 = require('ibm-watson/text-to-speech/v1');
|
||||
const { IamAuthenticator } = require('ibm-watson/auth');
|
||||
const ttsGoogle = require('@google-cloud/text-to-speech');
|
||||
const { PollyClient, DescribeVoicesCommand } = require('@aws-sdk/client-polly');
|
||||
const getAwsAuthToken = require('./get-aws-sts-token');
|
||||
const {Pool} = require('undici');
|
||||
const { HTTP_TIMEOUT } = require('./config');
|
||||
const verbioVoicePool = new Pool('https://us.rest.speechcenter.verbio.com');
|
||||
|
||||
const getIbmVoices = async(client, logger, credentials) => {
|
||||
const {tts_region, tts_api_key} = credentials;
|
||||
@@ -87,16 +92,31 @@ const getGoogleVoices = async(_client, logger, credentials) => {
|
||||
return await client.listVoices();
|
||||
};
|
||||
|
||||
const getAwsVoices = async(_client, logger, credentials) => {
|
||||
const getAwsVoices = async(_client, createHash, retrieveHash, logger, credentials) => {
|
||||
try {
|
||||
const {region, accessKeyId, secretAccessKey} = credentials;
|
||||
const client = new PollyClient({
|
||||
region,
|
||||
credentials: {
|
||||
accessKeyId,
|
||||
secretAccessKey
|
||||
}
|
||||
});
|
||||
const {region, accessKeyId, secretAccessKey, roleArn} = credentials;
|
||||
let client = null;
|
||||
if (accessKeyId && secretAccessKey) {
|
||||
client = new PollyClient({
|
||||
region,
|
||||
credentials: {
|
||||
accessKeyId,
|
||||
secretAccessKey
|
||||
}
|
||||
});
|
||||
} else if (roleArn) {
|
||||
client = new PollyClient({
|
||||
region,
|
||||
credentials: await getAwsAuthToken(
|
||||
logger, createHash, retrieveHash,
|
||||
{
|
||||
region,
|
||||
roleArn
|
||||
}),
|
||||
});
|
||||
} else {
|
||||
client = new PollyClient({region});
|
||||
}
|
||||
const command = new DescribeVoicesCommand({});
|
||||
const response = await client.send(command);
|
||||
return response;
|
||||
@@ -106,6 +126,26 @@ const getAwsVoices = async(_client, logger, credentials) => {
|
||||
}
|
||||
};
|
||||
|
||||
const getVerbioVoices = async(client, logger, credentials) => {
|
||||
try {
|
||||
const access_token = await getVerbioAccessToken(client, logger, credentials);
|
||||
const { body} = await verbioVoicePool.request({
|
||||
path: '/api/v1/voices',
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Authorization': `Bearer ${access_token.access_token}`,
|
||||
'User-Agent': 'jambonz'
|
||||
},
|
||||
timeout: HTTP_TIMEOUT,
|
||||
followRedirects: false
|
||||
});
|
||||
return await body.json();
|
||||
} catch (err) {
|
||||
logger.info({err}, 'getVerbioVoices - failed to list voices for Verbio');
|
||||
throw err;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Synthesize speech to an mp3 file, and also cache the generated speech
|
||||
* in redis (base64 format) for 24 hours so as to avoid unnecessarily paying
|
||||
@@ -122,10 +162,10 @@ const getAwsVoices = async(_client, logger, credentials) => {
|
||||
* @returns object containing filepath to an mp3 file in the /tmp folder containing
|
||||
* the synthesized audio, and a variable indicating whether it was served from cache
|
||||
*/
|
||||
async function getTtsVoices(client, logger, {vendor, credentials}) {
|
||||
async function getTtsVoices(client, createHash, retrieveHash, logger, {vendor, credentials}) {
|
||||
logger = logger || noopLogger;
|
||||
|
||||
assert.ok(['nuance', 'ibm', 'google', 'aws', 'polly'].includes(vendor),
|
||||
assert.ok(['nuance', 'ibm', 'google', 'aws', 'polly', 'verbio'].includes(vendor),
|
||||
`getTtsVoices not supported for vendor ${vendor}`);
|
||||
|
||||
switch (vendor) {
|
||||
@@ -137,7 +177,9 @@ async function getTtsVoices(client, logger, {vendor, credentials}) {
|
||||
return getGoogleVoices(client, logger, credentials);
|
||||
case 'aws':
|
||||
case 'polly':
|
||||
return getAwsVoices(client, logger, credentials);
|
||||
return getAwsVoices(client, createHash, retrieveHash, logger, credentials);
|
||||
case 'verbio':
|
||||
return getVerbioVoices(client, logger, credentials);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
const {Pool} = require('undici');
|
||||
const { noopLogger, makeVerbioKey } = require('./utils');
|
||||
const { HTTP_TIMEOUT } = require('./config');
|
||||
const pool = new Pool('https://auth.speechcenter.verbio.com:444');
|
||||
const debug = require('debug')('jambonz:realtimedb-helpers');
|
||||
|
||||
async function getVerbioAccessToken(client, logger, credentials) {
|
||||
logger = logger || noopLogger;
|
||||
const { client_id, client_secret } = credentials;
|
||||
try {
|
||||
const key = makeVerbioKey(client_id);
|
||||
const access_token = await client.get(key);
|
||||
if (access_token) {
|
||||
return {access_token, servedFromCache: true};
|
||||
}
|
||||
|
||||
const payload = {
|
||||
client_id,
|
||||
client_secret
|
||||
};
|
||||
|
||||
const {statusCode, headers, body} = await pool.request({
|
||||
path: '/api/v1/token',
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'User-Agent': 'jambonz'
|
||||
},
|
||||
body: JSON.stringify(payload),
|
||||
timeout: HTTP_TIMEOUT,
|
||||
followRedirects: false
|
||||
});
|
||||
|
||||
if (200 !== statusCode) {
|
||||
logger.debug({statusCode, headers, body: await body.text()}, 'error fetching access token from Verbio');
|
||||
const err = new Error();
|
||||
err.statusCode = statusCode;
|
||||
throw err;
|
||||
}
|
||||
const json = await body.json();
|
||||
const expiry = Math.floor(json.expiration_time - Date.now() / 1000 - 30);
|
||||
await client.set(key, json.access_token, 'EX', expiry);
|
||||
return {...json, servedFromCache: false};
|
||||
} catch (err) {
|
||||
debug(err, `getVerbioAccessToken: Error retrieving Verbio access token for client_id ${client_id}`);
|
||||
logger.error(err, `getVerbioAccessToken: Error retrieving Verbio access token for client_id ${client_id}`);
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = getVerbioAccessToken;
|
||||
@@ -12,7 +12,7 @@ const debug = require('debug')('jambonz:realtimedb-helpers');
|
||||
* @returns {object} result - {error, purgedCount}
|
||||
*/
|
||||
async function purgeTtsCache(client, logger, {all, account_sid, vendor,
|
||||
language, voice, deploymentId, engine, text} = {all: true}) {
|
||||
language, voice, deploymentId, engine, model, text, instructions} = {all: true}) {
|
||||
logger = logger || noopLogger;
|
||||
|
||||
let purgedCount = 0, error;
|
||||
@@ -33,7 +33,9 @@ async function purgeTtsCache(client, logger, {all, account_sid, vendor,
|
||||
language: language || '',
|
||||
voice: voice || deploymentId,
|
||||
engine,
|
||||
model,
|
||||
text,
|
||||
instructions
|
||||
});
|
||||
purgedCount = await client.del(key);
|
||||
if (purgedCount === 0) error = 'Specified item not found';
|
||||
|
||||
+811
-125
File diff suppressed because it is too large
Load Diff
+36
-5
@@ -3,10 +3,10 @@ const {SynthesizerClient} = require('../stubs/nuance/synthesizer_grpc_pb');
|
||||
const {RivaSpeechSynthesisClient} = require('../stubs/riva/proto/riva_tts_grpc_pb');
|
||||
const {Pool} = require('undici');
|
||||
const pool = new Pool('https://auth.crt.nuance.com');
|
||||
const HTTP_TIMEOUT = 5000;
|
||||
const NUANCE_AUTH_ENDPOINT = 'tts.api.nuance.com:443';
|
||||
const grpc = require('@grpc/grpc-js');
|
||||
const formurlencoded = require('form-urlencoded');
|
||||
const { TMP_FOLDER, HTTP_TIMEOUT } = require('./config');
|
||||
|
||||
const debug = require('debug')('jambonz:realtimedb-helpers');
|
||||
/**
|
||||
@@ -16,12 +16,29 @@ const debug = require('debug')('jambonz:realtimedb-helpers');
|
||||
*/
|
||||
//const nuanceClientMap = new Map();
|
||||
|
||||
function makeSynthKey({account_sid = '', vendor, language, voice, engine = '', text}) {
|
||||
function makeSynthKey({
|
||||
account_sid = '',
|
||||
vendor,
|
||||
language,
|
||||
voice,
|
||||
engine = '',
|
||||
model = '',
|
||||
text,
|
||||
instructions = '',
|
||||
}) {
|
||||
const hash = crypto.createHash('sha1');
|
||||
hash.update(`${language}:${vendor}:${voice}:${engine}:${text}`);
|
||||
return `tts${account_sid ? (':' + account_sid) : ''}:${hash.digest('hex')}`;
|
||||
hash.update(`${language}:${vendor}:${voice}:${engine}:${model}:${text}:${instructions}`);
|
||||
const hexHashKey = hash.digest('hex');
|
||||
const accountKey = account_sid ? `:${account_sid}` : '';
|
||||
const key = `tts${accountKey}:${hexHashKey}`;
|
||||
return key;
|
||||
}
|
||||
|
||||
function makeFilePath({key, salt = '', extension}) {
|
||||
return `${TMP_FOLDER}/${key.replace('tts:', `tts-${salt}`)}.${extension}`;
|
||||
}
|
||||
|
||||
|
||||
const noopLogger = {
|
||||
info: () => {},
|
||||
debug: () => {},
|
||||
@@ -49,6 +66,17 @@ function makeAwsKey(awsAccessKeyId) {
|
||||
return `aws:${hash.digest('hex')}`;
|
||||
}
|
||||
|
||||
function makePlayhtKey(apiKey) {
|
||||
const hash = crypto.createHash('sha1');
|
||||
hash.update(apiKey);
|
||||
return `playht:${hash.digest('hex')}`;
|
||||
}
|
||||
function makeVerbioKey(client_id) {
|
||||
const hash = crypto.createHash('sha1');
|
||||
hash.update(client_id);
|
||||
return `verbio:${hash.digest('hex')}`;
|
||||
}
|
||||
|
||||
function makeNuanceKey(clientId, secret, scope) {
|
||||
const hash = crypto.createHash('sha1');
|
||||
hash.update(`${clientId}:${secret}:${scope}`);
|
||||
@@ -116,12 +144,15 @@ module.exports = {
|
||||
makeSynthKey,
|
||||
makeNuanceKey,
|
||||
makeIbmKey,
|
||||
makePlayhtKey,
|
||||
makeAwsKey,
|
||||
makeVerbioKey,
|
||||
getNuanceAccessToken,
|
||||
createNuanceClient,
|
||||
createKryptonClient,
|
||||
createRivaClient,
|
||||
makeBasicAuthHeader,
|
||||
NUANCE_AUTH_ENDPOINT,
|
||||
noopLogger
|
||||
noopLogger,
|
||||
makeFilePath
|
||||
};
|
||||
|
||||
Generated
+2709
-2893
File diff suppressed because it is too large
Load Diff
+17
-12
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@jambonz/speech-utils",
|
||||
"version": "0.0.37",
|
||||
"version": "0.2.18",
|
||||
"description": "TTS-related speech utilities for jambonz",
|
||||
"main": "index.js",
|
||||
"author": "Dave Horton",
|
||||
@@ -12,7 +12,9 @@
|
||||
"test": "NODE_ENV=test node test/ ",
|
||||
"coverage": "nyc --reporter html --report-dir ./coverage npm run test",
|
||||
"jslint": "eslint index.js lib",
|
||||
"build": "./build_stubs.sh"
|
||||
"jslint:fix": "npm run jslint --fix",
|
||||
"build": "./build_stubs.sh",
|
||||
"prepare": "husky"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@@ -24,26 +26,29 @@
|
||||
},
|
||||
"homepage": "https://github.com/jambonz/speech-utils#readme",
|
||||
"dependencies": {
|
||||
"23": "^0.0.0",
|
||||
"@aws-sdk/client-polly": "^3.496.0",
|
||||
"@aws-sdk/client-sts": "^3.496.0",
|
||||
"@google-cloud/text-to-speech": "^5.0.2",
|
||||
"@cartesia/cartesia-js": "^2.1.0",
|
||||
"@google-cloud/text-to-speech": "^5.5.0",
|
||||
"@grpc/grpc-js": "^1.9.14",
|
||||
"@jambonz/realtimedb-helpers": "^0.8.7",
|
||||
"bent": "^7.3.12",
|
||||
"debug": "^4.3.4",
|
||||
"form-urlencoded": "^6.1.4",
|
||||
"google-protobuf": "^3.21.2",
|
||||
"ibm-watson": "^8.0.0",
|
||||
"microsoft-cognitiveservices-speech-sdk": "1.34.0",
|
||||
"openai": "^4.25.0",
|
||||
"undici": "^6.4.0"
|
||||
"ibm-watson": "^11.0.0",
|
||||
"microsoft-cognitiveservices-speech-sdk": "1.38.0",
|
||||
"openai": "^4.98.0",
|
||||
"undici": "^7.5.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"config": "^3.3.10",
|
||||
"eslint": "^8.56.0",
|
||||
"eslint-plugin-promise": "^6.1.1",
|
||||
"config": "^3.3.11",
|
||||
"eslint": "^9.3.0",
|
||||
"eslint-plugin-promise": "^6.2.0",
|
||||
"husky": "^9.0.11",
|
||||
"nyc": "^15.1.0",
|
||||
"pino": "^8.17.0",
|
||||
"tape": "^5.7.3"
|
||||
"pino": "^9.1.0",
|
||||
"tape": "^5.7.5"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,9 +62,9 @@ function deserialize_nuance_tts_v1_UnarySynthesisResponse(buffer_arg) {
|
||||
|
||||
//
|
||||
// The Synthesizer service offers these functionalities:
|
||||
// - GetVoices: Queries the list of available voices, with filters to reduce the search space.
|
||||
// - Synthesize: Synthesizes audio from input text and parameters, and returns an audio stream.
|
||||
// - UnarySynthesize: Synthesizes audio from input text and parameters, and returns a single audio response.
|
||||
// - GetVoices: Queries the list of available voices, with filters to reduce the search space.
|
||||
// - Synthesize: Synthesizes audio from input text and parameters, and returns an audio stream.
|
||||
// - UnarySynthesize: Synthesizes audio from input text and parameters, and returns a single audio response.
|
||||
var SynthesizerService = exports.SynthesizerService = {
|
||||
getVoices: {
|
||||
path: '/nuance.tts.v1.Synthesizer/GetVoices',
|
||||
|
||||
@@ -1 +1 @@
|
||||
// GENERATED CODE -- NO SERVICES IN PROTO
|
||||
// GENERATED CODE -- NO SERVICES IN PROTO
|
||||
|
||||
@@ -57,7 +57,7 @@ function deserialize_nvidia_riva_tts_SynthesizeSpeechResponse(buffer_arg) {
|
||||
var RivaSpeechSynthesisService = exports.RivaSpeechSynthesisService = {
|
||||
// Used to request text-to-speech from the service. Submit a request containing the
|
||||
// desired text and configuration, and receive audio bytes in the requested format.
|
||||
synthesize: {
|
||||
synthesize: {
|
||||
path: '/nvidia.riva.tts.RivaSpeechSynthesis/Synthesize',
|
||||
requestStream: false,
|
||||
responseStream: false,
|
||||
@@ -69,9 +69,9 @@ synthesize: {
|
||||
responseDeserialize: deserialize_nvidia_riva_tts_SynthesizeSpeechResponse,
|
||||
},
|
||||
// Used to request text-to-speech returned via stream as it becomes available.
|
||||
// Submit a SynthesizeSpeechRequest with desired text and configuration,
|
||||
// and receive stream of bytes in the requested format.
|
||||
synthesizeOnline: {
|
||||
// Submit a SynthesizeSpeechRequest with desired text and configuration,
|
||||
// and receive stream of bytes in the requested format.
|
||||
synthesizeOnline: {
|
||||
path: '/nvidia.riva.tts.RivaSpeechSynthesis/SynthesizeOnline',
|
||||
requestStream: false,
|
||||
responseStream: true,
|
||||
@@ -83,7 +83,7 @@ synthesizeOnline: {
|
||||
responseDeserialize: deserialize_nvidia_riva_tts_SynthesizeSpeechResponse,
|
||||
},
|
||||
// Enables clients to request the configuration of the current Synthesize service, or a specific model within the service.
|
||||
getRivaSynthesisConfig: {
|
||||
getRivaSynthesisConfig: {
|
||||
path: '/nvidia.riva.tts.RivaSpeechSynthesis/GetRivaSynthesisConfig',
|
||||
requestStream: false,
|
||||
responseStream: false,
|
||||
|
||||
+10
-2
@@ -19,12 +19,20 @@ test('AWS - create and cache auth token', async(t) => {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
let obj = await getAwsAuthToken(process.env.AWS_ACCESS_KEY_ID, process.env.AWS_SECRET_ACCESS_KEY, process.env.AWS_REGION);
|
||||
let obj = await getAwsAuthToken({
|
||||
accessKeyId: process.env.AWS_ACCESS_KEY_ID,
|
||||
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
|
||||
region: process.env.AWS_REGION
|
||||
});
|
||||
//console.log({obj}, 'received auth token from AWS');
|
||||
t.ok(obj.securityToken && !obj.servedFromCache, 'successfullY generated auth token from AWS');
|
||||
|
||||
await sleep(250);
|
||||
obj = await getAwsAuthToken(process.env.AWS_ACCESS_KEY_ID, process.env.AWS_SECRET_ACCESS_KEY, process.env.AWS_REGION);
|
||||
obj = await getAwsAuthToken({
|
||||
accessKeyId: process.env.AWS_ACCESS_KEY_ID,
|
||||
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
|
||||
region: process.env.AWS_REGION
|
||||
});
|
||||
//console.log({obj}, 'received auth token from AWS - second request');
|
||||
t.ok(obj.securityToken && obj.servedFromCache, 'successfully received access token from cache');
|
||||
|
||||
|
||||
@@ -12,6 +12,32 @@ const stats = {
|
||||
histogram: () => {}
|
||||
};
|
||||
|
||||
test('Verbio - get Access key and voices', async(t) => {
|
||||
const fn = require('..');
|
||||
const {client, getTtsVoices, getVerbioAccessToken} = fn(opts, logger);
|
||||
if (!process.env.VERBIO_CLIENT_ID || !process.env.VERBIO_CLIENT_SECRET) {
|
||||
t.pass('skipping Verbio test since no Verbio Keys provided');
|
||||
t.end();
|
||||
client.quit();
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const credentials = {
|
||||
client_id: process.env.VERBIO_CLIENT_ID,
|
||||
client_secret: process.env.VERBIO_CLIENT_SECRET
|
||||
};
|
||||
let obj = await getVerbioAccessToken(credentials);
|
||||
t.ok(obj.access_token , 'successfully received access token not from cache');
|
||||
const voices = await getTtsVoices({vendor: 'verbio', credentials});
|
||||
t.ok(voices && voices.length != 0, 'successfully received verbio voices');
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
t.end(err);
|
||||
}
|
||||
client.quit();
|
||||
});
|
||||
|
||||
test('IBM - create access key', async(t) => {
|
||||
const fn = require('..');
|
||||
const {client, getIbmAccessToken} = fn(opts, logger);
|
||||
|
||||
+410
-16
@@ -5,7 +5,7 @@ const fs = require('fs');
|
||||
const {makeSynthKey} = require('../lib/utils');
|
||||
const logger = require('pino')();
|
||||
const bent = require('bent');
|
||||
const getJSON = bent('json')
|
||||
const getJSON = bent('json');
|
||||
|
||||
process.on('unhandledRejection', (reason, p) => {
|
||||
console.log('Unhandled Rejection at: Promise', p, 'reason:', reason);
|
||||
@@ -91,14 +91,17 @@ test('Google speech Custom voice synth tests', async(t) => {
|
||||
const fn = require('..');
|
||||
const {synthAudio, client} = fn(opts, logger);
|
||||
|
||||
if (!process.env.GCP_CUSTOM_VOICE_FILE && !process.env.GCP_CUSTOM_VOICE_JSON_KEY || !process.env.GCP_CUSTOM_VOICE_MODEL) {
|
||||
t.pass('skipping google speech synth tests since neither GCP_CUSTOM_VOICE_FILE nor GCP_CUSTOM_VOICE_JSON_KEY provided, GCP_CUSTOM_VOICE_MODEL is not provided');
|
||||
if (!process.env.GCP_CUSTOM_VOICE_FILE &&
|
||||
!process.env.GCP_CUSTOM_VOICE_JSON_KEY ||
|
||||
!process.env.GCP_CUSTOM_VOICE_MODEL) {
|
||||
t.pass(`skipping google speech synth tests since neither
|
||||
GCP_CUSTOM_VOICE_FILE nor GCP_CUSTOM_VOICE_JSON_KEY provided, GCP_CUSTOM_VOICE_MODEL is not provided`);
|
||||
return t.end();
|
||||
}
|
||||
try {
|
||||
const str = process.env.GCP_CUSTOM_VOICE_JSON_KEY || fs.readFileSync(process.env.GCP_CUSTOM_VOICE_FILE);
|
||||
const creds = JSON.parse(str);
|
||||
let opts = await synthAudio(stats, {
|
||||
const opts = await synthAudio(stats, {
|
||||
vendor: 'google',
|
||||
credentials: {
|
||||
credentials: {
|
||||
@@ -109,7 +112,7 @@ test('Google speech Custom voice synth tests', async(t) => {
|
||||
language: 'en-AU',
|
||||
text: 'This is a test. This is only a test',
|
||||
voice: {
|
||||
reportedUsage:"REALTIME",
|
||||
reportedUsage: 'REALTIME',
|
||||
model: process.env.GCP_CUSTOM_VOICE_MODEL
|
||||
}
|
||||
});
|
||||
@@ -121,6 +124,48 @@ test('Google speech Custom voice synth tests', async(t) => {
|
||||
client.quit();
|
||||
});
|
||||
|
||||
test('Google speech voice cloning synth tests', async(t) => {
|
||||
const fn = require('..');
|
||||
const {synthAudio, client} = fn(opts, logger);
|
||||
|
||||
if (!process.env.GCP_CUSTOM_VOICE_FILE &&
|
||||
!process.env.GCP_CUSTOM_VOICE_JSON_KEY ||
|
||||
!process.env.GCP_VOICE_CLONING_FILE &&
|
||||
!process.env.GCP_VOICE_CLONING_JSON_KEY) {
|
||||
t.pass(`skipping google speech synth tests since neither
|
||||
GCP_CUSTOM_VOICE_FILE nor GCP_CUSTOM_VOICE_JSON_KEY provided,
|
||||
GCP_VOICE_CLONING_FILE nor GCP_VOICE_CLONING_JSON_KEY is not provided`);
|
||||
return t.end();
|
||||
}
|
||||
try {
|
||||
const googleKey = process.env.GCP_CUSTOM_VOICE_JSON_KEY ||
|
||||
fs.readFileSync(process.env.GCP_CUSTOM_VOICE_FILE);
|
||||
const voice_cloning_key = process.env.GCP_VOICE_CLONING_JSON_KEY ||
|
||||
fs.readFileSync(process.env.GCP_VOICE_CLONING_FILE).toString();
|
||||
const creds = JSON.parse(googleKey);
|
||||
const opts = await synthAudio(stats, {
|
||||
vendor: 'google',
|
||||
credentials: {
|
||||
credentials: {
|
||||
client_email: creds.client_email,
|
||||
private_key: creds.private_key,
|
||||
project_id: creds.project_id
|
||||
},
|
||||
},
|
||||
language: 'en-US',
|
||||
text: 'This is a test. This is only a test. This is a test. This is only a test. This is a test. This is only a test',
|
||||
voice: {
|
||||
voice_cloning_key
|
||||
}
|
||||
});
|
||||
t.ok(!opts.servedFromCache, `successfully synthesized google voice cloning audio to ${opts.filePath}`);
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
t.end(err);
|
||||
}
|
||||
client.quit();
|
||||
});
|
||||
|
||||
test('AWS speech synth tests', async(t) => {
|
||||
const fn = require('..');
|
||||
const {synthAudio, client} = fn(opts, logger);
|
||||
@@ -140,6 +185,7 @@ test('AWS speech synth tests', async(t) => {
|
||||
language: 'en-US',
|
||||
voice: 'Joey',
|
||||
text: 'This is a test. This is only a test',
|
||||
renderForCaching: true,
|
||||
});
|
||||
t.ok(!opts.servedFromCache, `successfully synthesized aws audio to ${opts.filePath}`);
|
||||
|
||||
@@ -153,6 +199,7 @@ test('AWS speech synth tests', async(t) => {
|
||||
language: 'en-US',
|
||||
voice: 'Joey',
|
||||
text: 'This is a test. This is only a test',
|
||||
renderForCaching: true,
|
||||
});
|
||||
t.ok(opts.servedFromCache, `successfully retrieved aws audio from cache ${opts.filePath}`);
|
||||
} catch (err) {
|
||||
@@ -162,6 +209,33 @@ test('AWS speech synth tests', async(t) => {
|
||||
client.quit();
|
||||
});
|
||||
|
||||
test('AWS speech synth tests by RoleArn', async(t) => {
|
||||
const fn = require('..');
|
||||
const {synthAudio, client} = fn(opts, logger);
|
||||
|
||||
if (!process.env.AWS_ROLE_ARN || !process.env.AWS_REGION) {
|
||||
t.pass('skipping AWS speech synth tests by RoleArn since AWS_ROLE_ARN or AWS_REGION not provided');
|
||||
return t.end();
|
||||
}
|
||||
try {
|
||||
let opts = await synthAudio(stats, {
|
||||
vendor: 'aws',
|
||||
credentials: {
|
||||
roleArn: process.env.AWS_ROLE_ARN,
|
||||
region: process.env.AWS_REGION,
|
||||
},
|
||||
language: 'en-US',
|
||||
voice: 'Joey',
|
||||
text: 'This is a test. This is only a test',
|
||||
});
|
||||
t.ok(!opts.servedFromCache, `successfully synthesized aws by roleArn audio to ${opts.filePath}`);
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
t.end(err);
|
||||
}
|
||||
client.quit();
|
||||
});
|
||||
|
||||
test('Azure speech synth tests', async(t) => {
|
||||
const fn = require('..');
|
||||
const {synthAudio, client} = fn(opts, logger);
|
||||
@@ -188,6 +262,7 @@ test('Azure speech synth tests', async(t) => {
|
||||
language: 'en-US',
|
||||
voice: 'en-US-ChristopherNeural',
|
||||
text: longText,
|
||||
renderForCaching: true
|
||||
});
|
||||
t.ok(!opts.servedFromCache, `successfully synthesized microsoft audio to ${opts.filePath}`);
|
||||
if (process.env.JAMBONES_HTTP_PROXY_IP && process.env.JAMBONES_HTTP_PROXY_PORT) {
|
||||
@@ -203,6 +278,7 @@ test('Azure speech synth tests', async(t) => {
|
||||
language: 'en-US',
|
||||
voice: 'en-US-ChristopherNeural',
|
||||
text: longText,
|
||||
renderForCaching: true
|
||||
});
|
||||
t.ok(opts.servedFromCache, `successfully retrieved microsoft audio from cache ${opts.filePath}`);
|
||||
} catch (err) {
|
||||
@@ -212,6 +288,58 @@ test('Azure speech synth tests', async(t) => {
|
||||
client.quit();
|
||||
});
|
||||
|
||||
test('Azure SSML tests', async(t) => {
|
||||
const fn = require('..');
|
||||
const {synthAudio, client} = fn(opts, logger);
|
||||
|
||||
if (!process.env.MICROSOFT_API_KEY || !process.env.MICROSOFT_REGION) {
|
||||
t.pass('skipping Microsoft speech synth tests since MICROSOFT_API_KEY or MICROSOFT_REGION not provided');
|
||||
return t.end();
|
||||
}
|
||||
try {
|
||||
const text = `<speak version="1.0" xmlns="http://www.w3.org/2001/10/synthesis" xmlns:mstts="https://www.w3.org/2001/mstts" xml:lang="en-US">
|
||||
<voice name="en-US-JennyMultilingualNeural">
|
||||
<mstts:express-as style="cheerful" styledegree="2">That'd be just amazing!
|
||||
</mstts:express-as>
|
||||
</voice>
|
||||
</speak>`;
|
||||
|
||||
let opts = await synthAudio(stats, {
|
||||
vendor: 'microsoft',
|
||||
credentials: {
|
||||
api_key: process.env.MICROSOFT_API_KEY,
|
||||
region: process.env.MICROSOFT_REGION,
|
||||
},
|
||||
language: 'en-US',
|
||||
voice: 'en-US-ChristopherNeural',
|
||||
text,
|
||||
renderForCaching: true
|
||||
});
|
||||
t.ok(!opts.servedFromCache, `successfully synthesized microsoft audio to ${opts.filePath}`);
|
||||
if (process.env.JAMBONES_HTTP_PROXY_IP && process.env.JAMBONES_HTTP_PROXY_PORT) {
|
||||
t.pass('successfully used proxy to reach microsoft tts service');
|
||||
}
|
||||
|
||||
opts = await synthAudio(stats, {
|
||||
vendor: 'microsoft',
|
||||
credentials: {
|
||||
api_key: process.env.MICROSOFT_API_KEY,
|
||||
region: process.env.MICROSOFT_REGION,
|
||||
},
|
||||
language: 'en-US',
|
||||
voice: 'en-US-ChristopherNeural',
|
||||
text,
|
||||
renderForCaching: true
|
||||
});
|
||||
t.ok(opts.servedFromCache, `successfully retrieved microsoft audio from cache ${opts.filePath}`);
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
t.end(err);
|
||||
}
|
||||
client.quit();
|
||||
});
|
||||
|
||||
|
||||
test('Azure custom voice speech synth tests', async(t) => {
|
||||
const fn = require('..');
|
||||
const {synthAudio, client} = fn(opts, logger);
|
||||
@@ -233,6 +361,7 @@ test('Azure custom voice speech synth tests', async(t) => {
|
||||
language: 'en-US',
|
||||
voice: process.env.MICROSOFT_CUSTOM_VOICE,
|
||||
text,
|
||||
renderForCaching: true
|
||||
});
|
||||
t.ok(!opts.servedFromCache, `successfully synthesized microsoft audio to ${opts.filePath}`);
|
||||
|
||||
@@ -247,6 +376,7 @@ test('Azure custom voice speech synth tests', async(t) => {
|
||||
language: 'en-US',
|
||||
voice: process.env.MICROSOFT_CUSTOM_VOICE,
|
||||
text,
|
||||
renderForCaching: true
|
||||
});
|
||||
t.ok(opts.servedFromCache, `successfully retrieved microsoft custom voice audio from cache ${opts.filePath}`);
|
||||
} catch (err) {
|
||||
@@ -426,6 +556,7 @@ test('Custom Vendor speech synth tests', async(t) => {
|
||||
text: 'This is a test. This is only a test',
|
||||
});
|
||||
t.ok(!opts.servedFromCache, `successfully synthesized custom vendor audio to ${opts.filePath}`);
|
||||
t.ok(opts.filePath.endsWith('wav'), 'audio is cached as wav file');
|
||||
let obj = await getJSON(`http://127.0.0.1:3100/lastRequest/somethingnew`);
|
||||
t.ok(obj.headers.Authorization == 'Bearer some_jwt_token', 'Custom Vendor Authentication Header is correct');
|
||||
t.ok(obj.body.language == 'en-US', 'Custom Vendor Language is correct');
|
||||
@@ -433,6 +564,21 @@ test('Custom Vendor speech synth tests', async(t) => {
|
||||
t.ok(obj.body.type == 'text', 'Custom Vendor type is correct');
|
||||
t.ok(obj.body.text == 'This is a test. This is only a test', 'Custom Vendor text is correct');
|
||||
|
||||
// Checking if cache is stored with wav format
|
||||
opts = await synthAudio(stats, {
|
||||
vendor: 'custom:somethingnew',
|
||||
credentials: {
|
||||
use_for_tts: 1,
|
||||
custom_tts_url: "http://127.0.0.1:3100/somethingnew",
|
||||
auth_token: 'some_jwt_token'
|
||||
},
|
||||
language: 'en-US',
|
||||
voice: 'English-US.Female-1',
|
||||
text: 'This is a test. This is only a test',
|
||||
});
|
||||
t.ok(opts.servedFromCache, `successfully get custom vendor cached audio to ${opts.filePath}`);
|
||||
t.ok(opts.filePath.endsWith('wav'), 'audio is cached as wav file');
|
||||
|
||||
opts = await synthAudio(stats, {
|
||||
vendor: 'custom:somethingnew2',
|
||||
credentials: {
|
||||
@@ -491,7 +637,217 @@ test('Elevenlabs speech synth tests', async(t) => {
|
||||
t.end(err);
|
||||
}
|
||||
client.quit();
|
||||
})
|
||||
});
|
||||
|
||||
const testPlayHT = async(t, voice_engine) => {
|
||||
const fn = require('..');
|
||||
const {synthAudio, client} = fn(opts, logger);
|
||||
|
||||
if (!process.env.PLAYHT_API_KEY || !process.env.PLAYHT_USER_ID) {
|
||||
t.pass('skipping PlayHT speech synth tests since PLAYHT_API_KEY or PLAYHT_USER_ID is/are not provided');
|
||||
return t.end();
|
||||
}
|
||||
const text = 'Hi there and welcome to jambones! ' + Date.now();
|
||||
try {
|
||||
const opts = await synthAudio(stats, {
|
||||
vendor: 'playht',
|
||||
credentials: {
|
||||
api_key: process.env.PLAYHT_API_KEY,
|
||||
user_id: process.env.PLAYHT_USER_ID,
|
||||
voice_engine,
|
||||
options: JSON.stringify({
|
||||
quality: 'medium',
|
||||
speed: 1,
|
||||
seed: 1,
|
||||
temperature: 1,
|
||||
emotion: 'female_happy',
|
||||
voice_guidance: 3,
|
||||
style_guidance: 20,
|
||||
text_guidance: 1,
|
||||
})
|
||||
},
|
||||
language: 'english',
|
||||
voice: 's3://voice-cloning-zero-shot/d9ff78ba-d016-47f6-b0ef-dd630f59414e/female-cs/manifest.json',
|
||||
text,
|
||||
renderForCaching: true
|
||||
});
|
||||
t.ok(!opts.servedFromCache, `successfully playht eleven audio to ${opts.filePath}`);
|
||||
|
||||
} catch (err) {
|
||||
console.error(JSON.stringify(err));
|
||||
t.end(err);
|
||||
}
|
||||
client.quit();
|
||||
};
|
||||
|
||||
test('PlayHT speech synth tests', async(t) => {
|
||||
await testPlayHT(t, 'PlayHT2.0-turbo');
|
||||
});
|
||||
|
||||
test('PlayHT3.0 speech synth tests', async(t) => {
|
||||
await testPlayHT(t, 'Play3.0');
|
||||
});
|
||||
|
||||
test('Cartesia speech synth tests', async(t) => {
|
||||
const fn = require('..');
|
||||
const {synthAudio, client} = fn(opts, logger);
|
||||
|
||||
if (!process.env.CARTESIA_API_KEY) {
|
||||
t.pass('skipping Cartesia speech synth tests since CARTESIA_API_KEY is not provided');
|
||||
return t.end();
|
||||
}
|
||||
const text = 'Hi there and welcome to jambones! ' + Date.now();
|
||||
try {
|
||||
const opts = await synthAudio(stats, {
|
||||
vendor: 'cartesia',
|
||||
credentials: {
|
||||
api_key: process.env.CARTESIA_API_KEY,
|
||||
model_id: 'sonic-english',
|
||||
options: JSON.stringify({
|
||||
speed: 1,
|
||||
emotion: 'female_happy',
|
||||
})
|
||||
},
|
||||
language: 'en',
|
||||
voice: '694f9389-aac1-45b6-b726-9d9369183238',
|
||||
text,
|
||||
renderForCaching: true
|
||||
});
|
||||
t.ok(!opts.servedFromCache, `successfully playht eleven audio to ${opts.filePath}`);
|
||||
|
||||
} catch (err) {
|
||||
console.error(JSON.stringify(err));
|
||||
t.end(err);
|
||||
}
|
||||
client.quit();
|
||||
});
|
||||
|
||||
test('inworld speech synth', async(t) => {
|
||||
const fn = require('..');
|
||||
const {synthAudio, client} = fn(opts, logger);
|
||||
|
||||
if (!process.env.INWORLD_API_KEY) {
|
||||
t.pass('skipping inworld speech synth tests since INWORLD_API_KEY is not provided');
|
||||
return t.end();
|
||||
}
|
||||
const text = 'Hi there and welcome to jambones!';
|
||||
try {
|
||||
const opts = await synthAudio(stats, {
|
||||
vendor: 'inworld',
|
||||
credentials: {
|
||||
api_key: process.env.INWORLD_API_KEY,
|
||||
model_id: 'inworld-tts-1'
|
||||
},
|
||||
language: 'en',
|
||||
voice: 'Ashley',
|
||||
text,
|
||||
renderForCaching: true
|
||||
});
|
||||
t.ok(!opts.servedFromCache, `successfully synthesized inworld audio to ${opts.filePath}`);
|
||||
|
||||
} catch (err) {
|
||||
console.error(JSON.stringify(err));
|
||||
t.end(err);
|
||||
}
|
||||
client.quit();
|
||||
});
|
||||
|
||||
test('resemble speech synth', async(t) => {
|
||||
const fn = require('..');
|
||||
const {synthAudio, client} = fn(opts, logger);
|
||||
|
||||
if (!process.env.RESEMBLE_API_KEY) {
|
||||
t.pass('skipping resemble speech synth tests since RESEMBLE_API_KEY is not provided');
|
||||
return t.end();
|
||||
}
|
||||
const text = '<speak prompt="Speak in an excited, upbeat tone">Hello from Resemble!</speak>';
|
||||
try {
|
||||
const opts = await synthAudio(stats, {
|
||||
vendor: 'resemble',
|
||||
credentials: {
|
||||
api_key: process.env.RESEMBLE_API_KEY,
|
||||
},
|
||||
language: 'en',
|
||||
voice: '3f5fb9f1',
|
||||
text,
|
||||
renderForCaching: true
|
||||
});
|
||||
t.ok(!opts.servedFromCache, `successfully synthesized resemble audio to ${opts.filePath}`);
|
||||
|
||||
} catch (err) {
|
||||
console.error(JSON.stringify(err));
|
||||
t.end(err);
|
||||
}
|
||||
client.quit();
|
||||
});
|
||||
|
||||
test('rimelabs speech synth tests mist', async(t) => {
|
||||
const fn = require('..');
|
||||
const {synthAudio, client} = fn(opts, logger);
|
||||
|
||||
if (!process.env.RIMELABS_API_KEY) {
|
||||
t.pass('skipping rimelabs speech synth tests since RIMELABS_API_KEY is not provided');
|
||||
return t.end();
|
||||
}
|
||||
const text = 'Hi there and welcome to jambones!';
|
||||
try {
|
||||
const opts = await synthAudio(stats, {
|
||||
vendor: 'rimelabs',
|
||||
credentials: {
|
||||
api_key: process.env.RIMELABS_API_KEY,
|
||||
model_id: 'mist',
|
||||
options: JSON.stringify({
|
||||
speedAlpha: 1.0,
|
||||
reduceLatency: false
|
||||
})
|
||||
},
|
||||
language: 'eng',
|
||||
voice: 'amber',
|
||||
text,
|
||||
renderForCaching: true
|
||||
});
|
||||
t.ok(!opts.servedFromCache, `successfully synthesized rimelabs audio to ${opts.filePath}`);
|
||||
|
||||
} catch (err) {
|
||||
console.error(JSON.stringify(err));
|
||||
t.end(err);
|
||||
}
|
||||
client.quit();
|
||||
});
|
||||
|
||||
test('rimelabs speech synth tests mistv2', async(t) => {
|
||||
const fn = require('..');
|
||||
const {synthAudio, client} = fn(opts, logger);
|
||||
|
||||
if (!process.env.RIMELABS_API_KEY) {
|
||||
t.pass('skipping rimelabs speech synth tests since RIMELABS_API_KEY is not provided');
|
||||
return t.end();
|
||||
}
|
||||
const text = 'Hi there and welcome to jambones!';
|
||||
try {
|
||||
const opts = await synthAudio(stats, {
|
||||
vendor: 'rimelabs',
|
||||
credentials: {
|
||||
api_key: process.env.RIMELABS_API_KEY,
|
||||
model_id: 'mistv2',
|
||||
options: JSON.stringify({
|
||||
speedAlpha: 1.0,
|
||||
reduceLatency: false
|
||||
})
|
||||
},
|
||||
language: 'spa',
|
||||
voice: 'pablo',
|
||||
text,
|
||||
renderForCaching: true
|
||||
});
|
||||
t.ok(!opts.servedFromCache, `successfully synthesized rimelabs mistv2 audio to ${opts.filePath}`);
|
||||
|
||||
} catch (err) {
|
||||
console.error(JSON.stringify(err));
|
||||
t.end(err);
|
||||
}
|
||||
client.quit();
|
||||
});
|
||||
|
||||
test('whisper speech synth tests', async(t) => {
|
||||
const fn = require('..');
|
||||
@@ -512,6 +868,40 @@ test('whisper speech synth tests', async(t) => {
|
||||
language: 'en-US',
|
||||
voice: 'alloy',
|
||||
text,
|
||||
renderForCaching: true
|
||||
});
|
||||
t.ok(!opts.servedFromCache, `successfully synthesized whisper audio to ${opts.filePath}`);
|
||||
|
||||
} catch (err) {
|
||||
console.error(JSON.stringify(err));
|
||||
t.end(err);
|
||||
}
|
||||
client.quit();
|
||||
});
|
||||
|
||||
test('Verbio speech synth tests', async(t) => {
|
||||
const fn = require('..');
|
||||
const {synthAudio, client} = fn(opts, logger);
|
||||
|
||||
if (!process.env.VERBIO_CLIENT_ID || !process.env.VERBIO_CLIENT_SECRET) {
|
||||
t.pass('skipping Verbio Synthesize test since no Verbio Keys provided');
|
||||
t.end();
|
||||
client.quit();
|
||||
return;
|
||||
}
|
||||
|
||||
const text = 'Hi there and welcome to jambones!';
|
||||
try {
|
||||
let opts = await synthAudio(stats, {
|
||||
vendor: 'verbio',
|
||||
credentials: {
|
||||
client_id: process.env.VERBIO_CLIENT_ID,
|
||||
client_secret: process.env.VERBIO_CLIENT_SECRET
|
||||
},
|
||||
language: 'en-US',
|
||||
voice: 'tommy_en-us',
|
||||
text,
|
||||
renderForCaching: true
|
||||
});
|
||||
t.ok(!opts.servedFromCache, `successfully synthesized whisper audio to ${opts.filePath}`);
|
||||
|
||||
@@ -537,8 +927,9 @@ test('Deepgram speech synth tests', async(t) => {
|
||||
credentials: {
|
||||
api_key: process.env.DEEPGRAM_API_KEY
|
||||
},
|
||||
model: 'alpha-asteria-en-v2',
|
||||
model: 'aura-asteria-en',
|
||||
text,
|
||||
renderForCaching: true
|
||||
});
|
||||
t.ok(!opts.servedFromCache, `successfully synthesized deepgram audio to ${opts.filePath}`);
|
||||
|
||||
@@ -557,11 +948,12 @@ test('TTS Cache tests', async(t) => {
|
||||
// save some random tts keys to cache
|
||||
const minRecords = 8;
|
||||
for (const i in Array(minRecords).fill(0)) {
|
||||
await client.set(makeSynthKey({vendor: i, language: i, voice: i, engine: i, text: i}), i);
|
||||
await client.set(makeSynthKey({vendor: i, language: i, voice: i, engine: i, model: i, text: i,
|
||||
instructions: i}), i);
|
||||
}
|
||||
const count = await getTtsSize();
|
||||
t.ok(count >= minRecords, 'getTtsSize worked.');
|
||||
|
||||
|
||||
const {purgedCount} = await purgeTtsCache();
|
||||
t.ok(purgedCount >= minRecords, `successfully purged at least ${minRecords} tts records from cache`);
|
||||
|
||||
@@ -576,7 +968,7 @@ test('TTS Cache tests', async(t) => {
|
||||
try {
|
||||
// save some random tts keys to cache
|
||||
for (const i in Array(10).fill(0)) {
|
||||
await client.set(makeSynthKey({vendor: i, language: i, voice: i, engine: i, text: i}), i);
|
||||
await client.set(makeSynthKey({vendor: i, language: i, voice: i, engine: i, text: i, instructions: i}), i);
|
||||
}
|
||||
// save a specific key to tts cache
|
||||
const opts = {vendor: 'aws', language: 'en-US', voice: 'MALE', engine: 'Engine', text: 'Hello World!'};
|
||||
@@ -592,13 +984,15 @@ test('TTS Cache tests', async(t) => {
|
||||
language: 'non-existing',
|
||||
voice: 'non-existing',
|
||||
});
|
||||
t.ok(purgedCountWhenErrored === 0, `purged no records when specified key was not found`);
|
||||
t.ok(error, `error returned when specified key was not found`);
|
||||
t.ok(purgedCountWhenErrored === 0, 'purged no records when specified key was not found');
|
||||
t.ok(error, 'error returned when specified key was not found');
|
||||
|
||||
// make sure other tts keys are still there
|
||||
const cached = (await client.keys('tts:*')).length;
|
||||
t.ok(cached >= 1, `successfully kept all non-specified tts records in cache`);
|
||||
const cached = await client.keys('tts:*');
|
||||
t.ok(cached.length >= 1, 'successfully kept all non-specified tts records in cache');
|
||||
|
||||
process.env.VG_TRIM_TTS_SILENCE = 'true';
|
||||
await client.set(makeSynthKey({ vendor: 'azure' }), 'value');
|
||||
} catch (err) {
|
||||
console.error(JSON.stringify(err));
|
||||
t.end(err);
|
||||
@@ -612,10 +1006,10 @@ test('TTS Cache tests', async(t) => {
|
||||
const account_sid = "12412512_cabc_5aff"
|
||||
const account_sid2 = "22412512_cabc_5aff"
|
||||
for (const i in Array(minRecords).fill(0)) {
|
||||
await client.set(makeSynthKey({account_sid, vendor: i, language: i, voice: i, engine: i, text: i}), i);
|
||||
await client.set(makeSynthKey({account_sid, vendor: i, language: i, voice: i, engine: i, text: i, instructions: i}), i);
|
||||
}
|
||||
for (const i in Array(minRecords).fill(0)) {
|
||||
await client.set(makeSynthKey({account_sid: account_sid2, vendor: i, language: i, voice: i, engine: i, text: i}), i);
|
||||
await client.set(makeSynthKey({account_sid: account_sid2, vendor: i, language: i, voice: i, engine: i, text: i, instructions: i}), i);
|
||||
}
|
||||
const {purgedCount} = await purgeTtsCache({account_sid});
|
||||
t.equal(purgedCount, minRecords, `successfully purged at least ${minRecords} tts records from cache for account_sid:${account_sid}`);
|
||||
|
||||
Reference in New Issue
Block a user