Skip to content

Commit

Permalink
file size check for zero rather than just exists
Browse files Browse the repository at this point in the history
Signed-off-by: Dave Lee <[email protected]>
  • Loading branch information
dave-gray101 committed Oct 22, 2024
1 parent 3854e02 commit 35760e7
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions gopiper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,27 @@ using namespace std;
int _piper_tts(char *text, char *model, char *espeakData, char *tashkeelPath, char *dst, optional<piper::SpeakerId> speakerId) {
filesystem::path model_path;
filesystem::path config_path;
error_code ec;
uintmax_t fsize;

model_path = filesystem::path(std::string(model));
config_path = filesystem::path(std::string(model) + ".json");

if (!filesystem::exists(model_path)) {
spdlog::debug("Error: Model path does not exist: ({})", model_path.c_str());
fsize = filesystem::file_size(model_path, &ec);
if (ec) {
spdlog::debug("Error while checking Model Path ({}) :: ({})", model_path.c_str(), ec.message());
return EXIT_FAILURE;
} else if (fsize == 0) {
spdlog::debug("Error while checking Model Path ({}) :: zero size", model_path.c_str());
return EXIT_FAILURE;
}

if (!filesystem::exists(config_path)) {
spdlog::debug("Error: Config path does not exist: ({})", config_path.c_str());
fsize = filesystem::file_size(config_path, &ec);
if (ec) {
spdlog::debug("Error while checking Model Path ({}) :: ({})", config_path.c_str(), ec.message());
return EXIT_FAILURE;
} else if (fsize == 0) {
spdlog::debug("Error while checking Model Path ({}) :: zero size", config_path.c_str());
return EXIT_FAILURE;
}

Expand Down

0 comments on commit 35760e7

Please sign in to comment.