Can you play audio directly from a python script using DawDreamer? #97
-
I'd like a python script that takes an audio file, slows it down and lowers it, then plays it directly from the python script (without having to write it to a wavfile). Is this possible? This is what I have so far:
And also, when I do try and write it to a wavfile, the file comes out playing nothing. Here's my code for when I try and write it to a wavfile:
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Hi, thanks for finding this bug! The issue is that from librosa import load
from scipy.io import wavfile
import dawdreamer as daw
SAMPLE_RATE = 44100
buffer_size = 512
time_ratio = 1.25
song_path = "C:/Users/sebastian/Desktop/slowed_and_lowered/Drake - Fair Trade (Lyrics) ft. Travis Scott.mp3"
def load_audio_file(file_path, duration=None):
sig, rate = load(file_path, duration=duration, mono=False, sr=SAMPLE_RATE)
assert(rate == SAMPLE_RATE)
return sig
engine = daw.RenderEngine(SAMPLE_RATE, buffer_size)
input_audio = load_audio_file(song_path)
playback_processor = engine.make_playbackwarp_processor("song", input_audio)
playback_processor.time_ratio = time_ratio
playback_processor.transpose = -5.
playback_processor.loop_end = 50000. # this is necessary due to a bug
graph = [
(playback_processor, []),
]
engine.load_graph(graph)
output_duration = (input_audio.shape[1]/SAMPLE_RATE)*time_ratio
engine.render(output_duration)
output_audio = playback_processor.get_audio()
wavfile.write('slowed_down_output.wav', SAMPLE_RATE, output_audio.transpose()) If you'd like to hear things directly from Python, you can try Jupyter/IPython notebooks. |
Beta Was this translation helpful? Give feedback.
Hi, thanks for finding this bug! The issue is that
loop_end
needs to be set to a high value (but also not too high, which is another bug aspect). This adjustment is working for me