Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

when run onnx vad example, it showed the error #59

Closed
snakers4 opened this issue Apr 15, 2021 · 3 comments
Closed

when run onnx vad example, it showed the error #59

snakers4 opened this issue Apr 15, 2021 · 3 comments
Labels
bug Something isn't working

Comments

@snakers4
Copy link
Owner

when run onnx vad example, it showed the error

import torch
import onnxruntime
from pprint import pprint

_, utils = torch.hub.load(repo_or_dir='snakers4/silero-vad',
                              model='silero_vad',
                              force_reload=True)

(get_speech_ts,
 _,_,
 read_audio,
 _, _, _) = utils

files_dir = torch.hub.get_dir() + '/snakers4_silero-vad_master/files'

def init_onnx_model(model_path: str):
    return onnxruntime.InferenceSession(model_path)

def validate_onnx(model, inputs):
    with torch.no_grad():
        ort_inputs = {'input': inputs.cpu().numpy()}
        outs = model.run(None, ort_inputs)
        outs = [torch.Tensor(x) for x in outs]
    return outs

model = init_onnx_model(f'{files_dir}/model.onnx')
wav = read_audio(f'{files_dir}/en.wav')

# get speech timestamps from full audio file
speech_timestamps = get_speech_ts(wav, model, num_steps=4, run_function=validate_onnx)
pprint(speech_timestamps)

Traceback (most recent call last):
File "1.py", line 30, in
speech_timestamps = get_speech_ts(wav, model, num_steps=4, run_function=validate_onnx)
File "/home/gary/.cache/torch/hub/snakers4_silero-vad_master/utils_vad.py", line 112, in get_speech_ts
outs = torch.cat(outs, dim=0)
TypeError: expected Tensor as element 0 in argument 0, but got list

Originally posted by @garymmi in #58

@snakers4 snakers4 added the bug Something isn't working label Apr 15, 2021
@snakers4
Copy link
Owner Author

@adamnsandle

another but after mini models release

@snakers4
Copy link
Owner Author

@garymmi

Please check that this solves your problem
#60

@snakers4
Copy link
Owner Author

I suppose this issue should be fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant