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_rtf.py | 28 ++++++++++++++--------------
1 files changed, 14 insertions(+), 14 deletions(-)
diff --git a/runtime/python/utils/test_rtf.py b/runtime/python/utils/test_rtf.py
index 391a0ac..3fe96a3 100644
--- a/runtime/python/utils/test_rtf.py
+++ b/runtime/python/utils/test_rtf.py
@@ -16,8 +16,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')
@@ -28,28 +28,28 @@
num = 30
wav_path = wav_files[0].split("\t")[1].strip() if "\t" in wav_files[0] else wav_files[0].split(" ")[1].strip()
for i in range(num):
- beg_time = time.time()
- result = model(wav_path)
- end_time = time.time()
- duration = end_time-beg_time
- total += duration
- print(result)
- print("num: {}, time, {}, avg: {}, rtf: {}".format(len(wav_path), duration, total/(i+1), (total/(i+1))/5.53))
+ beg_time = time.time()
+ result = model(wav_path)
+ end_time = time.time()
+ duration = end_time-beg_time
+ total += duration
+ print(result)
+ print("num: {}, time, {}, avg: {}, rtf: {}".format(len(wav_path), duration, total/(i+1), (total/(i+1))/5.53))
# infer time
beg_time = time.time()
for i, wav_path_i in enumerate(wav_files):
- wav_path = wav_path_i.split("\t")[1].strip() if "\t" in wav_path_i else wav_path_i.split(" ")[1].strip()
- result = model(wav_path)
+ wav_path = wav_path_i.split("\t")[1].strip() if "\t" in wav_path_i else wav_path_i.split(" ")[1].strip()
+ result = model(wav_path)
end_time = time.time()
duration = (end_time-beg_time)*1000
print("total_time_comput_ms: {}".format(int(duration)))
duration_time = 0.0
for i, wav_path_i in enumerate(wav_files):
- wav_path = wav_path_i.split("\t")[1].strip() if "\t" in wav_path_i else wav_path_i.split(" ")[1].strip()
- waveform, _ = librosa.load(wav_path, sr=16000)
- duration_time += len(waveform)/16.0
+ wav_path = wav_path_i.split("\t")[1].strip() if "\t" in wav_path_i else wav_path_i.split(" ")[1].strip()
+ waveform, _ = librosa.load(wav_path, sr=16000)
+ duration_time += len(waveform)/16.0
print("total_time_wav_ms: {}".format(int(duration_time)))
print("total_rtf: {:.5}".format(duration/duration_time))
\ No newline at end of file
--
Gitblit v1.9.1