Advertisement
Guest User

huita2

a guest
Nov 5th, 2015
267
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.46 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. t = np.arange(0, 1.0/clk*len(i),1.0/Fs)
  15. s = np.zeros(len(t))
  16. for nr, bit in enumerate(i):
  17.     mask = np.logical_and(t>=nr*1.0/clk,t<(nr+1)*1.0/clk)
  18.     if bit=='1':
  19.         s[mask]=1
  20.     elif bit=='0':
  21.         s[mask]=0
  22.  
  23. io.write('output.wav', Fs, s)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement