Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
# convert SRT to list of Subtitle
subtitle = list(parse(request_srt_content))
# segment audio into smaller chunks
flac_path_list = generate_audio_segments(media_file_path, subtitle, elastic = 0.5)
stt_task.add_step(TaskStep(comment = 'File segmented'))
lang = 'en'
if stt_task.lang:
lang = stt_task.lang
# Call API
logging.warning(flac_path_list)
result_recognize = recognize_segments(flac_path_list, lang_code = lang)
logging.warning(result_recognize)
new_subtitle = merge_result(subtitle, result_recognize)
stt_task.add_step(TaskStep(comment = 'STT conducted'))
# Clean up and put back punctuations
if lang == 'en' and stt_task.correct:
new_subtitle = segment_subtitle(new_subtitle)
stt_task.add_step(TaskStep(comment = 'DeepCorrect conducted'))
stt_task.result_srt_content = compose(new_subtitle)
stt_task.save()
shutil.rmtree(tmp_dir, ignore_errors = True)
return True