mirror of
https://github.com/jambonz/speech-utils.git
synced 2026-10-04 17:14:42 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
db135ee5ad | ||
|
|
5eac4c2ad8 | ||
|
|
e23a1a6d09 | ||
|
|
3a78300a08 | ||
|
|
1d7390e7ae | ||
|
|
3c0940f657 | ||
|
|
6fb6195b16 | ||
|
|
2ff8587601 | ||
|
|
925bd26a70 | ||
|
|
ddea485f5f | ||
|
|
49de25feb8 | ||
|
|
08b55b8d79 | ||
|
|
59bca302b9 | ||
|
|
0d98f73c43 | ||
|
|
36670e0080 | ||
|
|
61672f9868 | ||
|
|
ddeca8eb99 |
+3
-1
@@ -2,6 +2,7 @@ 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_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_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_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;
|
||||||
@@ -21,5 +22,6 @@ module.exports = {
|
|||||||
JAMBONES_TTS_CACHE_DURATION_MINS,
|
JAMBONES_TTS_CACHE_DURATION_MINS,
|
||||||
JAMBONES_EAGERLY_PRE_CACHE_AUDIO,
|
JAMBONES_EAGERLY_PRE_CACHE_AUDIO,
|
||||||
TMP_FOLDER,
|
TMP_FOLDER,
|
||||||
HTTP_TIMEOUT
|
HTTP_TIMEOUT,
|
||||||
|
JAMBONES_AZURE_ENABLE_SSML
|
||||||
};
|
};
|
||||||
|
|||||||
+15
-8
@@ -47,6 +47,7 @@ const {
|
|||||||
JAMBONES_HTTP_PROXY_PORT,
|
JAMBONES_HTTP_PROXY_PORT,
|
||||||
JAMBONES_TTS_CACHE_DURATION_MINS,
|
JAMBONES_TTS_CACHE_DURATION_MINS,
|
||||||
JAMBONES_TTS_TRIM_SILENCE,
|
JAMBONES_TTS_TRIM_SILENCE,
|
||||||
|
JAMBONES_AZURE_ENABLE_SSML
|
||||||
} = 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');
|
||||||
@@ -466,7 +467,6 @@ async function _synthOnPremMicrosoft(logger, {
|
|||||||
}) {
|
}) {
|
||||||
const {use_custom_tts, custom_tts_endpoint_url, api_key} = credentials;
|
const {use_custom_tts, custom_tts_endpoint_url, api_key} = credentials;
|
||||||
let content = text;
|
let content = text;
|
||||||
|
|
||||||
if (use_custom_tts && !content.startsWith('<speak')) {
|
if (use_custom_tts && !content.startsWith('<speak')) {
|
||||||
/**
|
/**
|
||||||
* Note: it seems that to use custom voice ssml is required with the voice attribute
|
* Note: it seems that to use custom voice ssml is required with the voice attribute
|
||||||
@@ -482,6 +482,10 @@ async function _synthOnPremMicrosoft(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');
|
||||||
}
|
}
|
||||||
|
else if (JAMBONES_AZURE_ENABLE_SSML && !content.startsWith('<speak')) {
|
||||||
|
// 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>`;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const trimSilence = JAMBONES_TTS_TRIM_SILENCE;
|
const trimSilence = JAMBONES_TTS_TRIM_SILENCE;
|
||||||
@@ -518,19 +522,23 @@ const synthMicrosoft = async(logger, {
|
|||||||
let content = text;
|
let content = text;
|
||||||
if (use_custom_tts && !content.startsWith('<speak')) {
|
if (use_custom_tts && !content.startsWith('<speak')) {
|
||||||
/**
|
/**
|
||||||
* Note: it seems that to use custom voice ssml is required with the voice attribute
|
* Note: it seems that to use custom voice ssml is required with the voice attribute
|
||||||
* Otherwise sending plain text we get "Voice does not match"
|
* Otherwise sending plain text we get "Voice does not match"
|
||||||
*/
|
*/
|
||||||
content = `<speak>${text}</speak>`;
|
content = `<speak>${text}</speak>`;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (content.startsWith('<speak>')) {
|
if (content.startsWith('<speak>')) {
|
||||||
/* 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}"><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');
|
||||||
}
|
}
|
||||||
|
else if (JAMBONES_AZURE_ENABLE_SSML && !content.startsWith('<speak')) {
|
||||||
|
// 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>`;
|
||||||
|
}
|
||||||
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 = '';
|
||||||
@@ -855,11 +863,10 @@ const synthElevenlabs = async(logger, {
|
|||||||
const synthPlayHT = async(client, logger, {
|
const synthPlayHT = async(client, logger, {
|
||||||
credentials, options, stats, voice, language, text, renderForCaching, disableTtsStreaming
|
credentials, options, stats, voice, language, text, renderForCaching, disableTtsStreaming
|
||||||
}) => {
|
}) => {
|
||||||
const {api_key, user_id, voice_engine, options: credOpts} = credentials;
|
const {api_key, user_id, voice_engine, playht_tts_uri, options: credOpts} = credentials;
|
||||||
const opts = !!options && Object.keys(options).length !== 0 ? options : JSON.parse(credOpts || '{}');
|
const opts = !!options && Object.keys(options).length !== 0 ? options : JSON.parse(credOpts || '{}');
|
||||||
|
|
||||||
let synthesizeUrl = 'https://api.play.ht/api/v2/tts/stream';
|
let synthesizeUrl = playht_tts_uri ? `${playht_tts_uri}/api/v2/tts/stream` : 'https://api.play.ht/api/v2/tts/stream';
|
||||||
|
|
||||||
// If model is play3.0, the synthesizeUrl is got from authentication endpoint
|
// If model is play3.0, the synthesizeUrl is got from authentication endpoint
|
||||||
if (voice_engine === 'Play3.0') {
|
if (voice_engine === 'Play3.0') {
|
||||||
try {
|
try {
|
||||||
|
|||||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "@jambonz/speech-utils",
|
"name": "@jambonz/speech-utils",
|
||||||
"version": "0.2.9",
|
"version": "0.2.12",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "@jambonz/speech-utils",
|
"name": "@jambonz/speech-utils",
|
||||||
"version": "0.2.9",
|
"version": "0.2.12",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"23": "^0.0.0",
|
"23": "^0.0.0",
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@jambonz/speech-utils",
|
"name": "@jambonz/speech-utils",
|
||||||
"version": "0.2.9",
|
"version": "0.2.12",
|
||||||
"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",
|
||||||
|
|||||||
Reference in New Issue
Block a user