mirror of
https://github.com/jambonz/speech-utils.git
synced 2026-10-03 23:33:59 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
33456b93d9 | ||
|
|
70e91b5057 | ||
|
|
c066840f85 |
+3
-2
@@ -941,8 +941,9 @@ const synthInworld = async(logger, {
|
||||
params += `,voice=${voice}`;
|
||||
params += `,write_cache_file=${disableTtsCache ? 0 : 1}`;
|
||||
if (opts.temperature) params += `,temperature=${opts.temperature}`;
|
||||
if (opts.audioConfig?.pitch) params += `,pitch=${opts.pitch}`;
|
||||
if (opts.audioConfig?.speakingRate) params += `,speakingRate=${opts.speakingRate}`;
|
||||
/* pitch and speakingRate are nested under audioConfig, matching Inworld's API */
|
||||
if (opts.audioConfig?.pitch) params += `,pitch=${opts.audioConfig.pitch}`;
|
||||
if (opts.audioConfig?.speakingRate) params += `,speakingRate=${opts.audioConfig.speakingRate}`;
|
||||
params += '}';
|
||||
|
||||
return {
|
||||
|
||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "@jambonz/speech-utils",
|
||||
"version": "1.0.15",
|
||||
"version": "1.0.16",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@jambonz/speech-utils",
|
||||
"version": "1.0.15",
|
||||
"version": "1.0.16",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@aws-sdk/client-polly": "^3.496.0",
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@jambonz/speech-utils",
|
||||
"version": "1.0.15",
|
||||
"version": "1.0.16",
|
||||
"description": "TTS-related speech utilities for jambonz",
|
||||
"main": "index.js",
|
||||
"author": "Dave Horton",
|
||||
|
||||
@@ -1147,6 +1147,69 @@ test('inworld speech synth', async(t) => {
|
||||
client.quit();
|
||||
});
|
||||
|
||||
test('inworld streaming say: params', async(t) => {
|
||||
/* This test asserts the streaming say: path, so it must run with streaming
|
||||
enabled. The Google non-streaming test above sets
|
||||
JAMBONES_DISABLE_TTS_STREAMING and, on its no-credentials skip path,
|
||||
deletes the env var WITHOUT clearing the require cache — so lib/config can
|
||||
still be holding 'true' by the time we get here. Re-require to be
|
||||
independent of what ran before us.
|
||||
*/
|
||||
delete process.env.JAMBONES_DISABLE_TTS_STREAMING;
|
||||
delete require.cache[require.resolve('../lib/config')];
|
||||
delete require.cache[require.resolve('../lib/synth-audio')];
|
||||
delete require.cache[require.resolve('..')];
|
||||
|
||||
const fn = require('..');
|
||||
const {synthAudio, client} = fn(opts, logger);
|
||||
|
||||
if (!process.env.INWORLD_API_KEY) {
|
||||
t.pass('skipping inworld streaming say: param tests since INWORLD_API_KEY is not provided');
|
||||
client.quit();
|
||||
return t.end();
|
||||
}
|
||||
|
||||
try {
|
||||
let result = await synthAudio(stats, {
|
||||
vendor: 'inworld',
|
||||
credentials: {api_key: process.env.INWORLD_API_KEY, model_id: 'inworld-tts-1.5-mini'},
|
||||
language: 'en',
|
||||
voice: 'Ashley',
|
||||
text: 'This is a test of inworld streaming.',
|
||||
options: {temperature: 0.9, audioConfig: {pitch: 2.5, speakingRate: 1.2}},
|
||||
disableTtsCache: true
|
||||
});
|
||||
t.ok(result.filePath.startsWith('say:'), 'inworld returns streaming say: path');
|
||||
t.ok(result.filePath.includes('vendor=inworld'), 'streaming path contains vendor=inworld');
|
||||
t.ok(result.filePath.includes('voice=Ashley'), 'streaming path contains voice');
|
||||
t.ok(result.filePath.includes('model_id=inworld-tts-1.5-mini'), 'streaming path contains model_id');
|
||||
t.ok(result.filePath.includes('temperature=0.9'), 'streaming path contains temperature');
|
||||
/* pitch and speakingRate are nested under audioConfig; they used to be read
|
||||
from the top level and emitted as "undefined"
|
||||
*/
|
||||
t.ok(result.filePath.includes('speakingRate=1.2'), 'audioConfig.speakingRate reaches the say: params');
|
||||
t.ok(result.filePath.includes('pitch=2.5'), 'audioConfig.pitch reaches the say: params');
|
||||
t.ok(!result.filePath.includes('undefined'), 'no undefined values in the say: params');
|
||||
|
||||
/* options omitted entirely: no stray keys */
|
||||
result = await synthAudio(stats, {
|
||||
vendor: 'inworld',
|
||||
credentials: {api_key: process.env.INWORLD_API_KEY, model_id: 'inworld-tts-1.5-mini'},
|
||||
language: 'en',
|
||||
voice: 'Ashley',
|
||||
text: 'This is a test of inworld streaming.',
|
||||
disableTtsCache: true
|
||||
});
|
||||
t.ok(!result.filePath.includes('speakingRate='), 'speakingRate omitted when unset');
|
||||
t.ok(!result.filePath.includes('pitch='), 'pitch omitted when unset');
|
||||
t.ok(!result.filePath.includes('undefined'), 'no undefined values when options are omitted');
|
||||
} 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);
|
||||
|
||||
Reference in New Issue
Block a user