From 1233c0d3ff9cf7fd6131862e7d0b208d3981f6da Mon Sep 17 00:00:00 2001
From: shixian.shi <shixian.shi@alibaba-inc.com>
Date: 星期一, 15 一月 2024 20:34:47 +0800
Subject: [PATCH] code update
---
runtime/python/utils/test_cer.py | 28 ++++++++++++++--------------
1 files changed, 14 insertions(+), 14 deletions(-)
diff --git a/runtime/python/utils/test_cer.py b/runtime/python/utils/test_cer.py
index e27e393..d795d33 100644
--- a/runtime/python/utils/test_cer.py
+++ b/runtime/python/utils/test_cer.py
@@ -17,8 +17,8 @@
from funasr.runtime.python.libtorch.funasr_torch import Paraformer
if args.backend == "onnx":
- from funasr.runtime.python.onnxruntime.funasr_onnx import Paraformer
-
+ from funasr.runtime.python.onnxruntime.funasr_onnx import Paraformer
+
model = Paraformer(args.model_dir, batch_size=1, quantize=args.quantize, intra_op_num_threads=args.intra_op_num_threads)
wav_file_f = open(args.wav_file, 'r')
@@ -26,23 +26,23 @@
output_dir = args.output_dir
if not os.path.exists(output_dir):
- os.makedirs(output_dir)
+ os.makedirs(output_dir)
if os.name == 'nt': # Windows
- newline = '\r\n'
+ newline = '\r\n'
else: # Linux Mac
- newline = '\n'
+ newline = '\n'
text_f = open(os.path.join(output_dir, "text"), "w", newline=newline)
token_f = open(os.path.join(output_dir, "token"), "w", newline=newline)
for i, wav_path_i in enumerate(wav_files):
- wav_name, wav_path = wav_path_i.strip().split()
- result = model(wav_path)
- text_i = "{} {}\n".format(wav_name, result[0]['preds'][0])
- token_i = "{} {}\n".format(wav_name, result[0]['preds'][1])
- text_f.write(text_i)
- text_f.flush()
- token_f.write(token_i)
- token_f.flush()
+ wav_name, wav_path = wav_path_i.strip().split()
+ result = model(wav_path)
+ text_i = "{} {}\n".format(wav_name, result[0]['preds'][0])
+ token_i = "{} {}\n".format(wav_name, result[0]['preds'][1])
+ text_f.write(text_i)
+ text_f.flush()
+ token_f.write(token_i)
+ token_f.flush()
text_f.close()
token_f.close()
-
+
--
Gitblit v1.9.1