mirror of
https://github.com/jambonz/speech-utils.git
synced 2026-07-04 19:31:49 +00:00
wip
This commit is contained in:
+7
-7
@@ -18,29 +18,29 @@ const debug = require('debug')('jambonz:realtimedb-helpers');
|
||||
|
||||
function makeSynthKey({
|
||||
account_sid = '', vendor, language, voice, engine = '', text,
|
||||
preCache = false}) {
|
||||
renderForCaching = false}) {
|
||||
const hash = crypto.createHash('sha1');
|
||||
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, preCache});
|
||||
const namespace = vendor.startsWith('custom') ? vendor : getFileExtension({vendor, renderForCaching});
|
||||
const key = `tts${accountKey}:${namespace}:${hexHashKey}`;
|
||||
return key;
|
||||
}
|
||||
|
||||
function makeFilePath({vendor, key, salt = '', preCache = false}) {
|
||||
const extension = getFileExtension({vendor, preCache});
|
||||
function makeFilePath({vendor, key, salt = '', renderForCaching = false}) {
|
||||
const extension = getFileExtension({vendor, renderForCaching});
|
||||
return `${TMP_FOLDER}/${key.replace('tts:', `tts-${salt}`)}.${extension}`;
|
||||
}
|
||||
|
||||
function getFileExtension({vendor, preCache = false}) {
|
||||
function getFileExtension({vendor, renderForCaching = false}) {
|
||||
const mp3Extension = 'mp3';
|
||||
const r8Extension = 'r8';
|
||||
|
||||
switch (vendor) {
|
||||
case 'azure':
|
||||
case 'microsoft':
|
||||
if (!preCache && !JAMBONES_DISABLE_TTS_STREAMING || JAMBONES_TTS_TRIM_SILENCE) {
|
||||
if (!renderForCaching && !JAMBONES_DISABLE_TTS_STREAMING || JAMBONES_TTS_TRIM_SILENCE) {
|
||||
return r8Extension;
|
||||
} else {
|
||||
return mp3Extension;
|
||||
@@ -48,7 +48,7 @@ function getFileExtension({vendor, preCache = false}) {
|
||||
case 'deepgram':
|
||||
case 'elevenlabs':
|
||||
case 'rimlabs':
|
||||
if (!preCache && !JAMBONES_DISABLE_TTS_STREAMING) {
|
||||
if (!renderForCaching && !JAMBONES_DISABLE_TTS_STREAMING) {
|
||||
return r8Extension;
|
||||
} else {
|
||||
return mp3Extension;
|
||||
|
||||
Reference in New Issue
Block a user