Spaces:
Runtime error
Runtime error
Commit
•
feb1951
1
Parent(s):
a718c40
Update app.py
Browse files
app.py
CHANGED
@@ -23,9 +23,15 @@ def download_audio(id_video):
|
|
23 |
embed_html_all = embed_html1 + id +embed_html2
|
24 |
return audio_file, audio_file, embed_html_all
|
25 |
|
26 |
-
def
|
27 |
# setup the client
|
28 |
audio_file, audio_file, embed_html_all = download_audio(input_path)
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
client = SimbalsAPIClient(os.environ['TOKEN'], debug=True)
|
30 |
parameters = client.prepare_request("31415", audio_file=audio_file)
|
31 |
|
@@ -91,7 +97,8 @@ def process(input_path):
|
|
91 |
audioquality = {}
|
92 |
audioquality[res['audio_quality'][0]['name']]= res['audio_quality'][0]['probability']
|
93 |
|
94 |
-
return embed_html_all, dict_moods, genres, instruments, vocalgender, timbres, themes, audioquality,str(dict_desc['Electric/Acoustic']),str(dict_desc['Danceability']),str(dict_desc['Arousal']),str(dict_desc['Vocal/Instrumental']),str(dict_desc['Studio/Live']),str(dict_desc['Music/Speech']),str(dict_desc['Valence']),str(dict_desc['Melodic']),str(dict_desc['Articulation']),str(dict_desc['RhythmicStability']),str(dict_desc['Dissonance']),str(dict_desc['BPM']),str(dict_desc['Binary']),str(dict_desc['Key']),str(dict_desc['Mode']),str(dict_desc['TexturalStability'])
|
|
|
95 |
|
96 |
|
97 |
|
@@ -107,12 +114,12 @@ with gr.Blocks() as demo:
|
|
107 |
|
108 |
with gr.Row():
|
109 |
audio_input = gr.Textbox(placeholder='YouTube video URL', label='YouTube video URL')
|
|
|
110 |
|
111 |
-
#with gr.Row():
|
112 |
-
# audio_input = gr.Audio(type="filepath", label='Audio Input')
|
113 |
-
|
114 |
with gr.Row():
|
115 |
-
|
|
|
|
|
116 |
|
117 |
with gr.Row():
|
118 |
with gr.Column():
|
@@ -172,7 +179,7 @@ with gr.Blocks() as demo:
|
|
172 |
themes=gr.Label(label="Themes", show_label=False)
|
173 |
'''
|
174 |
|
175 |
-
|
176 |
outputs=[html,
|
177 |
dict_moods,
|
178 |
genres,
|
@@ -198,5 +205,33 @@ with gr.Blocks() as demo:
|
|
198 |
mode,
|
199 |
texturalstability
|
200 |
])
|
201 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
202 |
demo.launch(debug=True)
|
|
|
23 |
embed_html_all = embed_html1 + id +embed_html2
|
24 |
return audio_file, audio_file, embed_html_all
|
25 |
|
26 |
+
def process_url(input_path):
|
27 |
# setup the client
|
28 |
audio_file, audio_file, embed_html_all = download_audio(input_path)
|
29 |
+
return embed_html_all, process(audio_file)
|
30 |
+
|
31 |
+
def process_file(input_path):
|
32 |
+
return "", process(input_path)
|
33 |
+
|
34 |
+
def process(input_path)
|
35 |
client = SimbalsAPIClient(os.environ['TOKEN'], debug=True)
|
36 |
parameters = client.prepare_request("31415", audio_file=audio_file)
|
37 |
|
|
|
97 |
audioquality = {}
|
98 |
audioquality[res['audio_quality'][0]['name']]= res['audio_quality'][0]['probability']
|
99 |
|
100 |
+
#return embed_html_all, dict_moods, genres, instruments, vocalgender, timbres, themes, audioquality,str(dict_desc['Electric/Acoustic']),str(dict_desc['Danceability']),str(dict_desc['Arousal']),str(dict_desc['Vocal/Instrumental']),str(dict_desc['Studio/Live']),str(dict_desc['Music/Speech']),str(dict_desc['Valence']),str(dict_desc['Melodic']),str(dict_desc['Articulation']),str(dict_desc['RhythmicStability']),str(dict_desc['Dissonance']),str(dict_desc['BPM']),str(dict_desc['Binary']),str(dict_desc['Key']),str(dict_desc['Mode']),str(dict_desc['TexturalStability'])
|
101 |
+
return dict_moods, genres, instruments, vocalgender, timbres, themes, audioquality,str(dict_desc['Electric/Acoustic']),str(dict_desc['Danceability']),str(dict_desc['Arousal']),str(dict_desc['Vocal/Instrumental']),str(dict_desc['Studio/Live']),str(dict_desc['Music/Speech']),str(dict_desc['Valence']),str(dict_desc['Melodic']),str(dict_desc['Articulation']),str(dict_desc['RhythmicStability']),str(dict_desc['Dissonance']),str(dict_desc['BPM']),str(dict_desc['Binary']),str(dict_desc['Key']),str(dict_desc['Mode']),str(dict_desc['TexturalStability'])
|
102 |
|
103 |
|
104 |
|
|
|
114 |
|
115 |
with gr.Row():
|
116 |
audio_input = gr.Textbox(placeholder='YouTube video URL', label='YouTube video URL')
|
117 |
+
analyze_url_btn = gr.Button('Analyze URL')
|
118 |
|
|
|
|
|
|
|
119 |
with gr.Row():
|
120 |
+
audio_input_file = gr.Audio(type="filepath", label='Audio Input')
|
121 |
+
analyze_file_btn = gr.Button('Analyze File')
|
122 |
+
|
123 |
|
124 |
with gr.Row():
|
125 |
with gr.Column():
|
|
|
179 |
themes=gr.Label(label="Themes", show_label=False)
|
180 |
'''
|
181 |
|
182 |
+
analyze_url_btn.click(process, inputs=[audio_input],
|
183 |
outputs=[html,
|
184 |
dict_moods,
|
185 |
genres,
|
|
|
205 |
mode,
|
206 |
texturalstability
|
207 |
])
|
208 |
+
|
209 |
+
analyze_file_btn.click(process_file, inputs=[audio_input],
|
210 |
+
outputs=[html,
|
211 |
+
dict_moods,
|
212 |
+
genres,
|
213 |
+
instruments,
|
214 |
+
vocalgender,
|
215 |
+
timbres,
|
216 |
+
themes,
|
217 |
+
audioquality,
|
218 |
+
acousticness,
|
219 |
+
danceability,
|
220 |
+
arousal,
|
221 |
+
instrumentalness,
|
222 |
+
liveness,
|
223 |
+
speechiness,
|
224 |
+
valence,
|
225 |
+
melodic,
|
226 |
+
articulation,
|
227 |
+
rhythmicstability,
|
228 |
+
dissonance,
|
229 |
+
bpm,
|
230 |
+
binary,
|
231 |
+
key,
|
232 |
+
mode,
|
233 |
+
texturalstability
|
234 |
+
])
|
235 |
+
|
236 |
+
|
237 |
demo.launch(debug=True)
|