File tree Expand file tree Collapse file tree 1 file changed +18
-2
lines changed
Expand file tree Collapse file tree 1 file changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -204,8 +204,24 @@ class VoiceEnginePiper(VoiceEngine):
204204 def make_wav (self , text , fname ):
205205 """Generate voice output to WAV file `fname`."""
206206 text = self .transform_text (text )
207- cmd = f"echo '{ text } ' | { self .command } --model /app/piper/voices/{ self .voice_name } --output_file { fname } "
208- return self .call ([cmd ]) == 0
207+ cmd = [
208+ self .command ,
209+ "--model" , f"/app/piper/voices/{ self .voice_name } " ,
210+ "--output_file" , fname
211+ ]
212+ try :
213+ # Run Piper and pass text via stdin
214+ process = subprocess .Popen (
215+ cmd ,
216+ stdin = subprocess .PIPE ,
217+ stdout = subprocess .DEVNULL , # Suppress stdout
218+ stderr = subprocess .DEVNULL # Suppress stderr
219+ )
220+ process .communicate (input = text .encode ("utf-8" ))
221+ return process .returncode == 0
222+ except Exception as e :
223+ print (f"Error generating WAV: { e } " )
224+ return False
209225
210226
211227
You can’t perform that action at this time.
0 commit comments