Skip to content

Commit aef2ff9

Browse files
committed
using default cache path if no env var is set
1 parent 1b388bb commit aef2ff9

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

frontend/src/routes.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,25 @@ const { runconvert } = require('./convert/convert')
99
const { wer } = require('./utils')
1010
const 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'
1415
const cacheKeyStt = (data, language, ext) => sanitize(`${crypto.createHash('md5').update(data).digest('hex')}_${language}${ext}`)
1516
const 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+
1726
if (cachePathStt) mkdirp.sync(cachePathStt)
1827
if (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

2433
const ttsEngines = {

0 commit comments

Comments
 (0)