LAP-DEV commited on
Commit
4aa7629
·
verified ·
1 Parent(s): e6a277b

Update modules/whisper/whisper_base.py

Browse files
Files changed (1) hide show
  1. modules/whisper/whisper_base.py +13 -13
modules/whisper/whisper_base.py CHANGED
@@ -266,27 +266,27 @@ class WhisperBase(ABC):
266
  # Translate to English using Whisper built-in functionality
267
  transcription_note = ""
268
  if params.is_translate:
269
- transcription_note = "To English (using Whisper)"
270
  source_lang = "English"
271
 
272
  # Translate the transcribed segments
273
  translation_note = ""
274
  if translate_output:
275
- self.nllb_inf = NLLBInference()
276
- if source_lang in NLLB_AVAILABLE_LANGS.keys():
277
- transcribed_segments = self.nllb_inf.translate_text(
278
- input_list_dict=transcribed_segments,
279
- model_size=translate_model,
280
- src_lang=source_lang,
281
- tgt_lang=target_lang,
282
- speaker_diarization=params.is_diarize
283
- )
284
- if source_lang != target_lang:
285
  translation_note = source_lang + " to " + target_lang + " (using Facebook NLLB)"
286
  else:
287
- translation_note = "None (Already in " + target_lang + ")"
288
  else:
289
- translation_note = source_lang + " not supported"
290
 
291
  ## Get preview as txt
292
  file_name, file_ext = os.path.splitext(os.path.basename(file))
 
266
  # Translate to English using Whisper built-in functionality
267
  transcription_note = ""
268
  if params.is_translate:
269
+ transcription_note = "To English\n\t\t\t(using Whisper)"
270
  source_lang = "English"
271
 
272
  # Translate the transcribed segments
273
  translation_note = ""
274
  if translate_output:
275
+ if source_lang != target_lang:
276
+ self.nllb_inf = NLLBInference()
277
+ if source_lang in NLLB_AVAILABLE_LANGS.keys():
278
+ transcribed_segments = self.nllb_inf.translate_text(
279
+ input_list_dict=transcribed_segments,
280
+ model_size=translate_model,
281
+ src_lang=source_lang,
282
+ tgt_lang=target_lang,
283
+ speaker_diarization=params.is_diarize
284
+ )
285
  translation_note = source_lang + " to " + target_lang + " (using Facebook NLLB)"
286
  else:
287
+ translation_note = source_lang + " not supported (using Facebook NLLB)"
288
  else:
289
+ translation_note = "None (Already in " + target_lang + ")"
290
 
291
  ## Get preview as txt
292
  file_name, file_ext = os.path.splitext(os.path.basename(file))