From 50997655414bc8627d2b08ad31e0ff4348198d00 Mon Sep 17 00:00:00 2001 From: talksik Date: Thu, 27 Apr 2023 16:58:32 -0700 Subject: [PATCH] trying another method to pipe to second command --- basic_text_to_speech/talk.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/basic_text_to_speech/talk.py b/basic_text_to_speech/talk.py index f8594df..3bbae2b 100644 --- a/basic_text_to_speech/talk.py +++ b/basic_text_to_speech/talk.py @@ -2,11 +2,16 @@ import time from subprocess import call +from subprocess import Popen, PIPE + def robot(text): print("executing command") - call(['espeak', '--stdin', '"Hello world how are you doing today?"', - '|', 'aplay', '-D plughw:2,0']) + espeak = Popen( + ['espeak', '--stdin "Hello world how are you doing today?"'], stdout=PIPE) + aplay = Popen(['aplay', '-D plughw:2,0'], stdin=espeak.stdout, stdout=PIPE) + espeak.stdout.close() # enable write error in dd if ssh dies + out, err = aplay.communicate() if __name__ == '__main__':