Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from __future__ import print_function
- import sys
- import numpy as np
- import scipy.io.wavfile as io
- from scipy.special import _ufuncs_cxx
- from scipy.sparse.csgraph import _validation
- Fs = 48000 #Hz
- truel = 0.01 #S
- falsel = 0.005 #S
- interval = 0.001 #S
- if len(sys.argv)==1:
- print ('Usage: python huita.py inputfile.txt')
- print ('or: python huita.py inputfile.txt 0.01 0.005 0.001, 48000')
- print ('numbers: length of 1 in seconds, length of 0 is seconds, interval',
- 'in seconds, sampling rate in Hz')
- print ('outputs output.wav')
- raise IOError("No file provided")
- if len(sys.argv)==6:
- truel = float(sys.argv[2])
- falsel = float(sys.argv[3])
- interval = float(sys.argv[4])
- Fs = int(sys.argv[5])
- with open(sys.argv[1], 'r') as f:
- i = f.read()
- s = []
- for nr, bit in enumerate(i):
- s.append(np.zeros(interval*Fs))
- if bit == '1':
- s.append(np.ones(truel*Fs))
- elif bit == '0':
- s.append(np.ones(falsel*Fs))
- s.append(np.zeros(interval*Fs))
- s = np.hstack(s)
- io.write('output.wav', Fs, s)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement