Advertisement
homer512

Pipe + output

Feb 8th, 2017
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.55 KB | None | 0 0
  1. #!/usr/bin/env python3
  2.  
  3.  
  4. import subprocess
  5. import sys
  6.  
  7.  
  8. def main():
  9.     audio_url, output_file = sys.argv[1:3]
  10.     popen = subprocess.Popen
  11.     mp3 = popen(('ffmpeg','-i', audio_url,
  12.                  '-f','s16le','-ac','1','-ar','16000','pipe:0'),
  13.                 stdout=subprocess.PIPE)
  14.     with mp3.stdout as pipe, open(output_file, 'wb') as output:
  15.         sphinx = popen(('java','-jar','transcriber.jar'),
  16.                        stdin=pipe, stdout=output)
  17.     sys.exit(sphinx.wait() | mp3.wait())
  18.  
  19.  
  20. if __name__ == '__main__':
  21.     main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement