Skip to content

Commit

Permalink
support mod_rimelabs_tts (#310)
Browse files Browse the repository at this point in the history
* support mod_rimelabs_tts

* update speech utils 0.0.51
  • Loading branch information
xquanluu committed Apr 12, 2024
1 parent 80418aa commit 39fcb17
Show file tree
Hide file tree
Showing 7 changed files with 815 additions and 7 deletions.
20 changes: 19 additions & 1 deletion lib/routes/api/speech-credentials.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ const {decrypt, encrypt} = require('../../utils/encrypt-decrypt');
const {parseAccountSid, parseServiceProviderSid, parseSpeechCredentialSid} = require('./utils');
const {decryptCredential, testWhisper, testDeepgramTTS,
getLanguagesAndVoicesForVendor,
testPlayHT} = require('../../utils/speech-utils');
testPlayHT,
testRimelabs} = require('../../utils/speech-utils');
const {DbErrorUnprocessableRequest, DbErrorForbidden, DbErrorBadRequest} = require('../../utils/errors');
const {
testGoogleTts,
Expand Down Expand Up @@ -229,6 +230,12 @@ const encryptCredential = (obj) => {
const playhtData = JSON.stringify({api_key, user_id, voice_engine, options});
return encrypt(playhtData);

case 'rimelabs':
assert(api_key, 'invalid rimelabs speech credential: api_key is required');
assert(model_id, 'invalid rimelabs speech credential: model_id is required');
const rimelabsData = JSON.stringify({api_key, model_id, options});
return encrypt(rimelabsData);

case 'assemblyai':
assert(api_key, 'invalid assemblyai speech credential: api_key is required');
const assemblyaiData = JSON.stringify({api_key});
Expand Down Expand Up @@ -752,6 +759,17 @@ router.get('/:sid/test', async(req, res) => {
SpeechCredential.ttsTestResult(sid, false);
}
}
} else if (cred.vendor === 'rimelabs') {
if (cred.use_for_tts) {
try {
await testRimelabs(logger, synthAudio, credential);
results.tts.status = 'ok';
SpeechCredential.ttsTestResult(sid, true);
} catch (err) {
results.tts = {status: 'fail', reason: err.message};
SpeechCredential.ttsTestResult(sid, false);
}
}
} else if (cred.vendor === 'assemblyai') {
const {api_key} = credential;
if (cred.use_for_stt) {
Expand Down
5 changes: 5 additions & 0 deletions lib/utils/speech-data/tts-model-rimelabs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = [
{ name: 'Mist', value: 'mist' },
{ name: 'V1', value: 'v1' },
];

Loading

0 comments on commit 39fcb17

Please sign in to comment.