fix: piper 加 ESPEAK_DATA_PATH 环境变量 (espeak-ng-data 目录)
This commit is contained in:
@@ -52,6 +52,8 @@ pub struct LocalCliBackend {
|
||||
piper_lib_dir: Option<PathBuf>,
|
||||
/// piper 模型 config json 路径(.onnx.json)
|
||||
piper_config: Option<PathBuf>,
|
||||
/// piper espeak-ng-data 目录路径
|
||||
espeak_data_dir: Option<PathBuf>,
|
||||
}
|
||||
|
||||
impl LocalCliBackend {
|
||||
@@ -61,6 +63,7 @@ impl LocalCliBackend {
|
||||
whisper_lib_dir: None,
|
||||
piper_lib_dir: None,
|
||||
piper_config: None,
|
||||
espeak_data_dir: None,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,10 +73,11 @@ impl LocalCliBackend {
|
||||
self
|
||||
}
|
||||
|
||||
/// 设置 piper 依赖库路径和 config(部署时由 deploy_ai.sh 标定)
|
||||
pub fn with_piper_deps(mut self, lib_dir: PathBuf, config: PathBuf) -> Self {
|
||||
/// 设置 piper 依赖(库路径、config、espeak-ng-data 目录)
|
||||
pub fn with_piper_deps(mut self, lib_dir: PathBuf, config: PathBuf, espeak_data: PathBuf) -> Self {
|
||||
self.piper_lib_dir = Some(lib_dir);
|
||||
self.piper_config = Some(config);
|
||||
self.espeak_data_dir = Some(espeak_data);
|
||||
self
|
||||
}
|
||||
|
||||
@@ -198,10 +202,14 @@ impl AiBackend for LocalCliBackend {
|
||||
fn tts(&self, text: &str, model_path: &Path, output_path: &Path) -> Result<()> {
|
||||
// echo <text> | piper -m <model> [-c <config>] -f <output> --output_format wav
|
||||
// piper 依赖 libespeak-ng.so / libpiper_phonemize.so,需设 LD_LIBRARY_PATH
|
||||
// piper 需要 ESPEAK_DATA_PATH 指向 espeak-ng-data 目录
|
||||
let mut cmd = Command::new(self.piper());
|
||||
if let Some(lib_dir) = &self.piper_lib_dir {
|
||||
self.with_lib_path(&mut cmd, lib_dir);
|
||||
}
|
||||
if let Some(espeak_data) = &self.espeak_data_dir {
|
||||
cmd.env("ESPEAK_DATA_PATH", espeak_data);
|
||||
}
|
||||
cmd.arg("-m")
|
||||
.arg(model_path)
|
||||
.arg("-f")
|
||||
|
||||
Reference in New Issue
Block a user