RapidAI/RapidASR

ValueError: negative dimensions are not allowed

Closed this issue · 3 comments

run test_demo.py error in feature.py:
def sliding_window(x, window_size, window_shift):
shape = x.shape[:-1] + (x.shape[-1] - window_size + 1, window_size)
strides = x.strides + (x.strides[-1],)
return np.lib.stride_tricks.as_strided(x, shape=shape, strides=strides)[::window_shift]
if x.shape[-1] - window_size + 1 < 0:
ValueError: negative dimensions are not allowed
what is the mean x.shape[-1] - window_size + 1 ?

SWHL commented

It would be better if you could provide the code to reproduce the problem.

-- encoding: utf-8 --

@author: SWHL

@Contact: liekkaskono@163.com

from wenet import WenetInfer

config_path = "pretrain_model/20211025_conformer_exp/test.yaml"
dict_path = "pretrain_model/20211025_conformer_exp/words.txt"
encoder_onnx_path = "RapidASR/encoder.onnx"
decoder_onnx_path = "RapidASR/decoder.onnx"
mode = 'attention_rescoring'

wenet_infer = WenetInfer(config_path,
dict_path, -1,
encoder_onnx_path,
decoder_onnx_path,
mode)

wav_path = r'/home/user/Program/wav2lip_few_data/val/id2_000191.wav'
key, content, elapse = wenet_infer(wav_path)
print(f'{key}\t{content}\t{elapse}s')

File "/home/caopu/workspace/RapidASR/python/base_wenet/test_demo.py", line 19, in
key, content, elapse = wenet_infer(wav_path)
File "/home/caopu/workspace/RapidASR/python/base_wenet/wenet/wenet_infer.py", line 108, in call
data = self.preprocess_data(wav_path)
File "/home/caopu/workspace/RapidASR/python/base_wenet/wenet/wenet_infer.py", line 101, in preprocess_data
data = compute_fbank(data, **fbank_conf)
File "/home/caopu/workspace/RapidASR/python/base_wenet/wenet/utils.py", line 153, in compute_fbank
mat = compute_fbank_feats(waveform,
File "/home/caopu/workspace/RapidASR/python/base_wenet/wenet/kaldifeat/feature.py", line 316, in compute_fbank_feats
frames, log_energy = extract_window(
File "/home/caopu/workspace/RapidASR/python/base_wenet/wenet/kaldifeat/feature.py", line 117, in extract_window
frames = sliding_window(waveform, window_size=window_size, window_shift=window_shift)
File "/home/caopu/workspace/RapidASR/python/base_wenet/wenet/kaldifeat/feature.py", line 10, in sliding_window
return np.lib.stride_tricks.as_strided(x, shape=shape, strides=strides)[::window_shift]
File "/home/caopu/miniconda3/envs/audio2head/lib/python3.8/site-packages/numpy/lib/stride_tricks.py", line 104, in as_strided
array = np.asarray(DummyArray(interface, base=x))
File "/home/caopu/miniconda3/envs/audio2head/lib/python3.8/site-packages/numpy/core/_asarray.py", line 102, in asarray
return array(a, dtype, copy=False, order=order)
ValueError: negative dimensions are not allowed
I found the error in the function sliding_window , if x.shape[-1] - window_size + 1 < 0 It will report an error, why is this, thank you 。

SWHL commented
  • I'm sorry to reply you so late.
  • Can you provide the raw wav(/home/user/Program/wav2lip_few_data/val/id2_000191.wav) for me to reproduce the error?
  • At the same time, can the demo given in the repository be reproduced?