From 5e2323ab235c5ea02846be1c550f11bea32cc223 Mon Sep 17 00:00:00 2001 From: Hongbo Wu Date: Wed, 28 Aug 2024 09:46:50 +0800 Subject: [PATCH] remove tts cache --- packages/text-to-speech/src/index.ts | 32 ++-------------------------- 1 file changed, 2 insertions(+), 30 deletions(-) diff --git a/packages/text-to-speech/src/index.ts b/packages/text-to-speech/src/index.ts index a933a940e..9101ff8c1 100644 --- a/packages/text-to-speech/src/index.ts +++ b/packages/text-to-speech/src/index.ts @@ -38,11 +38,6 @@ interface HTMLInput { bucket: string } -interface CacheResult { - audioDataString: string - speechMarks: SpeechMark[] -} - interface Claim { uid: string featureName: string | null @@ -283,20 +278,6 @@ export const textToSpeechStreamingHandler = Sentry.GCPFunction.wrapHttpFunction( const ssml = `${startSsml(ssmlOptions)}${utteranceInput.text}${endSsml()}` // hash ssml to get the cache key const cacheKey = crypto.createHash('md5').update(ssml).digest('hex') - // find audio data in cache - const cacheResult = await redisDataSource.cacheClient.get(cacheKey) - if (cacheResult) { - console.log('Cache hit') - const { audioDataString, speechMarks }: CacheResult = - JSON.parse(cacheResult) - res.send({ - idx: utteranceInput.idx, - audioData: audioDataString, - speechMarks, - }) - return - } - console.log('Cache miss') const bucket = process.env.GCS_UPLOAD_BUCKET if (!bucket) { @@ -350,17 +331,6 @@ export const textToSpeechStreamingHandler = Sentry.GCPFunction.wrapHttpFunction( } } - const audioDataString = audioData.toString('hex') - // save audio data to cache for 72 hours for mainly the newsletters - await redisDataSource.cacheClient.set( - cacheKey, - JSON.stringify({ audioDataString, speechMarks }), - 'EX', - 3600 * 72, - 'NX' - ) - console.log('Cache saved') - // update character count await updateCharacterCountInRedis( redisDataSource, @@ -368,6 +338,8 @@ export const textToSpeechStreamingHandler = Sentry.GCPFunction.wrapHttpFunction( characterCount ) + const audioDataString = audioData.toString('hex') + res.send({ idx: utteranceInput.idx, audioData: audioDataString,