Commit
•
efb7947
1
Parent(s):
c44e30d
Update app.py
Browse files
app.py
CHANGED
@@ -13,6 +13,9 @@ from x_transformer_1_23_2 import *
|
|
13 |
import random
|
14 |
import tqdm
|
15 |
|
|
|
|
|
|
|
16 |
from midi_to_colab_audio import midi_to_colab_audio
|
17 |
import TMIDIX
|
18 |
|
@@ -67,7 +70,7 @@ def GenerateMusic():
|
|
67 |
print('Done!')
|
68 |
print('=' * 70)
|
69 |
|
70 |
-
input_num_tokens =
|
71 |
print('-' * 70)
|
72 |
|
73 |
#===============================================================================
|
@@ -80,6 +83,11 @@ def GenerateMusic():
|
|
80 |
|
81 |
def tokens2txt(tokens):
|
82 |
return [chr(tok-648) for tok in tokens if 0+648 < tok < 128+648 ]
|
|
|
|
|
|
|
|
|
|
|
83 |
|
84 |
print('=' * 70)
|
85 |
print('Generating...')
|
@@ -126,7 +134,7 @@ def GenerateMusic():
|
|
126 |
print('Sample INTs', out1[:12])
|
127 |
print('=' * 70)
|
128 |
|
129 |
-
generated_song_description =
|
130 |
|
131 |
if len(out1) != 0:
|
132 |
|
|
|
13 |
import random
|
14 |
import tqdm
|
15 |
|
16 |
+
import pprint
|
17 |
+
import io
|
18 |
+
|
19 |
from midi_to_colab_audio import midi_to_colab_audio
|
20 |
import TMIDIX
|
21 |
|
|
|
70 |
print('Done!')
|
71 |
print('=' * 70)
|
72 |
|
73 |
+
input_num_tokens = 1024+512
|
74 |
print('-' * 70)
|
75 |
|
76 |
#===============================================================================
|
|
|
83 |
|
84 |
def tokens2txt(tokens):
|
85 |
return [chr(tok-648) for tok in tokens if 0+648 < tok < 128+648 ]
|
86 |
+
|
87 |
+
def pprint_to_string(obj, compact=True):
|
88 |
+
output = io.StringIO()
|
89 |
+
pprint.pprint(obj, stream=output, compact=compact)
|
90 |
+
return output.getvalue()
|
91 |
|
92 |
print('=' * 70)
|
93 |
print('Generating...')
|
|
|
134 |
print('Sample INTs', out1[:12])
|
135 |
print('=' * 70)
|
136 |
|
137 |
+
generated_song_description = pprint_to_string(''.join(tokens2txt(out1)))
|
138 |
|
139 |
if len(out1) != 0:
|
140 |
|