File size: 917 Bytes
da3e61e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import gradio as gr
import os
from acrcloud import ACRCloud

# Retrieve ACRCloud credentials from environment variables
acr_access_key = os.environ.get('ACR_ACCESS_KEY')
acr_access_secret = os.environ.get('ACR_ACCESS_SECRET')

# Initialize ACRCloud client
acr = ACRCloud('eu-west-1.api.acrcloud.com', acr_access_key, acr_access_secret)

def identify_audio(file):
    # Save the uploaded file temporarily
    file_path = "temp_audio_file.ogg"
    file.save(file_path)

    # Identify the audio using ACRCloud
    metadata = acr.identify(file_path)

    # Return the metadata as the output
    return metadata

# Create Gradio interface
iface = gr.Interface(
    fn=identify_audio,
    inputs=gr.File(label="Upload Audio File"),
    outputs=gr.JSON(label="Audio Metadata"),
    title="Audio Search by File",
    description="Upload an audio file to identify it using ACRCloud."
)

# Launch the interface
iface.launch()