Compare commits

...
5 Commits
Author SHA1 Message Date
Dave Horton 6efc99ad83 0.2.21 2025-08-20 10:59:40 -04:00
Dave Horton 127d01a8c1 add playback_id setting to additional tts vendors 2025-08-20 10:58:28 -04:00
Dave Horton 1900b26d8b 0.2.20 2025-08-20 10:01:01 -04:00
Dave Horton aa25a6f6d9 Merge pull request #125 from jambonz/feat/add-playback-id
add playback_id to say metadata
2025-08-20 10:00:37 -04:00
Dave Horton 8dfe17b600 add playback_id to say metadata 2025-08-20 08:58:46 -04:00
3 changed files with 37 additions and 23 deletions
+34 -20
View File
@@ -53,6 +53,8 @@ const EXPIRES = JAMBONES_TTS_CACHE_DURATION_MINS;
const OpenAI = require('openai'); const OpenAI = require('openai');
const getAwsAuthToken = require('./get-aws-sts-token'); const getAwsAuthToken = require('./get-aws-sts-token');
/* counter for playback id */
let playbackIdCounter = 0;
const trimTrailingSilence = (buffer) => { const trimTrailingSilence = (buffer) => {
assert.ok(buffer instanceof Buffer, 'trimTrailingSilence - argument is not a Buffer'); assert.ok(buffer instanceof Buffer, 'trimTrailingSilence - argument is not a Buffer');
@@ -313,6 +315,7 @@ const synthPolly = async(createHash, retrieveHash, logger,
let params = '{'; let params = '{';
params += `language=${language}`; params += `language=${language}`;
params += `,playback_id=${playbackIdCounter++}`;
params += ',write_cache_file=1'; params += ',write_cache_file=1';
params += ',vendor=aws'; params += ',vendor=aws';
if (accessKeyId && secretAccessKey) { if (accessKeyId && secretAccessKey) {
@@ -589,8 +592,9 @@ const synthMicrosoft = async(logger, {
} }
if (!JAMBONES_DISABLE_TTS_STREAMING && !JAMBONES_DISABLE_AZURE_TTS_STREAMING && if (!JAMBONES_DISABLE_TTS_STREAMING && !JAMBONES_DISABLE_AZURE_TTS_STREAMING &&
!renderForCaching && !disableTtsStreaming) { !renderForCaching && !disableTtsStreaming) {
let params = ''; let params = '{';
params += `{api_key=${apiKey}`; params += `api_key=${apiKey}`;
params += `,playback_id=${playbackIdCounter++}`;
params += `,language=${language}`; params += `,language=${language}`;
params += ',vendor=microsoft'; params += ',vendor=microsoft';
params += `,voice=${voice}`; params += `,voice=${voice}`;
@@ -773,6 +777,7 @@ const synthNvidia = async(client, logger, {
if (!JAMBONES_DISABLE_TTS_STREAMING && !renderForCaching && !disableTtsStreaming) { if (!JAMBONES_DISABLE_TTS_STREAMING && !renderForCaching && !disableTtsStreaming) {
let params = ''; let params = '';
params += `{riva_server_uri=${riva_server_uri}`; params += `{riva_server_uri=${riva_server_uri}`;
params += `,playback_id=${playbackIdCounter++}`;
params += `,voice=${voice}`; params += `,voice=${voice}`;
params += `,language=${language}`; params += `,language=${language}`;
params += ',write_cache_file=1'; params += ',write_cache_file=1';
@@ -853,8 +858,9 @@ const synthElevenlabs = async(logger, {
/* default to using the streaming interface, unless disabled by env var OR we want just a cache file */ /* 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) { if (!JAMBONES_DISABLE_TTS_STREAMING && !renderForCaching && !disableTtsStreaming) {
let params = ''; let params = '{';
params += `{api_key=${api_key}`; params += `api_key=${api_key}`;
params += `,playback_id=${playbackIdCounter++}`;
params += ',vendor=elevenlabs'; params += ',vendor=elevenlabs';
params += `,voice=${voice}`; params += `,voice=${voice}`;
params += `,model_id=${model_id}`; params += `,model_id=${model_id}`;
@@ -943,8 +949,9 @@ const synthPlayHT = async(client, logger, {
/* default to using the streaming interface, unless disabled by env var OR we want just a cache file */ /* 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) { if (!JAMBONES_DISABLE_TTS_STREAMING && !renderForCaching && !disableTtsStreaming) {
let params = ''; let params = '{';
params += `{api_key=${api_key}`; params += `api_key=${api_key}`;
params += `,playback_id=${playbackIdCounter++}`;
params += `,user_id=${user_id}`; params += `,user_id=${user_id}`;
params += ',vendor=playht'; params += ',vendor=playht';
params += `,voice=${voice}`; params += `,voice=${voice}`;
@@ -1010,8 +1017,9 @@ const synthInworld = async(logger, {
/* default to using the streaming interface, unless disabled by env var OR we want just a cache file */ /* 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) { if (!JAMBONES_DISABLE_TTS_STREAMING && !renderForCaching && !disableTtsStreaming) {
let params = ''; let params = '{';
params += `{api_key=${api_key}`; params += `api_key=${api_key}`;
params += `,playback_id=${playbackIdCounter++}`;
params += `,model_id=${model_id}`; params += `,model_id=${model_id}`;
params += ',vendor=inworld'; params += ',vendor=inworld';
params += `,voice=${voice}`; params += `,voice=${voice}`;
@@ -1074,8 +1082,9 @@ const synthRimelabs = async(logger, {
/* default to using the streaming interface, unless disabled by env var OR we want just a cache file */ /* 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) { if (!JAMBONES_DISABLE_TTS_STREAMING && !renderForCaching && !disableTtsStreaming) {
let params = ''; let params = '{';
params += `{api_key=${api_key}`; params += `api_key=${api_key}`;
params += `,playback_id=${playbackIdCounter++}`;
params += `,model_id=${model_id}`; params += `,model_id=${model_id}`;
params += ',vendor=rimelabs'; params += ',vendor=rimelabs';
params += `,language=${language}`; params += `,language=${language}`;
@@ -1130,8 +1139,9 @@ const synthVerbio = async(client, logger, {credentials, stats, voice, text, rend
} }
const token = await getVerbioAccessToken(client, logger, credentials); const token = await getVerbioAccessToken(client, logger, credentials);
if (!process.env.JAMBONES_DISABLE_TTS_STREAMING && !renderForCaching && !disableTtsStreaming) { if (!process.env.JAMBONES_DISABLE_TTS_STREAMING && !renderForCaching && !disableTtsStreaming) {
let params = ''; let params = '{';
params += `{access_token=${token.access_token}`; params += `access_token=${token.access_token}`;
params += `,playback_id=${playbackIdCounter++}`;
params += ',vendor=verbio'; params += ',vendor=verbio';
params += `,voice=${voice}`; params += `,voice=${voice}`;
params += ',write_cache_file=1'; params += ',write_cache_file=1';
@@ -1173,8 +1183,9 @@ const synthWhisper = async(logger, {credentials, stats, voice, text, instruction
const {api_key, model_id, baseURL, timeout, speed} = credentials; const {api_key, model_id, baseURL, timeout, speed} = credentials;
/* if the env is set to stream then bag out, unless we are specifically rendering to generate a cache file */ /* if the env is set to stream then bag out, unless we are specifically rendering to generate a cache file */
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 += `,playback_id=${playbackIdCounter++}`;
params += `,model_id=${model_id}`; params += `,model_id=${model_id}`;
params += ',vendor=whisper'; params += ',vendor=whisper';
params += `,voice=${voice}`; params += `,voice=${voice}`;
@@ -1219,8 +1230,9 @@ const synthWhisper = async(logger, {credentials, stats, voice, text, instruction
const synthDeepgram = async(logger, {credentials, stats, model, text, renderForCaching, disableTtsStreaming}) => { const synthDeepgram = async(logger, {credentials, stats, model, text, renderForCaching, disableTtsStreaming}) => {
const {api_key, deepgram_tts_uri} = 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 += `,playback_id=${playbackIdCounter++}`;
params += ',vendor=deepgram'; params += ',vendor=deepgram';
params += `,voice=${model}`; params += `,voice=${model}`;
params += ',write_cache_file=1'; params += ',write_cache_file=1';
@@ -1262,8 +1274,9 @@ const synthCartesia = async(logger, {
const opts = !!options && Object.keys(options).length !== 0 ? options : JSON.parse(credOpts || '{}'); const opts = !!options && Object.keys(options).length !== 0 ? options : JSON.parse(credOpts || '{}');
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 += `,playback_id=${playbackIdCounter++}`;
params += `,model_id=${model_id}`; params += `,model_id=${model_id}`;
params += ',vendor=cartesia'; params += ',vendor=cartesia';
params += `,voice=${voice}`; params += `,voice=${voice}`;
@@ -1333,8 +1346,9 @@ const synthResemble = async(logger, {
/* default to using the streaming interface, unless disabled by env var OR we want just a cache file */ /* 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) { if (!JAMBONES_DISABLE_TTS_STREAMING && !renderForCaching && !disableTtsStreaming) {
let params = ''; let params = '{';
params += `{api_key=${api_key}`; params += `api_key=${api_key}`;
params += `,playback_id=${playbackIdCounter++}`;
params += ',vendor=resemble'; params += ',vendor=resemble';
params += `,voice=${voice}`; params += `,voice=${voice}`;
params += ',write_cache_file=1'; params += ',write_cache_file=1';
+2 -2
View File
@@ -1,12 +1,12 @@
{ {
"name": "@jambonz/speech-utils", "name": "@jambonz/speech-utils",
"version": "0.2.19", "version": "0.2.21",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "@jambonz/speech-utils", "name": "@jambonz/speech-utils",
"version": "0.2.19", "version": "0.2.21",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"23": "^0.0.0", "23": "^0.0.0",
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "@jambonz/speech-utils", "name": "@jambonz/speech-utils",
"version": "0.2.19", "version": "0.2.21",
"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",