homer512 icon

Pipe + output

homer512 | PRO | 02/08/17 05:56:22 PM UTC | 0 ⭐ | 537 👁️ | Never ⏰ | []
Python |

550 B

|

None

|

0 👍

/

0 👎

#!/usr/bin/env python3
 
 
import subprocess
import sys
 
 
def main():
    audio_url, output_file = sys.argv[1:3]
    popen = subprocess.Popen
    mp3 = popen(('ffmpeg','-i', audio_url,
                 '-f','s16le','-ac','1','-ar','16000','pipe:0'),
                stdout=subprocess.PIPE)
    with mp3.stdout as pipe, open(output_file, 'wb') as output:
        sphinx = popen(('java','-jar','transcriber.jar'),
                       stdin=pipe, stdout=output)
    sys.exit(sphinx.wait() | mp3.wait())
 
 
if __name__ == '__main__':
    main()

Comments