diff --git a/CMakeLists.txt b/CMakeLists.txt index 31989e15..34b259f2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -37,9 +37,8 @@ endif() set(CMAKE_INSTALL_RPATH ${SHERPA_ONNX_RPATH_ORIGIN}) set(CMAKE_BUILD_RPATH ${SHERPA_ONNX_RPATH_ORIGIN}) -if(WIN32 AND BUILD_SHARED_LIBS) - message(STATUS "Set BUILD_SHARED_LIBS to OFF for windows") - set(BUILD_SHARED_LIBS OFF) +if(BUILD_SHARED_LIBS AND MSVC) + set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) endif() if(NOT CMAKE_BUILD_TYPE) diff --git a/cmake/onnxruntime.cmake b/cmake/onnxruntime.cmake index 056f16d9..104ca8af 100644 --- a/cmake/onnxruntime.cmake +++ b/cmake/onnxruntime.cmake @@ -54,15 +54,32 @@ function(download_onnxruntime) elseif(WIN32) # If you don't have access to the Internet, # please pre-download onnxruntime - set(possible_file_locations - $ENV{HOME}/Downloads/onnxruntime-win-x64-1.14.0.zip - ${PROJECT_SOURCE_DIR}/onnxruntime-win-x64-1.14.0.zip - ${PROJECT_BINARY_DIR}/onnxruntime-win-x64-1.14.0.zip - /tmp/onnxruntime-win-x64-1.14.0.zip - ) - set(onnxruntime_URL "https://github.com/microsoft/onnxruntime/releases/download/v1.14.0/onnxruntime-win-x64-1.14.0.zip") - set(onnxruntime_URL2 "https://huggingface.co/csukuangfj/sherpa-onnx-cmake-deps/resolve/main/onnxruntime-win-x64-1.14.0.zip") - set(onnxruntime_HASH "SHA256=300eafef456748cde2743ee08845bd40ff1bab723697ff934eba6d4ce3519620") + + if(CMAKE_VS_PLATFORM_NAME STREQUAL Win32) + # for 32-bit windows + set(possible_file_locations + $ENV{HOME}/Downloads/onnxruntime-win-x86-1.14.0.zip + ${PROJECT_SOURCE_DIR}/onnxruntime-win-x86-1.14.0.zip + ${PROJECT_BINARY_DIR}/onnxruntime-win-x86-1.14.0.zip + /tmp/onnxruntime-win-x86-1.14.0.zip + ) + + set(onnxruntime_URL "https://github.com/microsoft/onnxruntime/releases/download/v1.14.0/onnxruntime-win-x86-1.14.0.zip") + set(onnxruntime_URL2 "https://huggingface.co/csukuangfj/sherpa-onnx-cmake-deps/resolve/main/onnxruntime-win-x86-1.14.0.zip") + set(onnxruntime_HASH "SHA256=4214b130db602cbf31a6f26f25377ab077af0cf03c4ddd4651283e1fb68f56cf") + else() + # for 64-bit windows + set(possible_file_locations + $ENV{HOME}/Downloads/onnxruntime-win-x64-1.14.0.zip + ${PROJECT_SOURCE_DIR}/onnxruntime-win-x64-1.14.0.zip + ${PROJECT_BINARY_DIR}/onnxruntime-win-x64-1.14.0.zip + /tmp/onnxruntime-win-x64-1.14.0.zip + ) + + set(onnxruntime_URL "https://github.com/microsoft/onnxruntime/releases/download/v1.14.0/onnxruntime-win-x64-1.14.0.zip") + set(onnxruntime_URL2 "https://huggingface.co/csukuangfj/sherpa-onnx-cmake-deps/resolve/main/onnxruntime-win-x64-1.14.0.zip") + set(onnxruntime_HASH "SHA256=300eafef456748cde2743ee08845bd40ff1bab723697ff934eba6d4ce3519620") + endif() # After downloading, it contains: # ./lib/onnxruntime.{dll,lib,pdb} # ./lib/onnxruntime_providers_shared.{dll,lib,pdb} diff --git a/sherpa-onnx/csrc/online-transducer-model.cc b/sherpa-onnx/csrc/online-transducer-model.cc index 3a40e9c6..960d277f 100644 --- a/sherpa-onnx/csrc/online-transducer-model.cc +++ b/sherpa-onnx/csrc/online-transducer-model.cc @@ -60,9 +60,13 @@ static ModelType GetModelType(char *model_data, size_t model_data_length, std::unique_ptr OnlineTransducerModel::Create( const OnlineTransducerModelConfig &config) { - auto buffer = ReadFile(config.encoder_filename); + ModelType model_type = ModelType::kUnkown; - auto model_type = GetModelType(buffer.data(), buffer.size(), config.debug); + { + auto buffer = ReadFile(config.encoder_filename); + + model_type = GetModelType(buffer.data(), buffer.size(), config.debug); + } switch (model_type) { case ModelType::kLstm: