mirror of
https://github.com/jambonz/speech-utils.git
synced 2026-10-03 23:33:59 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5463e9f56e | ||
|
|
2eb36af650 | ||
|
|
b186cbc4f2 | ||
|
|
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 |
+1
-1
@@ -9,7 +9,7 @@ const JAMBONES_HTTP_PROXY_PORT = process.env.JAMBONES_HTTP_PROXY_PORT;
|
|||||||
const JAMBONES_TTS_CACHE_DURATION_MINS =
|
const JAMBONES_TTS_CACHE_DURATION_MINS =
|
||||||
(parseInt(process.env.JAMBONES_TTS_CACHE_DURATION_MINS) || 4 * 60) * 60; // cache tts for 4 hours
|
(parseInt(process.env.JAMBONES_TTS_CACHE_DURATION_MINS) || 4 * 60) * 60; // cache tts for 4 hours
|
||||||
|
|
||||||
const TMP_FOLDER = '/tmp';
|
const TMP_FOLDER = process.env.JAMBONES_TMP_FOLDER || '/tmp';
|
||||||
|
|
||||||
const HTTP_TIMEOUT = 5000;
|
const HTTP_TIMEOUT = 5000;
|
||||||
|
|
||||||
|
|||||||
+176
-8
@@ -98,7 +98,7 @@ async function synthAudio(client, createHash, retrieveHash, logger, stats, { acc
|
|||||||
logger = logger || noopLogger;
|
logger = logger || noopLogger;
|
||||||
|
|
||||||
assert.ok(['google', 'aws', 'polly', 'microsoft', 'wellsaid', 'nuance', 'nvidia', 'ibm', 'elevenlabs',
|
assert.ok(['google', 'aws', 'polly', 'microsoft', 'wellsaid', 'nuance', 'nvidia', 'ibm', 'elevenlabs',
|
||||||
'whisper', 'deepgram', 'playht', 'rimelabs', 'verbio', 'cartesia'].includes(vendor) ||
|
'whisper', 'deepgram', 'playht', 'rimelabs', 'verbio', 'cartesia', 'inworld', 'resemble'].includes(vendor) ||
|
||||||
vendor.startsWith('custom'),
|
vendor.startsWith('custom'),
|
||||||
`synthAudio supported vendors are google, aws, microsoft, nuance, nvidia and wellsaid ..etc, not ${vendor}`);
|
`synthAudio supported vendors are google, aws, microsoft, nuance, nvidia and wellsaid ..etc, not ${vendor}`);
|
||||||
if ('google' === vendor) {
|
if ('google' === vendor) {
|
||||||
@@ -141,6 +141,10 @@ async function synthAudio(client, createHash, retrieveHash, logger, stats, { acc
|
|||||||
assert.ok(credentials.api_key, 'synthAudio requires api_key when playht is used');
|
assert.ok(credentials.api_key, 'synthAudio requires api_key when playht is used');
|
||||||
assert.ok(credentials.user_id, 'synthAudio requires user_id when playht is used');
|
assert.ok(credentials.user_id, 'synthAudio requires user_id when playht is used');
|
||||||
assert.ok(credentials.voice_engine, 'synthAudio requires voice_engine when playht is used');
|
assert.ok(credentials.voice_engine, 'synthAudio requires voice_engine when playht is used');
|
||||||
|
} else if ('inworld' === vendor) {
|
||||||
|
assert.ok(voice, 'synthAudio requires voice when inworld is used');
|
||||||
|
assert.ok(credentials.api_key, 'synthAudio requires api_key when inworld is used');
|
||||||
|
assert.ok(credentials.model_id, 'synthAudio requires model_id when inworld is used');
|
||||||
} else if ('rimelabs' === vendor) {
|
} else if ('rimelabs' === vendor) {
|
||||||
assert.ok(voice, 'synthAudio requires voice when rimelabs is used');
|
assert.ok(voice, 'synthAudio requires voice when rimelabs is used');
|
||||||
assert.ok(credentials.api_key, 'synthAudio requires api_key when rimelabs is used');
|
assert.ok(credentials.api_key, 'synthAudio requires api_key when rimelabs is used');
|
||||||
@@ -162,6 +166,9 @@ async function synthAudio(client, createHash, retrieveHash, logger, stats, { acc
|
|||||||
} else if ('cartesia' === vendor) {
|
} else if ('cartesia' === vendor) {
|
||||||
assert.ok(credentials.api_key, 'synthAudio requires api_key when cartesia is used');
|
assert.ok(credentials.api_key, 'synthAudio requires api_key when cartesia is used');
|
||||||
assert.ok(credentials.model_id, 'synthAudio requires model_id when cartesia is used');
|
assert.ok(credentials.model_id, 'synthAudio requires model_id when cartesia is used');
|
||||||
|
} else if (vendor === 'resemble') {
|
||||||
|
assert.ok(voice, 'synthAudio requires voice when resemble is used');
|
||||||
|
assert.ok(credentials.api_key, 'synthAudio requires api_key when resemble is used');
|
||||||
}
|
}
|
||||||
|
|
||||||
const key = makeSynthKey({
|
const key = makeSynthKey({
|
||||||
@@ -204,7 +211,7 @@ async function synthAudio(client, createHash, retrieveHash, logger, stats, { acc
|
|||||||
case 'polly':
|
case 'polly':
|
||||||
vendorLabel = 'aws';
|
vendorLabel = 'aws';
|
||||||
audioData = await synthPolly(createHash, retrieveHash, logger,
|
audioData = await synthPolly(createHash, retrieveHash, logger,
|
||||||
{credentials, stats, language, voice, text, engine});
|
{credentials, stats, language, voice, text, engine, renderForCaching, disableTtsStreaming});
|
||||||
break;
|
break;
|
||||||
case 'azure':
|
case 'azure':
|
||||||
case 'microsoft':
|
case 'microsoft':
|
||||||
@@ -238,6 +245,10 @@ async function synthAudio(client, createHash, retrieveHash, logger, stats, { acc
|
|||||||
audioData = await synthCartesia(logger, {
|
audioData = await synthCartesia(logger, {
|
||||||
credentials, options, stats, language, voice, text, renderForCaching, disableTtsStreaming});
|
credentials, options, stats, language, voice, text, renderForCaching, disableTtsStreaming});
|
||||||
break;
|
break;
|
||||||
|
case 'inworld':
|
||||||
|
audioData = await synthInworld(logger, {
|
||||||
|
credentials, options, stats, language, voice, text, renderForCaching, disableTtsStreaming});
|
||||||
|
break;
|
||||||
case 'rimelabs':
|
case 'rimelabs':
|
||||||
audioData = await synthRimelabs(logger, {
|
audioData = await synthRimelabs(logger, {
|
||||||
credentials, options, stats, language, voice, text, renderForCaching, disableTtsStreaming});
|
credentials, options, stats, language, voice, text, renderForCaching, disableTtsStreaming});
|
||||||
@@ -255,6 +266,10 @@ async function synthAudio(client, createHash, retrieveHash, logger, stats, { acc
|
|||||||
audioData = await synthDeepgram(logger, {credentials, stats, model, text,
|
audioData = await synthDeepgram(logger, {credentials, stats, model, text,
|
||||||
renderForCaching, disableTtsStreaming});
|
renderForCaching, disableTtsStreaming});
|
||||||
break;
|
break;
|
||||||
|
case 'resemble':
|
||||||
|
audioData = await synthResemble(logger, {
|
||||||
|
credentials, stats, voice, text, options, renderForCaching, disableTtsStreaming});
|
||||||
|
break;
|
||||||
case vendor.startsWith('custom') ? vendor : 'cant_match_value':
|
case vendor.startsWith('custom') ? vendor : 'cant_match_value':
|
||||||
audioData = await synthCustomVendor(logger,
|
audioData = await synthCustomVendor(logger,
|
||||||
{credentials, stats, language, voice, text});
|
{credentials, stats, language, voice, text});
|
||||||
@@ -292,9 +307,42 @@ async function synthAudio(client, createHash, retrieveHash, logger, stats, { acc
|
|||||||
}
|
}
|
||||||
|
|
||||||
const synthPolly = async(createHash, retrieveHash, logger,
|
const synthPolly = async(createHash, retrieveHash, logger,
|
||||||
{credentials, stats, language, voice, engine, text}) => {
|
{credentials, stats, language, voice, engine, text, renderForCaching, disableTtsStreaming}) => {
|
||||||
try {
|
|
||||||
const {region, accessKeyId, secretAccessKey, roleArn} = credentials;
|
const {region, accessKeyId, secretAccessKey, roleArn} = credentials;
|
||||||
|
if (!JAMBONES_DISABLE_TTS_STREAMING && !renderForCaching && !disableTtsStreaming) {
|
||||||
|
|
||||||
|
let params = '{';
|
||||||
|
params += `language=${language}`;
|
||||||
|
params += ',write_cache_file=1';
|
||||||
|
params += ',vendor=aws';
|
||||||
|
if (accessKeyId && secretAccessKey) {
|
||||||
|
if (accessKeyId) params += `,accessKeyId=${accessKeyId}`;
|
||||||
|
if (secretAccessKey) params += `,secretAccessKey=${secretAccessKey}`;
|
||||||
|
} else if (roleArn) {
|
||||||
|
const cred = await getAwsAuthToken(
|
||||||
|
logger, createHash, retrieveHash,
|
||||||
|
{
|
||||||
|
region,
|
||||||
|
roleArn
|
||||||
|
});
|
||||||
|
|
||||||
|
if (cred) {
|
||||||
|
params += `,accessKeyId=${cred.accessKeyId}`;
|
||||||
|
params += `,secretAccessKey=${cred.secretAccessKey}`;
|
||||||
|
params += `,sessionToken=${cred.sessionToken}`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (region) params += `,region=${region}`;
|
||||||
|
if (engine) params += `,engine=${engine}`;
|
||||||
|
params += '}';
|
||||||
|
|
||||||
|
return {
|
||||||
|
filePath: `say:${params}${text.replace(/\n/g, ' ').replace(/\r/g, ' ')}`,
|
||||||
|
servedFromCache: false,
|
||||||
|
rtt: 0
|
||||||
|
};
|
||||||
|
}
|
||||||
|
try {
|
||||||
let polly;
|
let polly;
|
||||||
if (accessKeyId && secretAccessKey) {
|
if (accessKeyId && secretAccessKey) {
|
||||||
polly = new PollyClient({
|
polly = new PollyClient({
|
||||||
@@ -479,10 +527,10 @@ async function _synthOnPremMicrosoft(logger, {
|
|||||||
/* microsoft enforces some properties and uses voice xml element so if the user did not supply do it for them */
|
/* microsoft enforces some properties and uses voice xml element so if the user did not supply do it for them */
|
||||||
const words = content.slice(7, -8).trim().replace(/(\r\n|\n|\r)/gm, ' ');
|
const words = content.slice(7, -8).trim().replace(/(\r\n|\n|\r)/gm, ' ');
|
||||||
// eslint-disable-next-line max-len
|
// eslint-disable-next-line max-len
|
||||||
content = `<speak version="1.0" xmlns="http://www.w3.org/2001/10/synthesis" xmlns:mstts="https://www.w3.org/2001/mstts" xml:lang="${language}"><lang xml:lang="${language}"><voice name="${voice}">${words}</voice></lang></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');
|
||||||
}
|
}
|
||||||
else if (JAMBONES_AZURE_ENABLE_SSML) {
|
else if (JAMBONES_AZURE_ENABLE_SSML && !content.startsWith('<speak')) {
|
||||||
// eslint-disable-next-line max-len
|
// eslint-disable-next-line max-len
|
||||||
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}"><lang xml:lang="${language}">${text}</lang></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}"><lang xml:lang="${language}">${text}</lang></voice></speak>`;
|
||||||
}
|
}
|
||||||
@@ -532,10 +580,10 @@ const synthMicrosoft = async(logger, {
|
|||||||
/* microsoft enforces some properties and uses voice xml element so if the user did not supply do it for them */
|
/* microsoft enforces some properties and uses voice xml element so if the user did not supply do it for them */
|
||||||
const words = content.slice(7, -8).trim().replace(/(\r\n|\n|\r)/gm, ' ');
|
const words = content.slice(7, -8).trim().replace(/(\r\n|\n|\r)/gm, ' ');
|
||||||
// eslint-disable-next-line max-len
|
// eslint-disable-next-line max-len
|
||||||
content = `<speak version="1.0" xmlns="http://www.w3.org/2001/10/synthesis" xmlns:mstts="https://www.w3.org/2001/mstts" xml:lang="${language}"><lang xml:lang="${language}"><voice name="${voice}">${words}</voice></lang></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');
|
||||||
}
|
}
|
||||||
else if (JAMBONES_AZURE_ENABLE_SSML) {
|
else if (JAMBONES_AZURE_ENABLE_SSML && !content.startsWith('<speak')) {
|
||||||
// eslint-disable-next-line max-len
|
// eslint-disable-next-line max-len
|
||||||
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}"><lang xml:lang="${language}">${text}</lang></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}"><lang xml:lang="${language}">${text}</lang></voice></speak>`;
|
||||||
}
|
}
|
||||||
@@ -954,6 +1002,70 @@ const synthPlayHT = async(client, logger, {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const synthInworld = async(logger, {
|
||||||
|
credentials, options, stats, voice, text, renderForCaching, disableTtsStreaming
|
||||||
|
}) => {
|
||||||
|
const {api_key, model_id, options: credOpts} = credentials;
|
||||||
|
const opts = !!options && Object.keys(options).length !== 0 ? options : JSON.parse(credOpts || '{}');
|
||||||
|
|
||||||
|
/* default to using the streaming interface, unless disabled by env var OR we want just a cache file */
|
||||||
|
if (!JAMBONES_DISABLE_TTS_STREAMING && !renderForCaching && !disableTtsStreaming) {
|
||||||
|
let params = '';
|
||||||
|
params += `{api_key=${api_key}`;
|
||||||
|
params += `,model_id=${model_id}`;
|
||||||
|
params += ',vendor=inworld';
|
||||||
|
params += `,voice=${voice}`;
|
||||||
|
params += ',write_cache_file=1';
|
||||||
|
if (opts.temperature) params += `,temperature=${opts.temperature}`;
|
||||||
|
if (opts.audioConfig?.pitch) params += `,pitch=${opts.pitch}`;
|
||||||
|
if (opts.audioConfig?.speakingRate) params += `,speakingRate=${opts.speakingRate}`;
|
||||||
|
params += '}';
|
||||||
|
|
||||||
|
return {
|
||||||
|
filePath: `say:${params}${text.replace(/\n/g, ' ').replace(/\r/g, ' ')}`,
|
||||||
|
servedFromCache: false,
|
||||||
|
rtt: 0
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const url = 'https://api.inworld.ai/tts/v1/voice';
|
||||||
|
const sampleRate = 8000;
|
||||||
|
const options = {
|
||||||
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
'Authorization': `Basic ${api_key}`,
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
},
|
||||||
|
body: JSON.stringify({
|
||||||
|
text,
|
||||||
|
voiceId: voice,
|
||||||
|
modelId: model_id,
|
||||||
|
audioConfig: {
|
||||||
|
...(opts.audioConfig || {}),
|
||||||
|
audioEncoding: 'MP3',
|
||||||
|
}
|
||||||
|
})
|
||||||
|
};
|
||||||
|
|
||||||
|
const response = await fetch(url, options);
|
||||||
|
|
||||||
|
if (!response.ok) {
|
||||||
|
throw new Error(await response.text());
|
||||||
|
}
|
||||||
|
const json = await response.json();
|
||||||
|
return {
|
||||||
|
audioContent: Buffer.from(json.audioContent, 'base64'),
|
||||||
|
extension: 'mp3',
|
||||||
|
sampleRate
|
||||||
|
};
|
||||||
|
} catch (err) {
|
||||||
|
logger.info({err}, 'synth inworld returned error');
|
||||||
|
stats.increment('tts.count', ['vendor:inworld', 'accepted:no']);
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const synthRimelabs = async(logger, {
|
const synthRimelabs = async(logger, {
|
||||||
credentials, options, stats, language, voice, text, renderForCaching, disableTtsStreaming
|
credentials, options, stats, language, voice, text, renderForCaching, disableTtsStreaming
|
||||||
}) => {
|
}) => {
|
||||||
@@ -1213,6 +1325,62 @@ const synthCartesia = async(logger, {
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const synthResemble = async(logger, {
|
||||||
|
credentials, options, stats, voice, text, renderForCaching, disableTtsStreaming
|
||||||
|
}) => {
|
||||||
|
const {api_key, resemble_tts_uri, resemble_tts_use_tls} = credentials;
|
||||||
|
const {project_uuid, use_hd} = options || {};
|
||||||
|
|
||||||
|
/* default to using the streaming interface, unless disabled by env var OR we want just a cache file */
|
||||||
|
if (!JAMBONES_DISABLE_TTS_STREAMING && !renderForCaching && !disableTtsStreaming) {
|
||||||
|
let params = '';
|
||||||
|
params += `{api_key=${api_key}`;
|
||||||
|
params += ',vendor=resemble';
|
||||||
|
params += `,voice=${voice}`;
|
||||||
|
params += ',write_cache_file=1';
|
||||||
|
if (project_uuid) params += `,project_uuid=${project_uuid}`;
|
||||||
|
if (use_hd) params += `,use_hd=${use_hd}`;
|
||||||
|
if (resemble_tts_uri) params += `,endpoint=${resemble_tts_uri}`;
|
||||||
|
if (resemble_tts_use_tls) params += `,use_tls=${resemble_tts_use_tls}`;
|
||||||
|
|
||||||
|
params += '}';
|
||||||
|
|
||||||
|
return {
|
||||||
|
filePath: `say:${params}${text.replace(/\n/g, ' ').replace(/\r/g, ' ')}`,
|
||||||
|
servedFromCache: false,
|
||||||
|
rtt: 0
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const baseUrl = resemble_tts_uri || 'https://f.cluster.resemble.ai';
|
||||||
|
const post = bent(baseUrl, 'POST', 'buffer', {
|
||||||
|
'Authorization': `Bearer ${api_key}`,
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
});
|
||||||
|
const response = await post('/synthesize', {
|
||||||
|
voice_uuid: voice,
|
||||||
|
data: text,
|
||||||
|
sample_rate: 8000,
|
||||||
|
output_format: 'mp3',
|
||||||
|
...(project_uuid && {project_uuid}),
|
||||||
|
...(use_hd && {use_hd}),
|
||||||
|
});
|
||||||
|
|
||||||
|
const json = JSON.parse(response.toString('utf8'));
|
||||||
|
const audioContent = Buffer.from(json.audio_content, 'base64');
|
||||||
|
return {
|
||||||
|
audioContent,
|
||||||
|
extension: 'mp3',
|
||||||
|
sampleRate: 8000
|
||||||
|
};
|
||||||
|
} catch (err) {
|
||||||
|
logger.info({err}, 'synth Elevenlabs returned error');
|
||||||
|
stats.increment('tts.count', ['vendor:elevenlabs', 'accepted:no']);
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const getFileExtFromMime = (mime) => {
|
const getFileExtFromMime = (mime) => {
|
||||||
switch (mime) {
|
switch (mime) {
|
||||||
case 'audio/wav':
|
case 'audio/wav':
|
||||||
|
|||||||
Generated
+327
-641
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.2.11",
|
"version": "0.2.19",
|
||||||
"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",
|
||||||
@@ -37,7 +37,7 @@
|
|||||||
"debug": "^4.3.4",
|
"debug": "^4.3.4",
|
||||||
"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": "^11.0.0",
|
||||||
"microsoft-cognitiveservices-speech-sdk": "1.38.0",
|
"microsoft-cognitiveservices-speech-sdk": "1.38.0",
|
||||||
"openai": "^4.98.0",
|
"openai": "^4.98.0",
|
||||||
"undici": "^7.5.0"
|
"undici": "^7.5.0"
|
||||||
|
|||||||
@@ -185,6 +185,7 @@ test('AWS speech synth tests', async(t) => {
|
|||||||
language: 'en-US',
|
language: 'en-US',
|
||||||
voice: 'Joey',
|
voice: 'Joey',
|
||||||
text: 'This is a test. This is only a test',
|
text: 'This is a test. This is only a test',
|
||||||
|
renderForCaching: true,
|
||||||
});
|
});
|
||||||
t.ok(!opts.servedFromCache, `successfully synthesized aws audio to ${opts.filePath}`);
|
t.ok(!opts.servedFromCache, `successfully synthesized aws audio to ${opts.filePath}`);
|
||||||
|
|
||||||
@@ -198,6 +199,7 @@ test('AWS speech synth tests', async(t) => {
|
|||||||
language: 'en-US',
|
language: 'en-US',
|
||||||
voice: 'Joey',
|
voice: 'Joey',
|
||||||
text: 'This is a test. This is only a test',
|
text: 'This is a test. This is only a test',
|
||||||
|
renderForCaching: true,
|
||||||
});
|
});
|
||||||
t.ok(opts.servedFromCache, `successfully retrieved aws audio from cache ${opts.filePath}`);
|
t.ok(opts.servedFromCache, `successfully retrieved aws audio from cache ${opts.filePath}`);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
@@ -720,6 +722,65 @@ test('Cartesia speech synth tests', async(t) => {
|
|||||||
client.quit();
|
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) => {
|
test('rimelabs speech synth tests mist', async(t) => {
|
||||||
const fn = require('..');
|
const fn = require('..');
|
||||||
const {synthAudio, client} = fn(opts, logger);
|
const {synthAudio, client} = fn(opts, logger);
|
||||||
|
|||||||
Reference in New Issue
Block a user