PierreHanna commited on
Commit
830f8b5
1 Parent(s): 5558062

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +43 -3
app.py CHANGED
@@ -25,12 +25,52 @@ def process(input_path):
25
  print(json.dumps(results[1], indent=1))
26
  #return json.dumps(results[1], indent=1)
27
  output = json.dumps(results[1], indent=1)
28
- trackname = results[1]["response"]["scanmatch"]['1']['partial_fast_matches'][0]['track']['title']
29
- artistname = results[1]["response"]["scanmatch"]['1']['partial_fast_matches'][0]['artists'][0]['name']
30
- return trackname+" by "+artistname
31
  break
32
  time.sleep(1)
33
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34
  demo = gr.Interface(fn=process,
35
  inputs=gr.Audio(type="filepath"),
36
  outputs=gr.outputs.Textbox(label="Generated Text")
 
25
  print(json.dumps(results[1], indent=1))
26
  #return json.dumps(results[1], indent=1)
27
  output = json.dumps(results[1], indent=1)
 
 
 
28
  break
29
  time.sleep(1)
30
 
31
+
32
+ res = results[1]["response"]["tagging"]["2"]
33
+
34
+ moods = []
35
+ for m in res['moods']:
36
+ moods.append((m['name'], m['probability']))
37
+ print(moods)
38
+
39
+ music_desc=[]
40
+ for d in res['music_descriptors']:
41
+ music_desc.append((d['name'],d['value']))
42
+ print(music_desc)
43
+
44
+ genres=[]
45
+ for d in res['genres']:
46
+ genres.append((d['name'],d['probability']))
47
+ print(genres)
48
+
49
+ themes = []
50
+ for d in res['themes']:
51
+ themes.append((d['name'],d['probability']))
52
+ print(themes)
53
+
54
+
55
+ instruments = []
56
+ for d in res['instruments']:
57
+ instruments.append((d['name'],d['probability']))
58
+ print(instruments)
59
+
60
+ timbres = []
61
+ for d in res['timbres']:
62
+ timbres.append((d['name'],d['probability']))
63
+ print(timbres)
64
+
65
+ vocalgender = [res['vocal_gender'][0]['name'], res['vocal_gender'][0]['probability']]
66
+ print(vocalgender)
67
+
68
+ audioquality = [res['audio_quality'][0]['name'], res['audio_quality'][0]['probability']]
69
+ print(audioquality)
70
+
71
+ return moods
72
+
73
+
74
  demo = gr.Interface(fn=process,
75
  inputs=gr.Audio(type="filepath"),
76
  outputs=gr.outputs.Textbox(label="Generated Text")