keivalya commited on
Commit
593ffbb
·
verified ·
1 Parent(s): c9663b3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -3
app.py CHANGED
@@ -1,13 +1,37 @@
1
  import numpy as np
2
-
3
  import gradio as gr
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
 
5
  def reverse_audio(audio):
6
  sr, data = audio
7
  return (sr, np.flipud(data))
8
 
9
  input_audio = gr.Audio(
10
- sources=["microphone"],
11
  waveform_options=gr.WaveformOptions(
12
  waveform_color="#01C6FF",
13
  waveform_progress_color="#0066B4",
@@ -18,7 +42,11 @@ input_audio = gr.Audio(
18
  demo = gr.Interface(
19
  fn=reverse_audio,
20
  inputs=input_audio,
21
- outputs="audio"
 
 
 
 
22
  )
23
 
24
  if __name__ == "__main__":
 
1
  import numpy as np
 
2
  import gradio as gr
3
+ import requests
4
+ import os
5
+
6
+ def main_function():
7
+ data = {
8
+ 'api_token': '171afdabea68ffcdbd7f102b8611ac63',
9
+ 'return': 'apple_music,spotify',
10
+ }
11
+ files = {
12
+ 'file': open('test1_scientist.mp3', 'rb'),
13
+ }
14
+ result = requests.post('https://api.audd.io/', data=data, files=files)
15
+ # print(result.text)
16
+ # print(result.json())
17
+ artist, title, genre, image_url = result.json()['result']['artist'], result.json()['result']['title'], result.json()['result']['apple_music']['genreNames'], result.json()['result']['spotify']['album']['images'][0]['url']
18
+ print("--------------------------------")
19
+ print(result.json()['result']['artist'])
20
+ print("--------------------------------")
21
+ print(result.json()['result']['title'])
22
+ print("--------------------------------")
23
+ print(result.json()['result']['apple_music']['genreNames'])
24
+ print("--------------------------------")
25
+ print(result.json()['result']['spotify']['album']['images'][0]['url'])
26
+ print("--------------------------------")
27
+ return artist, title, genre
28
 
29
  def reverse_audio(audio):
30
  sr, data = audio
31
  return (sr, np.flipud(data))
32
 
33
  input_audio = gr.Audio(
34
+ sources=["upload", "microphone"],
35
  waveform_options=gr.WaveformOptions(
36
  waveform_color="#01C6FF",
37
  waveform_progress_color="#0066B4",
 
42
  demo = gr.Interface(
43
  fn=reverse_audio,
44
  inputs=input_audio,
45
+ outputs=[
46
+ gr.Textbox(label="Artist", show_copy_button=True),
47
+ gr.Textbox(label="Music", show_copy_button=True),
48
+ gr.Textbox(label="Genre", show_copy_button=True)
49
+ ]
50
  )
51
 
52
  if __name__ == "__main__":