mirror of
https://github.com/jambonz/speech-utils.git
synced 2026-10-03 23:33:59 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
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 |
@@ -13,6 +13,11 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
node-version: lts/*
|
node-version: lts/*
|
||||||
- run: npm install
|
- 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: npm run jslint
|
||||||
- run: sudo apt update && sudo apt install -y squid
|
- run: sudo apt update && sudo apt install -y squid
|
||||||
- run: sudo cp test/squid.conf /etc/squid/squid.conf
|
- run: sudo cp test/squid.conf /etc/squid/squid.conf
|
||||||
|
|||||||
+1
-1
@@ -1,3 +1,3 @@
|
|||||||
npm audit
|
#npm audit
|
||||||
npm run jslint:fix || true
|
npm run jslint:fix || true
|
||||||
npm test
|
npm test
|
||||||
@@ -1,5 +1,7 @@
|
|||||||
const JAMBONES_TTS_TRIM_SILENCE = process.env.JAMBONES_TTS_TRIM_SILENCE;
|
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_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_HTTP_PROXY_IP = process.env.JAMBONES_HTTP_PROXY_IP;
|
const JAMBONES_HTTP_PROXY_IP = process.env.JAMBONES_HTTP_PROXY_IP;
|
||||||
const JAMBONES_HTTP_PROXY_PORT = process.env.JAMBONES_HTTP_PROXY_PORT;
|
const JAMBONES_HTTP_PROXY_PORT = process.env.JAMBONES_HTTP_PROXY_PORT;
|
||||||
@@ -13,9 +15,11 @@ const HTTP_TIMEOUT = 5000;
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
JAMBONES_TTS_TRIM_SILENCE,
|
JAMBONES_TTS_TRIM_SILENCE,
|
||||||
JAMBONES_DISABLE_TTS_STREAMING,
|
JAMBONES_DISABLE_TTS_STREAMING,
|
||||||
|
JAMBONES_DISABLE_AZURE_TTS_STREAMING,
|
||||||
JAMBONES_HTTP_PROXY_IP,
|
JAMBONES_HTTP_PROXY_IP,
|
||||||
JAMBONES_HTTP_PROXY_PORT,
|
JAMBONES_HTTP_PROXY_PORT,
|
||||||
JAMBONES_TTS_CACHE_DURATION_MINS,
|
JAMBONES_TTS_CACHE_DURATION_MINS,
|
||||||
|
JAMBONES_EAGERLY_PRE_CACHE_AUDIO,
|
||||||
TMP_FOLDER,
|
TMP_FOLDER,
|
||||||
HTTP_TIMEOUT
|
HTTP_TIMEOUT
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,20 +1,22 @@
|
|||||||
const { STSClient, GetSessionTokenCommand, AssumeRoleCommand } = require('@aws-sdk/client-sts');
|
const { STSClient, GetSessionTokenCommand, AssumeRoleCommand } = require('@aws-sdk/client-sts');
|
||||||
const {makeAwsKey, noopLogger} = require('./utils');
|
const {makeAwsKey, noopLogger} = require('./utils');
|
||||||
const debug = require('debug')('jambonz:speech-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(
|
async function getAwsAuthToken(
|
||||||
logger, createHash, retrieveHash,
|
logger, createHash, retrieveHash,
|
||||||
awsAccessKeyId, awsSecretAccessKey, awsRegion, roleArn = null) {
|
{accessKeyId, secretAccessKey, region, roleArn}) {
|
||||||
logger = logger || noopLogger;
|
logger = logger || noopLogger;
|
||||||
try {
|
try {
|
||||||
const key = makeAwsKey(roleArn || awsAccessKeyId);
|
const key = makeAwsKey(roleArn || accessKeyId);
|
||||||
const obj = await retrieveHash(key);
|
const obj = await retrieveHash(key);
|
||||||
if (obj) return {...obj, servedFromCache: true};
|
if (obj) return {...obj, servedFromCache: true};
|
||||||
|
|
||||||
let data;
|
let data;
|
||||||
if (roleArn) {
|
if (roleArn) {
|
||||||
const stsClient = new STSClient({ region: awsRegion});
|
const stsClient = new STSClient({ region });
|
||||||
const roleToAssume = { RoleArn: roleArn, RoleSessionName: 'Jambonz_Speech', DurationSeconds: EXPIRY};
|
const roleToAssume = { RoleArn: roleArn, RoleSessionName: 'Jambonz_Speech', DurationSeconds: EXPIRY};
|
||||||
const command = new AssumeRoleCommand(roleToAssume);
|
const command = new AssumeRoleCommand(roleToAssume);
|
||||||
|
|
||||||
@@ -22,10 +24,10 @@ async function getAwsAuthToken(
|
|||||||
} else {
|
} else {
|
||||||
/* access token not found in cache, so generate it using STS */
|
/* access token not found in cache, so generate it using STS */
|
||||||
const stsClient = new STSClient({
|
const stsClient = new STSClient({
|
||||||
region: awsRegion,
|
region,
|
||||||
credentials: {
|
credentials: {
|
||||||
accessKeyId: awsAccessKeyId,
|
accessKeyId,
|
||||||
secretAccessKey: awsSecretAccessKey,
|
secretAccessKey,
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
const command = new GetSessionTokenCommand({DurationSeconds: EXPIRY});
|
const command = new GetSessionTokenCommand({DurationSeconds: EXPIRY});
|
||||||
@@ -39,8 +41,7 @@ async function getAwsAuthToken(
|
|||||||
securityToken: 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, CACHE_EXPIRY)
|
||||||
createHash(key, credentials, EXPIRY - 600)
|
|
||||||
.catch((err) => logger.error(err, `Error saving hash for key ${key}`));
|
.catch((err) => logger.error(err, `Error saving hash for key ${key}`));
|
||||||
|
|
||||||
return {...credentials, servedFromCache: false};
|
return {...credentials, servedFromCache: false};
|
||||||
|
|||||||
@@ -107,7 +107,12 @@ const getAwsVoices = async(_client, createHash, retrieveHash, logger, credential
|
|||||||
} else if (roleArn) {
|
} else if (roleArn) {
|
||||||
client = new PollyClient({
|
client = new PollyClient({
|
||||||
region,
|
region,
|
||||||
credentials: await getAwsAuthToken(logger, createHash, retrieveHash, null, null, region, roleArn),
|
credentials: await getAwsAuthToken(
|
||||||
|
logger, createHash, retrieveHash,
|
||||||
|
{
|
||||||
|
region,
|
||||||
|
roleArn
|
||||||
|
}),
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
client = new PollyClient({region});
|
client = new PollyClient({region});
|
||||||
|
|||||||
+47
-8
@@ -40,9 +40,11 @@ const {AudioEncoding} = require('../stubs/riva/proto/riva_audio_pb');
|
|||||||
const debug = require('debug')('jambonz:realtimedb-helpers');
|
const debug = require('debug')('jambonz:realtimedb-helpers');
|
||||||
const {
|
const {
|
||||||
JAMBONES_DISABLE_TTS_STREAMING,
|
JAMBONES_DISABLE_TTS_STREAMING,
|
||||||
|
JAMBONES_DISABLE_AZURE_TTS_STREAMING,
|
||||||
JAMBONES_HTTP_PROXY_IP,
|
JAMBONES_HTTP_PROXY_IP,
|
||||||
JAMBONES_HTTP_PROXY_PORT,
|
JAMBONES_HTTP_PROXY_PORT,
|
||||||
JAMBONES_TTS_CACHE_DURATION_MINS,
|
JAMBONES_TTS_CACHE_DURATION_MINS,
|
||||||
|
JAMBONES_EAGERLY_PRE_CACHE_AUDIO,
|
||||||
} = require('./config');
|
} = require('./config');
|
||||||
const EXPIRES = JAMBONES_TTS_CACHE_DURATION_MINS;
|
const EXPIRES = JAMBONES_TTS_CACHE_DURATION_MINS;
|
||||||
const OpenAI = require('openai');
|
const OpenAI = require('openai');
|
||||||
@@ -85,7 +87,7 @@ const trimTrailingSilence = (buffer) => {
|
|||||||
*/
|
*/
|
||||||
async function synthAudio(client, createHash, retrieveHash, logger, stats, { account_sid,
|
async function synthAudio(client, createHash, retrieveHash, logger, stats, { account_sid,
|
||||||
vendor, language, voice, gender, text, engine, salt, model, credentials, deploymentId,
|
vendor, language, voice, gender, text, engine, salt, model, credentials, deploymentId,
|
||||||
disableTtsCache, renderForCaching, disableTtsStreaming, options
|
disableTtsCache, renderForCaching = false, disableTtsStreaming, options
|
||||||
}) {
|
}) {
|
||||||
let audioBuffer;
|
let audioBuffer;
|
||||||
let servedFromCache = false;
|
let servedFromCache = false;
|
||||||
@@ -150,21 +152,48 @@ async function synthAudio(client, createHash, retrieveHash, logger, stats, { acc
|
|||||||
assert.ok(voice, 'synthAudio requires voice when verbio is used');
|
assert.ok(voice, 'synthAudio requires voice when verbio is used');
|
||||||
assert.ok(credentials.client_id, 'synthAudio requires client_id when verbio is used');
|
assert.ok(credentials.client_id, 'synthAudio requires client_id when verbio is used');
|
||||||
assert.ok(credentials.client_secret, 'synthAudio requires client_secret when verbio is used');
|
assert.ok(credentials.client_secret, 'synthAudio requires client_secret when verbio is used');
|
||||||
|
} else if ('deepgram' === vendor) {
|
||||||
|
if (!credentials.deepgram_tts_uri) {
|
||||||
|
assert.ok(credentials.api_key, 'synthAudio requires api_key when deepgram is used');
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const key = makeSynthKey({
|
const key = makeSynthKey({
|
||||||
account_sid,
|
account_sid,
|
||||||
vendor,
|
vendor,
|
||||||
language: language || '',
|
language: language || '',
|
||||||
voice: voice || deploymentId,
|
voice: voice || deploymentId,
|
||||||
engine,
|
engine,
|
||||||
text
|
text,
|
||||||
|
renderForCaching
|
||||||
});
|
});
|
||||||
let filePath;
|
let filePath;
|
||||||
filePath = makeFilePath(vendor, key, salt);
|
filePath = makeFilePath({vendor, key, salt, renderForCaching});
|
||||||
debug(`synth key is ${key}`);
|
debug(`synth key is ${key}`);
|
||||||
let cached;
|
let cached;
|
||||||
if (!disableTtsCache) {
|
if (!disableTtsCache) {
|
||||||
cached = await client.get(key);
|
cached = await client.get(key);
|
||||||
|
/**
|
||||||
|
* If we are using tts streaming and also precaching audio, audio could have been cached by streaming (r8)
|
||||||
|
* or here in speech-utils due to precaching (mp3), so we need to check for both keys.
|
||||||
|
*/
|
||||||
|
if (!cached && JAMBONES_EAGERLY_PRE_CACHE_AUDIO) {
|
||||||
|
const preCachekey = makeSynthKey({
|
||||||
|
account_sid,
|
||||||
|
vendor,
|
||||||
|
language: language || '',
|
||||||
|
voice: voice || deploymentId,
|
||||||
|
engine,
|
||||||
|
text,
|
||||||
|
renderForCaching: true
|
||||||
|
});
|
||||||
|
cached = await client.get(preCachekey);
|
||||||
|
if (cached) {
|
||||||
|
// Precache audio is available update filpath with precache file extension.
|
||||||
|
filePath = makeFilePath({vendor, key, salt, renderForCaching: true});
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (cached) {
|
if (cached) {
|
||||||
// found in cache - extend the expiry and use it
|
// found in cache - extend the expiry and use it
|
||||||
@@ -280,7 +309,12 @@ const synthPolly = async(createHash, retrieveHash, logger,
|
|||||||
} else if (roleArn) {
|
} else if (roleArn) {
|
||||||
polly = new PollyClient({
|
polly = new PollyClient({
|
||||||
region,
|
region,
|
||||||
credentials: await getAwsAuthToken(logger, createHash, retrieveHash, null, null, region, roleArn),
|
credentials: await getAwsAuthToken(
|
||||||
|
logger, createHash, retrieveHash,
|
||||||
|
{
|
||||||
|
region,
|
||||||
|
roleArn
|
||||||
|
}),
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
// AWS RoleArn assigned to Instance profile
|
// AWS RoleArn assigned to Instance profile
|
||||||
@@ -443,7 +477,8 @@ const synthMicrosoft = async(logger, {
|
|||||||
content = `<speak version="1.0" xmlns="http://www.w3.org/2001/10/synthesis" xmlns:mstts="https://www.w3.org/2001/mstts" xml:lang="${language}"><voice name="${voice}">${words}</voice></speak>`;
|
content = `<speak version="1.0" xmlns="http://www.w3.org/2001/10/synthesis" xmlns:mstts="https://www.w3.org/2001/mstts" xml:lang="${language}"><voice name="${voice}">${words}</voice></speak>`;
|
||||||
logger.info({content}, 'synthMicrosoft');
|
logger.info({content}, 'synthMicrosoft');
|
||||||
}
|
}
|
||||||
if (!JAMBONES_DISABLE_TTS_STREAMING && !renderForCaching && !disableTtsStreaming) {
|
if (!JAMBONES_DISABLE_TTS_STREAMING && !JAMBONES_DISABLE_AZURE_TTS_STREAMING &&
|
||||||
|
!renderForCaching && !disableTtsStreaming) {
|
||||||
let params = '';
|
let params = '';
|
||||||
params += `{api_key=${apiKey}`;
|
params += `{api_key=${apiKey}`;
|
||||||
params += `,language=${language}`;
|
params += `,language=${language}`;
|
||||||
@@ -684,6 +719,8 @@ const synthElevenlabs = async(logger, {
|
|||||||
if (opts.voice_settings?.stability) params += `,stability=${opts.voice_settings.stability}`;
|
if (opts.voice_settings?.stability) params += `,stability=${opts.voice_settings.stability}`;
|
||||||
if (opts.voice_settings?.style) params += `,style=${opts.voice_settings.style}`;
|
if (opts.voice_settings?.style) params += `,style=${opts.voice_settings.style}`;
|
||||||
if (opts.voice_settings?.use_speaker_boost === false) params += ',use_speaker_boost=false';
|
if (opts.voice_settings?.use_speaker_boost === false) params += ',use_speaker_boost=false';
|
||||||
|
if (opts.previous_text) params += `,previous_text=${opts.previous_text}`;
|
||||||
|
if (opts.next_text) params += `,next_text=${opts.next_text}`;
|
||||||
params += '}';
|
params += '}';
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@@ -900,13 +937,14 @@ const synthWhisper = async(logger, {credentials, stats, voice, text, renderForCa
|
|||||||
};
|
};
|
||||||
|
|
||||||
const synthDeepgram = async(logger, {credentials, stats, model, text, renderForCaching, disableTtsStreaming}) => {
|
const synthDeepgram = async(logger, {credentials, stats, model, text, renderForCaching, disableTtsStreaming}) => {
|
||||||
const {api_key} = credentials;
|
const {api_key, deepgram_tts_uri} = credentials;
|
||||||
if (!JAMBONES_DISABLE_TTS_STREAMING && !renderForCaching && !disableTtsStreaming) {
|
if (!JAMBONES_DISABLE_TTS_STREAMING && !renderForCaching && !disableTtsStreaming) {
|
||||||
let params = '';
|
let params = '';
|
||||||
params += `{api_key=${api_key}`;
|
params += `{api_key=${api_key}`;
|
||||||
params += ',vendor=deepgram';
|
params += ',vendor=deepgram';
|
||||||
params += `,voice=${model}`;
|
params += `,voice=${model}`;
|
||||||
params += ',write_cache_file=1';
|
params += ',write_cache_file=1';
|
||||||
|
if (deepgram_tts_uri) params += `,endpoint=${deepgram_tts_uri}`;
|
||||||
params += '}';
|
params += '}';
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@@ -916,8 +954,9 @@ const synthDeepgram = async(logger, {credentials, stats, model, text, renderForC
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
const post = bent('https://api.deepgram.com', 'POST', 'buffer', {
|
const post = bent(deepgram_tts_uri || 'https://api.deepgram.com', 'POST', 'buffer', {
|
||||||
'Authorization': `Token ${api_key}`,
|
// on-premise deepgram does not require to have api_key
|
||||||
|
...(api_key && {'Authorization': `Token ${api_key}`}),
|
||||||
'Accept': 'audio/mpeg',
|
'Accept': 'audio/mpeg',
|
||||||
'Content-Type': 'application/json'
|
'Content-Type': 'application/json'
|
||||||
});
|
});
|
||||||
|
|||||||
+20
-9
@@ -16,29 +16,31 @@ const debug = require('debug')('jambonz:realtimedb-helpers');
|
|||||||
*/
|
*/
|
||||||
//const nuanceClientMap = new Map();
|
//const nuanceClientMap = new Map();
|
||||||
|
|
||||||
function makeSynthKey({account_sid = '', vendor, language, voice, engine = '', text}) {
|
function makeSynthKey({
|
||||||
|
account_sid = '', vendor, language, voice, engine = '', text,
|
||||||
|
renderForCaching = false}) {
|
||||||
const hash = crypto.createHash('sha1');
|
const hash = crypto.createHash('sha1');
|
||||||
hash.update(`${language}:${vendor}:${voice}:${engine}:${text}`);
|
hash.update(`${language}:${vendor}:${voice}:${engine}:${text}`);
|
||||||
const hexHashKey = hash.digest('hex');
|
const hexHashKey = hash.digest('hex');
|
||||||
const accountKey = account_sid ? `:${account_sid}` : '';
|
const accountKey = account_sid ? `:${account_sid}` : '';
|
||||||
const namespace = vendor.startsWith('custom') ? vendor : getFileExtension(vendor);
|
const namespace = vendor.startsWith('custom') ? vendor : getFileExtension({vendor, renderForCaching});
|
||||||
const key = `tts${accountKey}:${namespace}:${hexHashKey}`;
|
const key = `tts${accountKey}:${namespace}:${hexHashKey}`;
|
||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
|
|
||||||
function makeFilePath(vendor, key, salt = '') {
|
function makeFilePath({vendor, key, salt = '', renderForCaching = false}) {
|
||||||
const extension = getFileExtension(vendor);
|
const extension = getFileExtension({vendor, renderForCaching});
|
||||||
return `${TMP_FOLDER}/${key.replace('tts:', `tts-${salt}`)}.${extension}`;
|
return `${TMP_FOLDER}/${key.replace('tts:', `tts-${salt}`)}.${extension}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getFileExtension(vendor) {
|
function getFileExtension({vendor, renderForCaching = false}) {
|
||||||
const mp3Extension = 'mp3';
|
const mp3Extension = 'mp3';
|
||||||
const r8Extension = 'r8';
|
const r8Extension = 'r8';
|
||||||
|
|
||||||
switch (vendor) {
|
switch (vendor) {
|
||||||
case 'azure':
|
case 'azure':
|
||||||
case 'microsoft':
|
case 'microsoft':
|
||||||
if (!JAMBONES_DISABLE_TTS_STREAMING || JAMBONES_TTS_TRIM_SILENCE) {
|
if (!renderForCaching && !JAMBONES_DISABLE_TTS_STREAMING || JAMBONES_TTS_TRIM_SILENCE) {
|
||||||
return r8Extension;
|
return r8Extension;
|
||||||
} else {
|
} else {
|
||||||
return mp3Extension;
|
return mp3Extension;
|
||||||
@@ -46,16 +48,25 @@ function getFileExtension(vendor) {
|
|||||||
case 'deepgram':
|
case 'deepgram':
|
||||||
case 'elevenlabs':
|
case 'elevenlabs':
|
||||||
case 'rimlabs':
|
case 'rimlabs':
|
||||||
if (!JAMBONES_DISABLE_TTS_STREAMING) {
|
case 'playht':
|
||||||
return r8Extension;
|
if (renderForCaching || JAMBONES_DISABLE_TTS_STREAMING) {
|
||||||
} else {
|
|
||||||
return mp3Extension;
|
return mp3Extension;
|
||||||
|
} else {
|
||||||
|
return r8Extension;
|
||||||
}
|
}
|
||||||
case 'nuance':
|
case 'nuance':
|
||||||
case 'nvidia':
|
case 'nvidia':
|
||||||
case 'verbio':
|
case 'verbio':
|
||||||
return r8Extension;
|
return r8Extension;
|
||||||
default:
|
default:
|
||||||
|
// If vendor is custom
|
||||||
|
if (vendor.startsWith('custom')) {
|
||||||
|
if (renderForCaching || JAMBONES_DISABLE_TTS_STREAMING) {
|
||||||
|
return mp3Extension;
|
||||||
|
} else {
|
||||||
|
return r8Extension;
|
||||||
|
}
|
||||||
|
}
|
||||||
return mp3Extension;
|
return mp3Extension;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Generated
+1565
-1391
File diff suppressed because it is too large
Load Diff
+2
-2
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@jambonz/speech-utils",
|
"name": "@jambonz/speech-utils",
|
||||||
"version": "0.1.6",
|
"version": "0.1.16",
|
||||||
"description": "TTS-related speech utilities for jambonz",
|
"description": "TTS-related speech utilities for jambonz",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"author": "Dave Horton",
|
"author": "Dave Horton",
|
||||||
@@ -36,7 +36,7 @@
|
|||||||
"form-urlencoded": "^6.1.4",
|
"form-urlencoded": "^6.1.4",
|
||||||
"google-protobuf": "^3.21.2",
|
"google-protobuf": "^3.21.2",
|
||||||
"ibm-watson": "^8.0.0",
|
"ibm-watson": "^8.0.0",
|
||||||
"microsoft-cognitiveservices-speech-sdk": "1.36.0",
|
"microsoft-cognitiveservices-speech-sdk": "1.38.0",
|
||||||
"openai": "^4.25.0",
|
"openai": "^4.25.0",
|
||||||
"undici": "^6.4.0"
|
"undici": "^6.4.0"
|
||||||
},
|
},
|
||||||
|
|||||||
+10
-2
@@ -19,12 +19,20 @@ test('AWS - create and cache auth token', async(t) => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
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');
|
//console.log({obj}, 'received auth token from AWS');
|
||||||
t.ok(obj.securityToken && !obj.servedFromCache, 'successfullY generated auth token from AWS');
|
t.ok(obj.securityToken && !obj.servedFromCache, 'successfullY generated auth token from AWS');
|
||||||
|
|
||||||
await sleep(250);
|
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');
|
//console.log({obj}, 'received auth token from AWS - second request');
|
||||||
t.ok(obj.securityToken && obj.servedFromCache, 'successfully received access token from cache');
|
t.ok(obj.securityToken && obj.servedFromCache, 'successfully received access token from cache');
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user