Spaces:
Running
Running
File size: 1,748 Bytes
c9663b3 593ffbb c9663b3 593ffbb c9663b3 c25a71e c9663b3 593ffbb c9663b3 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
import numpy as np
import gradio as gr
import requests
import os
def main_function():
data = {
'api_token': '171afdabea68ffcdbd7f102b8611ac63',
'return': 'apple_music,spotify',
}
files = {
'file': open('test1_scientist.mp3', 'rb'),
}
result = requests.post('https://api.audd.io/', data=data, files=files)
# print(result.text)
# print(result.json())
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']
print("--------------------------------")
print(result.json()['result']['artist'])
print("--------------------------------")
print(result.json()['result']['title'])
print("--------------------------------")
print(result.json()['result']['apple_music']['genreNames'])
print("--------------------------------")
print(result.json()['result']['spotify']['album']['images'][0]['url'])
print("--------------------------------")
return artist, title, genre
def reverse_audio(audio):
sr, data = audio
return (sr, np.flipud(data))
input_audio = gr.Audio(
sources=["upload", "microphone"],
waveform_options=gr.WaveformOptions(
waveform_color="#01C6FF",
waveform_progress_color="#0066B4",
skip_length=2,
show_controls=False,
),
)
demo = gr.Interface(
fn=main_function,
inputs=input_audio,
outputs=[
gr.Textbox(label="Artist", show_copy_button=True),
gr.Textbox(label="Music", show_copy_button=True),
gr.Textbox(label="Genre", show_copy_button=True)
]
)
if __name__ == "__main__":
demo.launch() |