Spaces:
Sleeping
Sleeping
| 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 | |