\runtime\onnxruntime\bin\funasr-onnx-offline.cpp
modelscope-funasr用这个c++代码推理,出现这个报错,而且没有result结果,这个是什么原因?
补充细节:
1.请列出你的环境?(linux)
首先,确保您的环境已经正确安装了ModelScope和ONNXRuntime。您可以在官方文档中找到安装说明:https://modelscope.cn/docs/installation
检查您的代码是否正确调用了funasr-onnx-offline
工具。您可以参考以下示例代码:
#include <iostream>
#include <string>
#include "funasr-onnx-offline.h"
int main(int argc, char* argv[]) {
if (argc != 3) {
std::cerr << "Usage: " << argv[0] << " <input_audio_file> <output_result_file>" << std::endl;
return 1;
}
std::string input_audio_file = argv[1];
std::string output_result_file = argv[2];
funasr_onnx_offline::FunasrOnnxOffline funasr_onnx_offline(input_audio_file, output_result_file);
funasr_onnx_offline.run();
return 0;
}
确保您的输入音频文件路径和输出结果文件路径是正确的。如果路径不正确,程序将无法找到文件并报错。
检查ONNX模型是否与您的Python代码兼容。您可以参考ModelScope的文档了解如何将PyTorch模型转换为ONNX模型:https://modelscope.cn/docs/model_zoo/onnx_converter
如果以上步骤都无法解决问题,您可以尝试在ModelScope的GitHub仓库中提交一个issue,详细描述您的问题和错误信息。这将有助于开发者更好地了解问题并提供解决方案。
根据您提供的信息,我无法直接查看您的代码和错误信息。但是,我可以给您一些建议来排查问题。
首先,确保您已经正确安装了ONNX Runtime库。您可以按照官方文档进行安装:https://github.com/microsoft/onnxruntime
检查您的C++代码是否正确加载了ONNX模型。您可以使用以下代码片段来加载模型:
#include <onnxruntime_cxx_api.h>
Ort::Env env(ORT_LOGGING_LEVEL_WARNING, "test");
Ort::SessionOptions session_options;
session_options.SetIntraOpNumThreads(1);
std::shared_ptr<Ort::Session> session = env.CreateSession("path/to/your/model.onnx", session_options);
Ort::MemoryInfo memory_info = Ort::MemoryInfo::CreateCpu(OrtArenaAllocator, OrtMemTypeDefault);
std::vector<int64_t> input_shape = {1, 16000}; // 根据实际模型调整
std::unique_ptr<Ort::Value> input_tensor = Ort::Value::CreateTensor<float>(memory_info, input_shape.data(), input_shape.size());
// 假设您已经创建了一个名为input_tensor的Ort::Value对象
session->Run(Ort::RunOptions{nullptr}, &input_name, &input_tensor, 1, &output_name, &output_tensor);
量化后的模型报错了,所以没结果,可以直接用我们量化后的onnx模型:speech_paraformer-large_asr_nat-zh-cn-16k-common-vocab8404-onnx。此回答整理自钉群“modelscope-funasr社区交流”
ModelScope旨在打造下一代开源的模型即服务共享平台,为泛AI开发者提供灵活、易用、低成本的一站式模型服务产品,让模型应用更简单!欢迎加入技术交流群:微信公众号:魔搭ModelScope社区,钉钉群号:44837352