Added import statements
Browse files- audio_methods.py +14 -1
audio_methods.py
CHANGED
@@ -1,3 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
_CAP = 3501 # Cap for the number of notes
|
2 |
_SAMPLING_RATE = 16000 # Parameter to pass continuous signal to a discrete one
|
3 |
_INSTRUMENT_NAME = "Acoustic Grand Piano" # MIDI instrument used
|
@@ -74,7 +88,6 @@ def map_to_wav(song_map: pd.DataFrame, out_file: str, velocity: int=100):
|
|
74 |
|
75 |
def generate_and_display(out_file, model, z_sample=None, velocity=100, seconds=120):
|
76 |
song_map = model.generate(z_sample)
|
77 |
-
display.display(imshow(tf.squeeze(song_map)[:,:50]))
|
78 |
wav = map_to_wav(song_map, out_file, velocity)
|
79 |
|
80 |
return display_audio(wav, seconds)
|
|
|
1 |
+
# Flow and data
|
2 |
+
import numpy as np
|
3 |
+
import pandas as pd
|
4 |
+
|
5 |
+
# Audio
|
6 |
+
import pretty_midi
|
7 |
+
|
8 |
+
# Displaying
|
9 |
+
from IPython import display
|
10 |
+
|
11 |
+
# Extras
|
12 |
+
import collections
|
13 |
+
|
14 |
+
|
15 |
_CAP = 3501 # Cap for the number of notes
|
16 |
_SAMPLING_RATE = 16000 # Parameter to pass continuous signal to a discrete one
|
17 |
_INSTRUMENT_NAME = "Acoustic Grand Piano" # MIDI instrument used
|
|
|
88 |
|
89 |
def generate_and_display(out_file, model, z_sample=None, velocity=100, seconds=120):
|
90 |
song_map = model.generate(z_sample)
|
|
|
91 |
wav = map_to_wav(song_map, out_file, velocity)
|
92 |
|
93 |
return display_audio(wav, seconds)
|