How to use the stt.chromium.recognize_segments function in stt

To help you get started, we’ve selected a few stt examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github cnbeining / autotimecode / autotimecode_worker / task.py View on Github external
## Conduct STT
    # 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

stt

A library for doing speech recognition using a Coqui STT model

MPL-2.0
Latest version published 2 years ago

Package Health Score

63 / 100
Full package analysis