This commit is contained in:
Quan HL
2024-04-10 05:47:56 +07:00
parent c131209d42
commit ee7dfbc194
+9 -9
View File
@@ -257,13 +257,7 @@ const testPlayHT = async(logger, synthAudio, credentials) => {
}
);
// Test if playHT can fetch voices
const get = bent('https://api.play.ht', 'GET', 'json', {
'AUTHORIZATION' : credentials.api_key,
'X-USER-ID': credentials.user_id,
'Accept': 'application/json'
});
await Promise.all([ get('/api/v2/cloned-voices'), get('/api/v2/voices')]);
await fetchLayHTVoices(credentials);
} catch (err) {
logger.info({err}, 'synth Playht returned error');
throw err;
@@ -687,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,
@@ -695,7 +689,13 @@ async function getLanguagesVoicesForPlayHT(credential) {
'Accept': 'application/json'
});
const [cloned_voice, voices] = await Promise.all([ get('/api/v2/cloned-voices'), get('/api/v2/voices')]);
return await Promise.all([ get('/api/v2/cloned-voices'), get('/api/v2/voices')]);
}
};
async function getLanguagesVoicesForPlayHT(credential) {
if (credential) {
const [cloned_voice, voices] = await fetchLayHTVoices(credential);
const list_voices = [...cloned_voice, ...voices];
const buildVoice = (d) => {