mirror of
https://github.com/jambonz/jambonz-api-server.git
synced 2026-01-25 02:08:24 +00:00
feat/982: fixed issue where vendor's API is not called if vendor is defined at service provider level, and also made format of name consistent (#365)
This commit is contained in:
@@ -22,14 +22,17 @@ class SpeechCredential extends Model {
|
|||||||
|
|
||||||
static async getSpeechCredentialsByVendorAndLabel(service_provider_sid, account_sid, vendor, label) {
|
static async getSpeechCredentialsByVendorAndLabel(service_provider_sid, account_sid, vendor, label) {
|
||||||
let sql;
|
let sql;
|
||||||
|
let rows = [];
|
||||||
if (account_sid) {
|
if (account_sid) {
|
||||||
sql = `SELECT * FROM speech_credentials WHERE account_sid = ? AND vendor = ?
|
sql = `SELECT * FROM speech_credentials WHERE account_sid = ? AND vendor = ?
|
||||||
AND label ${label ? '= ?' : 'is NULL'}`;
|
AND label ${label ? '= ?' : 'is NULL'}`;
|
||||||
} else {
|
[rows] = await promisePool.query(sql, [account_sid, vendor, label]);
|
||||||
|
}
|
||||||
|
if (rows.length === 0) {
|
||||||
sql = `SELECT * FROM speech_credentials WHERE service_provider_sid = ? AND vendor = ?
|
sql = `SELECT * FROM speech_credentials WHERE service_provider_sid = ? AND vendor = ?
|
||||||
AND label ${label ? '= ?' : 'is NULL'}`;
|
AND label ${label ? '= ?' : 'is NULL'}`;
|
||||||
|
[rows] = await promisePool.query(sql, [service_provider_sid, vendor, label]);
|
||||||
}
|
}
|
||||||
const [rows] = await promisePool.query(sql, [account_sid ? account_sid : service_provider_sid, vendor, label]);
|
|
||||||
return rows;
|
return rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,12 +27,6 @@ module.exports = [
|
|||||||
value: 'miguel_es_pe',
|
value: 'miguel_es_pe',
|
||||||
name: 'Miguel-Male',
|
name: 'Miguel-Male',
|
||||||
},
|
},
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
value: 'es-PE',
|
|
||||||
name: 'Peruvian Spanish',
|
|
||||||
voices: [
|
|
||||||
{
|
{
|
||||||
value: 'luz_es_pe',
|
value: 'luz_es_pe',
|
||||||
name: 'Luz-Female',
|
name: 'Luz-Female',
|
||||||
|
|||||||
@@ -821,27 +821,35 @@ async function getLanguagesVoicesForElevenlabs(credential) {
|
|||||||
}).sort((a, b) => a.name.localeCompare(b.name)) : [];
|
}).sort((a, b) => a.name.localeCompare(b.name)) : [];
|
||||||
|
|
||||||
if (languages && languages.length > 0) {
|
if (languages && languages.length > 0) {
|
||||||
|
// using if condition to avoid \n character in name
|
||||||
const voices = voiceResp ? voiceResp.voices.map((v) => {
|
const voices = voiceResp ? voiceResp.voices.map((v) => {
|
||||||
let name = `${v.name}${v.category !== 'premade' ? ` (${v.category})` : ''} -
|
let name = `${v.name}${v.category !== 'premade' ? ` (${v.category.trim()})` : ''} - (`;
|
||||||
${v.labels.accent ? ` ${v.labels.accent},` : ''}
|
if (v.labels.accent) name += `${v.labels.accent}, `;
|
||||||
${v.labels.description ? ` ${v.labels.description},` : ''}
|
if (v.labels.description) name += `${v.labels.description}, `;
|
||||||
${v.labels.age ? ` ${v.labels.age},` : ''}
|
if (v.labels.age) name += `${v.labels.age}, `;
|
||||||
${v.labels.gender ? ` ${v.labels.gender},` : ''}
|
if (v.labels.gender) name += `${v.labels.gender}, `;
|
||||||
${v.labels['use case'] ? ` ${v.labels['use case']},` : ''}
|
if (v.labels['use case']) name += `${v.labels['use case']}, `;
|
||||||
`;
|
|
||||||
const lastIndex = name.lastIndexOf(',');
|
const lastIndex = name.lastIndexOf(',');
|
||||||
if (lastIndex !== -1) {
|
if (lastIndex !== -1) {
|
||||||
name = name.substring(0, lastIndex);
|
name = name.substring(0, lastIndex);
|
||||||
}
|
}
|
||||||
|
name += ')';
|
||||||
return {
|
return {
|
||||||
value: v.voice_id,
|
value: v.voice_id,
|
||||||
name
|
name
|
||||||
};
|
};
|
||||||
}).sort((a, b) => a.name.localeCompare(b.name)) : [];
|
}).sort((a, b) => a.name.localeCompare(b.name)) : [];
|
||||||
languages[0].voices = voices;
|
for (const language of languages) {
|
||||||
|
language.voices = voices;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return tranform(languages, undefined, TtsModelElevenLabs);
|
return tranform(languages, undefined, TtsModelElevenLabs);
|
||||||
} else {
|
} else {
|
||||||
|
const voices = TtsElevenlabsLanguagesVoices[0].voices;
|
||||||
|
for (const language of TtsElevenlabsLanguagesVoices) {
|
||||||
|
language.voices = voices;
|
||||||
|
}
|
||||||
return tranform(TtsElevenlabsLanguagesVoices, undefined, TtsModelElevenLabs);
|
return tranform(TtsElevenlabsLanguagesVoices, undefined, TtsModelElevenLabs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -876,10 +884,12 @@ async function getLanguagesVoicesForPlayHT(credential) {
|
|||||||
const list_voices = [...cloned_voice, ...voices];
|
const list_voices = [...cloned_voice, ...voices];
|
||||||
|
|
||||||
const buildVoice = (d) => {
|
const buildVoice = (d) => {
|
||||||
let name = `${d.name} -${concat(d.accent)}${concat(d.age)}${concat(d.gender)}${concat(d.loudness)}` +
|
let name = `${d.name} - (${concat(d.accent)}${concat(d.age)}${concat(d.gender)}${concat(d.loudness)}` +
|
||||||
`${concat(d.style)}${concat(d.tempo)}${concat(d.texture)}` ;
|
`${concat(d.style)}${concat(d.tempo)}${concat(d.texture)}` ;
|
||||||
name = name.endsWith(',') ? name.trim().slice(0, -1) : name;
|
name = name.endsWith(',') ? name.trim().slice(0, -1) : name;
|
||||||
name += !d.language_code ? ' - Custom Voice' : '';
|
name += !d.language_code ? ' - Custom Voice' : '';
|
||||||
|
name += ')';
|
||||||
|
name = name.replaceAll('( ', '(');
|
||||||
|
|
||||||
return {
|
return {
|
||||||
value: `${d.id}`,
|
value: `${d.id}`,
|
||||||
@@ -965,15 +975,18 @@ async function getLanguagesVoicesForWhisper(credential) {
|
|||||||
|
|
||||||
async function getLanguagesVoicesForVerbio(credentials, getTtsVoices, logger) {
|
async function getLanguagesVoicesForVerbio(credentials, getTtsVoices, logger) {
|
||||||
const stt = SttVerbioLanguagesVoices.reduce((acc, v) => {
|
const stt = SttVerbioLanguagesVoices.reduce((acc, v) => {
|
||||||
if (!v.version || credentials.engine_version === v.version) {
|
if (!v.version || (credentials && credentials.engine_version === v.version)) {
|
||||||
acc.push(v);
|
acc.push(v);
|
||||||
}
|
}
|
||||||
return acc;
|
return acc;
|
||||||
}, []);
|
}, []);
|
||||||
try {
|
try {
|
||||||
const data = await getTtsVoices({vendor: 'verbio', credentials});
|
if (credentials) {
|
||||||
const voices = parseVerbioLanguagesVoices(data);
|
const data = await getTtsVoices({vendor: 'verbio', credentials});
|
||||||
return tranform(voices, stt, undefined);
|
const voices = parseVerbioLanguagesVoices(data);
|
||||||
|
return tranform(voices, stt, undefined);
|
||||||
|
}
|
||||||
|
return tranform(TtsVerbioLanguagesVoices, stt, undefined);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
logger.info({err}, 'there is error while fetching verbio speech voices');
|
logger.info({err}, 'there is error while fetching verbio speech voices');
|
||||||
return tranform(TtsVerbioLanguagesVoices, stt, undefined);
|
return tranform(TtsVerbioLanguagesVoices, stt, undefined);
|
||||||
@@ -1043,7 +1056,7 @@ function parseAwsLanguagesVoices(data) {
|
|||||||
if (existingLanguage) {
|
if (existingLanguage) {
|
||||||
existingLanguage.voices.push({
|
existingLanguage.voices.push({
|
||||||
value: voice.Id,
|
value: voice.Id,
|
||||||
name: `(${voice.Gender}) ${voice.Name}`
|
name: `${voice.Name} (${voice.Gender})`
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
acc.push({
|
acc.push({
|
||||||
@@ -1051,7 +1064,7 @@ function parseAwsLanguagesVoices(data) {
|
|||||||
name: voice.LanguageName,
|
name: voice.LanguageName,
|
||||||
voices: [{
|
voices: [{
|
||||||
value: voice.Id,
|
value: voice.Id,
|
||||||
name: `(${voice.Gender}) ${voice.Name}`
|
name: `${voice.Name} (${voice.Gender})`
|
||||||
}]
|
}]
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user