diff --git a/montreal_forced_aligner/g2p/phonetisaurus_trainer.py b/montreal_forced_aligner/g2p/phonetisaurus_trainer.py index 1397fe96..22db2f9a 100644 --- a/montreal_forced_aligner/g2p/phonetisaurus_trainer.py +++ b/montreal_forced_aligner/g2p/phonetisaurus_trainer.py @@ -1023,22 +1023,26 @@ def train_ngram_model(self) -> None: os.path.join(self.working_log_directory, "model.log"), "w", encoding="utf8" ) as logf: ngrammerge_proc = subprocess.Popen( - [thirdparty_binary("ngrammerge"), *count_paths], + [ + thirdparty_binary("ngrammerge"), + f'--ofile={self.ngram_path.replace(".fst", ".cnts")}', + *count_paths, + ], stderr=logf, - stdout=subprocess.PIPE, + # stdout=subprocess.PIPE, env=os.environ, ) + ngrammerge_proc.communicate() ngrammake_proc = subprocess.Popen( [ thirdparty_binary("ngrammake"), f"--method={self.smoothing_method}", + self.ngram_path.replace(".fst", ".cnts"), ], - stdin=ngrammerge_proc.stdout, stderr=logf, stdout=subprocess.PIPE, env=os.environ, ) - ngrammake_proc.communicate() ngramshrink_proc = subprocess.Popen( [