Mashiro

Results 10 comments of Mashiro

> 请问runtime时怎么加载onnx进行推理 是指runtime C++加载onnx进行推理吧?这个没有尝试,后续可能会尝试。 建议参考wenet-online-decoder-onnx仓库的python推理代码的逻辑,改写官方Wenet仓库的runtime C++代码。

> /example/onnx运行run_onnx.sh时: File "", line 1, in File "/path_to_my_pkg/lib/python3.8/site-packages/onnx/**init**.py", line 10, in from .onnx_cpp2py_export import ONNX_ML ModuleNotFoundError: No module named 'onnx.onnx_cpp2py_export' 看起来是onnx的版本不一致

因为在wenet/transformer/encoder.py中 1. forward_chunk_onnx函数中required_cache_size被 if else条件语句 设计了三个分支,分支计算在onnx中并不支持。 2. 并且在required_cache_size>0时,使用了max function来计算next_cache_start,这在onnx中也不支持。所有onnx模型实际上不保留required_cache_size equals 0 和 greater than 0 的情况,暴力执行next_cache_start = 1。 因此对于ONNX模型来说,required_cache_size被其默认为-1,不需要再被传入。 我暂时没有找到比较好解决上述两个问题的方法,可以后续继续讨论。(* ̄︶ ̄) ``` if required_cache_size < 0: # next_cache_start = 0 next_cache_start...

``` # 参考wenet_online_decoder_onnx.py文件,配置好相关模型后 # 你可以这样直接使用 weNetDecoder.offline_decode('./your_long_audio.wav',useVad=True) weNetDecoder.resetAll() # 也可以流式打开你的文件(如果音频真的很长,推荐使用这个) with open('./your_long_audio.wav','rb') as audiostream: audiostream.read(44) for dataflow in tqdm(iter(lambda:audiostream.read(32000 * 20),"")): # 每次读取20s的音频 if len(dataflow) == 0: break weNetDecoder.offline_decode(dataflow,isbytes=True,useVad=True) time.sleep(0.1) weNetDecoder.resetAll()...

我没有使用过cpp跑onnx模型,不过根据 FillVectorsFromInput Starts must be a 1-D array,应该是传入的参数格式不对。我猜测是不是offset用的不是数组?( 虽然这很奇怪,但是在python代码中我传入的offset为np.array(1,dtype=int64),我不确定这时的offset类型是什么 ),可以对照着python代码细节看一下。或者是可以再检查一个各个传入的参数,在python代码中均有详细注释。

应该是注释里有\n,之前可能是适配的,现在应改为\\n https://stackoverflow.com/questions/40918168/docstring-has-inconsistent-leading-whitespace

好,稍等我导出一份wenet开源的模型放在仓库里

已更新代码,但因无法上传100MB以上的文件到github上,请去对应链接下载,或留下邮箱。

> 能否给我发一份 encoder_chunk.onnx,decoder.onnx,ctc.onnnx [[email protected]](mailto:[email protected]),谢谢了~ 不知现在是否仍需要?:joy: