Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,8 +1,8 @@
|
|
1 |
import numpy as np
|
|
|
2 |
import requests
|
3 |
import os
|
4 |
from scipy.io.wavfile import write
|
5 |
-
import gradio as gr
|
6 |
|
7 |
def main_function(audio):
|
8 |
os.makedirs("out", exist_ok=True)
|
@@ -19,24 +19,40 @@ def main_function(audio):
|
|
19 |
title = result.json()['result']['title']
|
20 |
genre = result.json()['result']['apple_music']['genreNames']
|
21 |
image_url = result.json()['result']['spotify']['album']['images'][0]['url']
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
return artist, title, genre, image_url
|
23 |
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
|
42 |
-
|
|
|
|
1 |
import numpy as np
|
2 |
+
import gradio as gr
|
3 |
import requests
|
4 |
import os
|
5 |
from scipy.io.wavfile import write
|
|
|
6 |
|
7 |
def main_function(audio):
|
8 |
os.makedirs("out", exist_ok=True)
|
|
|
19 |
title = result.json()['result']['title']
|
20 |
genre = result.json()['result']['apple_music']['genreNames']
|
21 |
image_url = result.json()['result']['spotify']['album']['images'][0]['url']
|
22 |
+
print("--------------------------------")
|
23 |
+
print(result.json()['result']['artist'])
|
24 |
+
print("--------------------------------")
|
25 |
+
print(result.json()['result']['title'])
|
26 |
+
print("--------------------------------")
|
27 |
+
print(result.json()['result']['apple_music']['genreNames'])
|
28 |
+
print("--------------------------------")
|
29 |
+
print(result.json()['result']['spotify']['album']['images'][0]['url'])
|
30 |
+
print("--------------------------------")
|
31 |
return artist, title, genre, image_url
|
32 |
|
33 |
+
def reverse_audio(audio):
|
34 |
+
sr, data = audio
|
35 |
+
return (sr, np.flipud(data))
|
36 |
+
|
37 |
+
input_audio = gr.Audio(
|
38 |
+
sources=["upload", "microphone"],
|
39 |
+
waveform_options=gr.WaveformOptions(
|
40 |
+
waveform_color="#01C6FF",
|
41 |
+
waveform_progress_color="#0066B4",
|
42 |
+
skip_length=2,
|
43 |
+
show_controls=False,
|
44 |
+
),
|
45 |
+
)
|
46 |
+
demo = gr.Interface(
|
47 |
+
fn=main_function,
|
48 |
+
inputs=input_audio,
|
49 |
+
outputs=[
|
50 |
+
gr.Textbox(label="Artist", show_copy_button=True),
|
51 |
+
gr.Textbox(label="Music", show_copy_button=True),
|
52 |
+
gr.Textbox(label="Genre", show_copy_button=True),
|
53 |
+
gr.Image(label="Cover")
|
54 |
+
]
|
55 |
+
)
|
56 |
|
57 |
+
if __name__ == "__main__":
|
58 |
+
demo.launch()
|