vunhucuongit commited on
Commit
f3572ce
1 Parent(s): 8be2acf

Update soni_translate/speech_segmentation.py

Browse files
soni_translate/speech_segmentation.py CHANGED
@@ -9,7 +9,6 @@ import gc
9
  import os
10
  import soundfile as sf
11
  from IPython.utils import capture # noqa
12
- from .language_configuration import EXTRA_ALIGN, INVERTED_LANGUAGES
13
  from .logging_setup import logger
14
  from .postprocessor import sanitize_file_name
15
  from .utils import remove_directory_contents, run_command
@@ -59,8 +58,6 @@ def load_align_and_align_segments(result, audio, DAMHF):
59
  language_code=result["language"],
60
  device=os.environ.get("SONITR_DEVICE") if os.environ.get("ZERO_GPU") != "TRUE" else "cuda",
61
  model_name=None
62
- if result["language"] in DAMHF.keys()
63
- else EXTRA_ALIGN[result["language"]],
64
  )
65
 
66
  # Align segments
@@ -343,31 +340,6 @@ def align_speech(audio, result):
343
  - Cleans up memory by releasing resources after alignment.
344
  """
345
  DAMHF.update(DAMT) # lang align
346
- if (
347
- not result["language"] in DAMHF.keys()
348
- and not result["language"] in EXTRA_ALIGN.keys()
349
- ):
350
- logger.warning(
351
- "Automatic detection: Source language not compatible with align"
352
- )
353
- raise ValueError(
354
- f"Detected language {result['language']} incompatible, "
355
- "you can select the source language to avoid this error."
356
- )
357
- if (
358
- result["language"] in EXTRA_ALIGN.keys()
359
- and EXTRA_ALIGN[result["language"]] == ""
360
- ):
361
- lang_name = (
362
- INVERTED_LANGUAGES[result["language"]]
363
- if result["language"] in INVERTED_LANGUAGES.keys()
364
- else result["language"]
365
- )
366
- logger.warning(
367
- "No compatible wav2vec2 model found "
368
- f"for the language '{lang_name}', skipping alignment."
369
- )
370
- return result
371
 
372
  # random_sleep()
373
  result = load_align_and_align_segments(result, audio, DAMHF)
 
9
  import os
10
  import soundfile as sf
11
  from IPython.utils import capture # noqa
 
12
  from .logging_setup import logger
13
  from .postprocessor import sanitize_file_name
14
  from .utils import remove_directory_contents, run_command
 
58
  language_code=result["language"],
59
  device=os.environ.get("SONITR_DEVICE") if os.environ.get("ZERO_GPU") != "TRUE" else "cuda",
60
  model_name=None
 
 
61
  )
62
 
63
  # Align segments
 
340
  - Cleans up memory by releasing resources after alignment.
341
  """
342
  DAMHF.update(DAMT) # lang align
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
343
 
344
  # random_sleep()
345
  result = load_align_and_align_segments(result, audio, DAMHF)