Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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)
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)))
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)))