How to use the asrtoolkit.file_utils.script_input_validation.assign_if_valid function in asrtoolkit

To help you get started, we’ve selected a few asrtoolkit 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 finos / greenkey-asrtoolkit / asrtoolkit / convert_transcript.py View on Github external
def convert(input_file, output_file):
    """
    Convert between text file formats (supported formats are stm, json, srt, vtt, txt, and html)
    """
    check_input_file_validity(input_file)
    input_file = assign_if_valid(input_file)
    input_file.write(output_file)
github finos / greenkey-asrtoolkit / asrtoolkit / wer.py View on Github external
def compute_wer(reference_file,
                transcript_file,
                char_level=False,
                ignore_nsns=False):
    """
    Compares a reference and transcript file and calculates word error rate (WER) between these two files
    If --char-level is given, compute CER instead
    If --ignore-nsns is given, ignore non silence noises
    """

    # read files from arguments
    ref = assign_if_valid(reference_file)
    hyp = assign_if_valid(transcript_file)

    if ref is None or hyp is None:
        print(
            "Error with an input file. Please check all files exist and are accepted by ASRToolkit"
        )
    elif char_level:
        print("CER: {:5.3f}%".format(cer(ref, hyp, ignore_nsns)))
    else:
        print("WER: {:5.3f}%".format(wer(ref, hyp, ignore_nsns)))
github finos / greenkey-asrtoolkit / asrtoolkit / wer.py View on Github external
def compute_wer(reference_file,
                transcript_file,
                char_level=False,
                ignore_nsns=False):
    """
    Compares a reference and transcript file and calculates word error rate (WER) between these two files
    If --char-level is given, compute CER instead
    If --ignore-nsns is given, ignore non silence noises
    """

    # read files from arguments
    ref = assign_if_valid(reference_file)
    hyp = assign_if_valid(transcript_file)

    if ref is None or hyp is None:
        print(
            "Error with an input file. Please check all files exist and are accepted by ASRToolkit"
        )
    elif char_level:
        print("CER: {:5.3f}%".format(cer(ref, hyp, ignore_nsns)))
    else:
        print("WER: {:5.3f}%".format(wer(ref, hyp, ignore_nsns)))