Skip to content

Commit

Permalink
Merge pull request #9 from dave-gray101/check-zero-size
Browse files Browse the repository at this point in the history
fix: file size check for zero rather than just exists
  • Loading branch information
mudler authored Oct 23, 2024
2 parents 3854e02 + 35760e7 commit 2494246
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 2494246

Please sign in to comment.