Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # combine all individual graph sounds into one waveform
- import soundfile as sf
- import numpy as np
- idle_time = 0.5
- graph_duration = 5.0
- data, samplerate = sf.read('graphs_clean.wav')
- graph_samples = int(graph_duration*samplerate)
- last_time = 0
- start_points = []
- for i, samp in enumerate(data):
- cur_time = i / samplerate
- if np.abs(samp[0]) > 0.001 or np.abs(samp[1]) > 0.001:
- if cur_time - last_time > idle_time:
- start_points.append(i)
- last_time = cur_time
- arr = np.zeros((graph_samples, 2))
- for point in start_points:
- arr += data[point:point+graph_samples]
- arr /= len(start_points)
- sf.write('graph_combined.wav', arr, samplerate)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement