Advertisement
Guest User

huita

a guest
Nov 5th, 2015
242
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.45 KB | None | 0 0
  1. import sys
  2. import numpy as np
  3. import scipy.io.wavfile as io
  4.  
  5. Fs = 44100 #Hz
  6. clk = 1000 #Hz
  7.  
  8. if len(sys.argv)==1:
  9.     raise IOError("No file provided")
  10.  
  11. with open(sys.argv[1], 'r') as f:
  12.     i = f.read()
  13.  
  14. s = np.arange(0, 1.0/clk*len(i),1.0/Fs)
  15. for nr, bit in enumerate(i):
  16.     mask = np.logical_and(s>=nr*1.0/clk,s<(nr+1)*1.0/clk)
  17.     if bit=='1':
  18.         s[mask]=1
  19.     elif bit=='0':
  20.         s[mask]=0
  21.  
  22. io.write('output.wav', Fs, s)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement