Compare commits

...

5 Commits

Author SHA1 Message Date
Quan HL
4b23cabee8 wip 2024-04-10 18:17:23 +07:00
Quan HL
446ae5ae70 wip 2024-04-10 18:15:15 +07:00
Quan HL
678fd086ea wip 2024-04-10 06:11:46 +07:00
Quan HL
ee7dfbc194 wip 2024-04-10 05:47:56 +07:00
Quan HL
c131209d42 check playht can fetch voices when adding new speech credential 2024-04-10 05:42:40 +07:00
2 changed files with 23 additions and 3 deletions

View File

@@ -743,7 +743,12 @@ router.get('/:sid/test', async(req, res) => {
results.tts.status = 'ok';
SpeechCredential.ttsTestResult(sid, true);
} catch (err) {
results.tts = {status: 'fail', reason: err.message};
let reason = err.message;
// if error is from bent, let get the body
try {
reason = await err.text();
} catch {}
results.tts = {status: 'fail', reason};
SpeechCredential.ttsTestResult(sid, false);
}
}

View File

@@ -256,6 +256,8 @@ const testPlayHT = async(logger, synthAudio, credentials) => {
text: 'Hi there and welcome to jambones!'
}
);
// Test if playHT can fetch voices
await fetchLayHTVoices(credentials);
} catch (err) {
logger.info({err}, 'synth Playht returned error');
throw err;
@@ -679,7 +681,7 @@ const concat = (a) => {
return a ? ` ${a},` : '';
};
async function getLanguagesVoicesForPlayHT(credential) {
const fetchLayHTVoices = async(credential) => {
if (credential) {
const get = bent('https://api.play.ht', 'GET', 'json', {
'AUTHORIZATION' : credential.api_key,
@@ -687,7 +689,20 @@ async function getLanguagesVoicesForPlayHT(credential) {
'Accept': 'application/json'
});
const [cloned_voice, voices] = await Promise.all([ get('/api/v2/cloned-voices'), get('/api/v2/voices')]);
const voices = await get('/api/v2/voices');
let clone_voices = [];
try {
// try if the account has permission to cloned voice
//otherwise ignore this.
clone_voices = await get('/api/v2/cloned-voices');
} catch {}
return [clone_voices, voices];
}
};
async function getLanguagesVoicesForPlayHT(credential) {
if (credential) {
const [cloned_voice, voices] = await fetchLayHTVoices(credential);
const list_voices = [...cloned_voice, ...voices];
const buildVoice = (d) => {