Committed by
GitHub
Keep multiple threads from calling into espeak-ng at the same time (#489)
正在显示
1 个修改的文件
包含
8 行增加
和
1 行删除
| @@ -223,7 +223,14 @@ std::vector<std::vector<int64_t>> PiperPhonemizeLexicon::ConvertTextToTokenIds( | @@ -223,7 +223,14 @@ std::vector<std::vector<int64_t>> PiperPhonemizeLexicon::ConvertTextToTokenIds( | ||
| 223 | config.voice = voice; // e.g., voice is en-us | 223 | config.voice = voice; // e.g., voice is en-us |
| 224 | 224 | ||
| 225 | std::vector<std::vector<piper::Phoneme>> phonemes; | 225 | std::vector<std::vector<piper::Phoneme>> phonemes; |
| 226 | - piper::phonemize_eSpeak(text, config, phonemes); | 226 | + |
| 227 | + static std::mutex espeak_mutex; | ||
| 228 | + { | ||
| 229 | + std::lock_guard<std::mutex> lock(espeak_mutex); | ||
| 230 | + | ||
| 231 | + // keep multi threads from calling into piper::phonemize_eSpeak | ||
| 232 | + piper::phonemize_eSpeak(text, config, phonemes); | ||
| 233 | + } | ||
| 227 | 234 | ||
| 228 | std::vector<std::vector<int64_t>> ans; | 235 | std::vector<std::vector<int64_t>> ans; |
| 229 | 236 |
-
请 注册 或 登录 后发表评论