Skip to content

Commit

Permalink
only output translation keys if translation was done and fix detected…
Browse files Browse the repository at this point in the history
… language
  • Loading branch information
marjisound committed Oct 8, 2024
1 parent 0a76d54 commit 41ce18c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
13 changes: 7 additions & 6 deletions packages/worker/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -315,11 +315,12 @@ const pollTranscriptionQueue = async (
userEmail: job.userEmail,
originalFilename: job.originalFilename,
outputBucketKeys,
translationOutputBucketKeys: job.translationOutputBucketUrls && {
srt: job.translationOutputBucketUrls.srt.key,
json: job.translationOutputBucketUrls.json.key,
text: job.translationOutputBucketUrls.text.key,
},
translationOutputBucketKeys: job.translationOutputBucketUrls &&
transcriptResult.transcriptTranslations && {
srt: job.translationOutputBucketUrls.srt.key,
json: job.translationOutputBucketUrls.json.key,
text: job.translationOutputBucketUrls.text.key,
},
isTranslation: job.translate,
};

Expand All @@ -330,7 +331,7 @@ const pollTranscriptionQueue = async (
);

logger.info(
'Worker successfully transcribed the file and sent notification to sns',
`Worker successfully transcribed the file and sent notification to ${job.transcriptDestinationService} output queue`,
{
id: transcriptionOutput.id,
filename: transcriptionOutput.originalFilename,
Expand Down
4 changes: 3 additions & 1 deletion packages/worker/src/transcribe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,12 +222,14 @@ const transcribeAndTranslate = async (
const dlParams = whisperParams(true, whisperBaseParams.wavPath);
const { metadata } = await runWhisper(whisperBaseParams, dlParams);
const languageCode =
languageCodes.find((c) => c === metadata.detectedLanguageCode) || 'en';
languageCodes.find((c) => c === metadata.detectedLanguageCode) || 'auto';
const transcription = await runTranscription(
whisperBaseParams,
languageCode,
false,
);

transcription.metadata.detectedLanguageCode = metadata.detectedLanguageCode;
const translation =
languageCode === 'en'
? null
Expand Down

0 comments on commit 41ce18c

Please sign in to comment.