Skip to content

Commit

Permalink
Keep multiple threads from calling into espeak-ng at the same time (#489
Browse files Browse the repository at this point in the history
)
  • Loading branch information
csukuangfj authored Dec 15, 2023
1 parent ad72e7a commit 03ff9db
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion sherpa-onnx/csrc/piper-phonemize-lexicon.cc
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,14 @@ std::vector<std::vector<int64_t>> PiperPhonemizeLexicon::ConvertTextToTokenIds(
config.voice = voice; // e.g., voice is en-us

std::vector<std::vector<piper::Phoneme>> phonemes;
piper::phonemize_eSpeak(text, config, phonemes);

static std::mutex espeak_mutex;
{
std::lock_guard<std::mutex> lock(espeak_mutex);

// keep multi threads from calling into piper::phonemize_eSpeak
piper::phonemize_eSpeak(text, config, phonemes);
}

std::vector<std::vector<int64_t>> ans;

Expand Down

0 comments on commit 03ff9db

Please sign in to comment.