@@ -9,16 +9,25 @@ const { runconvert } = require('./convert/convert')
99const { wer } = require ( './utils' )
1010const debug = require ( 'debug' ) ( 'botium-speech-processing-routes' )
1111
12- const cachePathStt = process . env . BOTIUM_SPEECH_CACHE_DIR && path . join ( process . env . BOTIUM_SPEECH_CACHE_DIR , 'stt' )
13- const cachePathTts = process . env . BOTIUM_SPEECH_CACHE_DIR && path . join ( process . env . BOTIUM_SPEECH_CACHE_DIR , 'tts' )
12+ const cachePathStt = ( process . env . BOTIUM_SPEECH_CACHE_DIR && path . join ( process . env . BOTIUM_SPEECH_CACHE_DIR , 'stt' ) ) || './resources/.cache/stt'
13+ const cachePathTts = ( process . env . BOTIUM_SPEECH_CACHE_DIR && path . join ( process . env . BOTIUM_SPEECH_CACHE_DIR , 'tts' ) ) || './resources/.cache/tts'
14+ const tmpPath = process . env . BOTIUM_SPEECH_TMP_DIR || './resources/.tmp'
1415const cacheKeyStt = ( data , language , ext ) => sanitize ( `${ crypto . createHash ( 'md5' ) . update ( data ) . digest ( 'hex' ) } _${ language } ${ ext } ` )
1516const cacheKeyTts = ( data , language , voice , ext ) => sanitize ( `${ crypto . createHash ( 'md5' ) . update ( data ) . digest ( 'hex' ) } _${ language } _${ voice || 'default' } ${ ext } ` )
1617
18+ if ( process . env . BOTIUM_SPEECH_CACHE_DIR === undefined ) {
19+ console . log ( `ATTENTION: cache dir is not set, using ${ cachePathStt } and ${ cachePathTts } instead` )
20+ }
21+
22+ if ( process . env . BOTIUM_SPEECH_TMP_DIR === undefined ) {
23+ console . log ( `ATTENTION: tmp dir is not set, using ${ tmpPath } instead` )
24+ }
25+
1726if ( cachePathStt ) mkdirp . sync ( cachePathStt )
1827if ( cachePathTts ) mkdirp . sync ( cachePathTts )
1928
20- if ( process . env . BOTIUM_SPEECH_TMP_DIR ) {
21- mkdirp . sync ( process . env . BOTIUM_SPEECH_TMP_DIR )
29+ if ( tmpPath ) {
30+ mkdirp . sync ( tmpPath )
2231}
2332
2433const ttsEngines = {
0 commit comments