mirror of
https://github.com/jambonz/speech-utils.git
synced 2026-07-24 21:22:00 +00:00
support google voice cloning
This commit is contained in:
+12
-4
@@ -23,19 +23,20 @@ function makeSynthKey({
|
||||
hash.update(`${language}:${vendor}:${voice}:${engine}:${text}`);
|
||||
const hexHashKey = hash.digest('hex');
|
||||
const accountKey = account_sid ? `:${account_sid}` : '';
|
||||
const namespace = vendor.startsWith('custom') ? vendor : getFileExtension({vendor, renderForCaching});
|
||||
const namespace = vendor.startsWith('custom') ? vendor : getFileExtension({vendor, voice, renderForCaching});
|
||||
const key = `tts${accountKey}:${namespace}:${hexHashKey}`;
|
||||
return key;
|
||||
}
|
||||
|
||||
function makeFilePath({vendor, key, salt = '', renderForCaching = false}) {
|
||||
const extension = getFileExtension({vendor, renderForCaching});
|
||||
function makeFilePath({vendor, voice, key, salt = '', renderForCaching = false}) {
|
||||
const extension = getFileExtension({vendor, renderForCaching, voice});
|
||||
return `${TMP_FOLDER}/${key.replace('tts:', `tts-${salt}`)}.${extension}`;
|
||||
}
|
||||
|
||||
function getFileExtension({vendor, renderForCaching = false}) {
|
||||
function getFileExtension({vendor, voice, renderForCaching = false}) {
|
||||
const mp3Extension = 'mp3';
|
||||
const r8Extension = 'r8';
|
||||
const wavExtension = 'wav';
|
||||
|
||||
switch (vendor) {
|
||||
case 'azure':
|
||||
@@ -58,6 +59,13 @@ function getFileExtension({vendor, renderForCaching = false}) {
|
||||
case 'nvidia':
|
||||
case 'verbio':
|
||||
return r8Extension;
|
||||
case 'google':
|
||||
// google voice cloning just support wav.
|
||||
if (typeof voice === 'object' && voice.voice_cloning_key) {
|
||||
return wavExtension;
|
||||
} else {
|
||||
return mp3Extension;
|
||||
}
|
||||
default:
|
||||
// If vendor is custom
|
||||
if (vendor.startsWith('custom')) {
|
||||
|
||||
Reference in New Issue
Block a user