Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- f = open('labels_processed.txt', 'r')
- y, sr = librosa.load('morse.wav', sr=None)
- sample_time = len(y)/sr
- # out = open('labels_excel.txt', 'w')
- sound = np.zeros((len(y)), dtype='float')
- stat = True # init. condition
- prev_pos = 0
- while True:
- line = f.readline()
- if not line:
- f.close()
- break
- pos = int(float(line.split('\t')[0]) / 10 * sr)
- if stat:
- sound[prev_pos:pos] = librosa.tone(800, sr=44100, length=(pos - prev_pos))
- else:
- prev_pos = pos
- stat = not stat
- sf.write('sound_inv.wav', sound, sr)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement