josuelmet commited on
Commit
e11cb6f
·
1 Parent(s): 37ced38

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +42 -0
app.py ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from datetime import datetime
2
+ import gradio as gr
3
+ from gradio.components import *
4
+ import mgzip
5
+ import numpy as np
6
+ import pickle
7
+ from zipfile import ZipFile
8
+
9
+ from _Generation import Generator
10
+
11
+ import tensorflow as tf
12
+ from tensorflow import keras
13
+
14
+
15
+
16
+ gen = Generator()
17
+
18
+ def main(artist):
19
+
20
+ if artist == 'Any':
21
+ artist = None
22
+ gen.generate_track_batch(artist)
23
+ filename = f'generation_{datetime.now().strftime("%Y_%m_%d %H_%M_%S")}.gp5'
24
+ gen.save_tracks(filename)
25
+
26
+ # create a ZipFile object
27
+ zipObj = ZipFile(filename.replace('.gp5', '.zip'), "w")
28
+ zipObj.write(filename)
29
+ zipObj.close()
30
+
31
+ return filename.replace('.gp5', '.zip')
32
+
33
+ with mgzip.open('data\\track_data.pickle.gz') as file:
34
+ track_data = pickle.load(file)
35
+
36
+
37
+ inputs = Radio(['Any'] + list(track_data.artist.unique()), label='Choose an Artist for Song Initialization:')
38
+
39
+
40
+ i = gr.Interface(fn = main, inputs = inputs,
41
+ outputs = File())
42
+ i.launch()