From ec5b1dbd4382c885f44b987e86850d9de9a8926e Mon Sep 17 00:00:00 2001 From: Daniel Souza Date: Mon, 11 Mar 2024 16:11:20 -0300 Subject: [PATCH] fix: handle unicode characters in onnx model path --- lib/src/chunk_processor.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/src/chunk_processor.cpp b/lib/src/chunk_processor.cpp index a3bb4cb..16b3899 100644 --- a/lib/src/chunk_processor.cpp +++ b/lib/src/chunk_processor.cpp @@ -2,6 +2,8 @@ #include #include #include +#include +#include #include #include @@ -23,6 +25,8 @@ ChunkProcessor::ChunkProcessor(std::string modelPath, &queue_), webrtcVad_(options.webrtcVadLevel, options.sampleRate) { queueThread_ = std::thread([&, modelPath] { + setlocale(LC_ALL, "pt_BR.UTF-8"); + ortMutex_.lock(); if (!ortSession_) { ortEnv_ = std::make_unique(ORT_LOGGING_LEVEL_WARNING, @@ -33,10 +37,10 @@ ChunkProcessor::ChunkProcessor(std::string modelPath, Ort::SessionOptions sessionOptions; sessionOptions.SetIntraOpNumThreads(1); #ifdef _WIN32 - std::wstring wstring(modelPath.begin(), modelPath.end()); - ortSession_ = std::make_unique(*ortEnv_, wstring.c_str(), - sessionOptions); - + std::filesystem::path unicodeModelPath(modelPath.begin(), + modelPath.end()); + ortSession_ = std::make_unique( + *ortEnv_, unicodeModelPath.c_str(), sessionOptions); #else ortSession_ = std::make_unique(*ortEnv_, modelPath.c_str(), sessionOptions);