Skip to content

Commit ad182f4

Browse files
committed
lint
1 parent 030bb81 commit ad182f4

File tree

1 file changed

+21
-19
lines changed

1 file changed

+21
-19
lines changed

src/whisper-processing.cpp

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -77,25 +77,27 @@ struct whisper_context *init_whisper_context(const std::string &model_path)
7777
obs_log(LOG_INFO, "Loading whisper model from %s", model_path.c_str());
7878

7979
#ifdef _WIN32
80-
// convert model path UTF8 to wstring (wchar_t) for whisper
81-
int count = MultiByteToWideChar(CP_UTF8, 0, model_path.c_str(), (int)model_path.length(), NULL, 0);
82-
std::wstring model_path_ws(count, 0);
83-
MultiByteToWideChar(CP_UTF8, 0, model_path.c_str(), (int)model_path.length(), &model_path_ws[0], count);
84-
85-
// Read model into buffer
86-
std::ifstream modelFile(model_path_ws, std::ios::binary);
87-
if (!modelFile.is_open()) {
88-
obs_log(LOG_ERROR, "Failed to open whisper model file %s", model_path.c_str());
89-
return nullptr;
90-
}
91-
modelFile.seekg(0, std::ios::end);
92-
const size_t modelFileSize = modelFile.tellg();
93-
modelFile.seekg(0, std::ios::beg);
94-
std::vector<char> modelBuffer(modelFileSize);
95-
modelFile.read(modelBuffer.data(), modelFileSize);
96-
modelFile.close();
97-
98-
// Initialize whisper
80+
// convert model path UTF8 to wstring (wchar_t) for whisper
81+
int count = MultiByteToWideChar(CP_UTF8, 0, model_path.c_str(), (int)model_path.length(),
82+
NULL, 0);
83+
std::wstring model_path_ws(count, 0);
84+
MultiByteToWideChar(CP_UTF8, 0, model_path.c_str(), (int)model_path.length(),
85+
&model_path_ws[0], count);
86+
87+
// Read model into buffer
88+
std::ifstream modelFile(model_path_ws, std::ios::binary);
89+
if (!modelFile.is_open()) {
90+
obs_log(LOG_ERROR, "Failed to open whisper model file %s", model_path.c_str());
91+
return nullptr;
92+
}
93+
modelFile.seekg(0, std::ios::end);
94+
const size_t modelFileSize = modelFile.tellg();
95+
modelFile.seekg(0, std::ios::beg);
96+
std::vector<char> modelBuffer(modelFileSize);
97+
modelFile.read(modelBuffer.data(), modelFileSize);
98+
modelFile.close();
99+
100+
// Initialize whisper
99101
struct whisper_context *ctx = whisper_init_from_buffer(modelBuffer.data(), modelFileSize);
100102
#else
101103
struct whisper_context *ctx = whisper_init_from_file(model_path.c_str());

0 commit comments

Comments
 (0)