keivalya commited on
Commit
a537178
·
verified ·
1 Parent(s): 7382a55

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +35 -19
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
- with gr.Blocks() as demo:
25
- with gr.Row():
26
- audio_input = gr.Audio(
27
- sources=["upload", "microphone"],
28
- waveform_options=gr.WaveformOptions(
29
- waveform_color="#01C6FF",
30
- waveform_progress_color="#0066B4",
31
- skip_length=2,
32
- show_controls=False,
33
- ),
34
- )
35
- with gr.Row():
36
- artist_output = gr.Textbox(label="Artist", show_copy_button=True)
37
- title_output = gr.Textbox(label="Music", show_copy_button=True)
38
- genre_output = gr.Textbox(label="Genre", show_copy_button=True)
39
- with gr.Row():
40
- image_output = gr.Image(label="Cover")
 
 
 
 
 
 
41
 
42
- demo.launch(inputs=audio_input, outputs=[artist_output, title_output, genre_output, image_output])
 
 
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()