Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sys
- import numpy as np
- import scipy.io.wavfile as io
- Fs = 44100 #Hz
- clk = 1000 #Hz
- if len(sys.argv)==1:
- raise IOError("No file provided")
- with open(sys.argv[1], 'r') as f:
- i = f.read()
- t = np.arange(0, 1.0/clk*len(i),1.0/Fs)
- s = np.zeros(len(t))
- for nr, bit in enumerate(i):
- mask = np.logical_and(t>=nr*1.0/clk,t<(nr+1)*1.0/clk)
- if bit=='1':
- s[mask]=1
- elif bit=='0':
- s[mask]=0
- io.write('output.wav', Fs, s)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement