Spaces:
Running
Running
File size: 1,442 Bytes
c9663b3 593ffbb 462bf87 7382a55 593ffbb 025cdfe 462bf87 593ffbb 462bf87 593ffbb b7ffa5d c9663b3 8074472 c9663b3 8074472 |
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 |
import numpy as np
import requests
import os
from scipy.io.wavfile import write
import gradio as gr
def main_function(audio):
os.makedirs("out", exist_ok=True)
write('test.wav', audio[0], audio[1])
data = {
'api_token': '171afdabea68ffcdbd7f102b8611ac63',
'return': 'apple_music,spotify',
}
files = {
'file': open('test.wav', 'rb'),
}
result = requests.post('https://api.audd.io/', data=data, files=files)
artist = result.json()['result']['artist']
title = result.json()['result']['title']
genre = result.json()['result']['apple_music']['genreNames']
image_url = result.json()['result']['spotify']['album']['images'][0]['url']
return artist, title, genre, image_url
with gr.Blocks() as demo:
with gr.Row():
audio_input = gr.Audio(
sources=["upload", "microphone"],
waveform_options=gr.WaveformOptions(
waveform_color="#01C6FF",
waveform_progress_color="#0066B4",
skip_length=2,
show_controls=False,
),
)
with gr.Row():
artist_output = gr.Textbox(label="Artist", show_copy_button=True)
title_output = gr.Textbox(label="Music", show_copy_button=True)
genre_output = gr.Textbox(label="Genre", show_copy_button=True)
with gr.Row():
image_output = gr.Image(label="Cover")
demo.launch(inputs=audio_input, outputs=[artist_output, title_output, genre_output, image_output]) |