diff --git a/server/api/pronounce/[voice]/[pronunciation].get.ts b/server/api/pronounce/[voice]/[pronunciation].get.ts index b7a81d22f..d857408c5 100644 --- a/server/api/pronounce/[voice]/[pronunciation].get.ts +++ b/server/api/pronounce/[voice]/[pronunciation].get.ts @@ -3,16 +3,16 @@ import { NoSuchKey } from '@aws-sdk/client-s3'; import type { S3 } from '@aws-sdk/client-s3'; import type { NodeJsClient } from '@smithy/types'; import { Base64 } from 'js-base64'; -import sha1 from 'sha1'; import { convertPronunciationStringToSsml, convertPronunciationStringToNarakeetFormat, + sha256, } from '#shared/helpers.ts'; import { voices } from '#shared/pronunciation/voices.ts'; import type { VoiceKey, AwsPollyVoice, NarakeetVoice, Voice } from '#shared/pronunciation/voices.ts'; import { s3, awsConfig, s3BucketParams } from '~~/server/cloudServices.ts'; -import { getLocale, loadConfig, localesDict } from '~~/server/data.ts'; +import { localesDict } from '~~/server/data.ts'; type ProviderKey = 'aws_polly' | 'narakeet'; interface Provider { @@ -82,9 +82,6 @@ export default defineEventHandler(async (event) => { }); } - const locale = getLocale(event); - const config = await loadConfig(locale); - const voiceKey = getRouterParam(event, 'voice'); if (voiceKey === undefined || !(voiceKey in voices)) { throw createError({ @@ -96,7 +93,7 @@ export default defineEventHandler(async (event) => { const voice = voices[voiceKey as VoiceKey]; const provider = providers[(voice.provider || 'aws_polly') as ProviderKey]; const tokenised = provider.tokenised(text); - const key = `pronunciation/${config.locale}-${voiceKey}/${sha1(tokenised)}.mp3`; + const key = `pronunciation/${voiceKey}/${await sha256(tokenised)}.mp3`; try { const s3Response = await (s3 as NodeJsClient).getObject({ Key: key, ...s3BucketParams });