interactive-pipe-tutorial / core_audio.py
balthou's picture
remove audio generation
3ffc2f6
raw
history blame contribute delete
502 Bytes
import numpy as np
def create_audio(img, context={}):
audio_length_seconds = 0.5
time_axis = np.linspace(0, audio_length_seconds,
int(audio_length_seconds*44100))
modulation = np.interp(time_axis, np.linspace(
0., 1., img.shape[0]), img[:, 0, 0])
frequency = 440 * (1 + context.get('freq', 0)/100.)
audio_1 = (np.sin(2 * np.pi * frequency * time_axis))
audio_2 = (modulation*np.sin(2 * np.pi * 300 * time_axis))
return audio_1, audio_2