Skip to content

Commit

Permalink
fix: handle unicode characters in onnx model path
Browse files Browse the repository at this point in the history
  • Loading branch information
dsouza95 committed Mar 11, 2024
1 parent 41e5ecd commit ec5b1db
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions lib/src/chunk_processor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
#include <chrono>
#include <climits>
#include <cmath>
#include <filesystem>
#include <locale>
#include <iostream>
#include <memory>

Expand All @@ -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::Env>(ORT_LOGGING_LEVEL_WARNING,
Expand All @@ -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<Ort::Session>(*ortEnv_, wstring.c_str(),
sessionOptions);

std::filesystem::path unicodeModelPath(modelPath.begin(),
modelPath.end());
ortSession_ = std::make_unique<Ort::Session>(
*ortEnv_, unicodeModelPath.c_str(), sessionOptions);
#else
ortSession_ = std::make_unique<Ort::Session>(*ortEnv_, modelPath.c_str(),
sessionOptions);
Expand Down

0 comments on commit ec5b1db

Please sign in to comment.