File size: 1,236 Bytes
a3b5b38
5d68a5f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b2e7566
5d68a5f
 
 
 
 
b2e7566
5d68a5f
 
 
 
 
 
 
 
 
 
 
794de16
5d68a5f
 
 
 
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
import gradio as gr
import datetime as DT
import pytz
from gradio_client import Client

ipAddress = None


def __nowInIST():
    return DT.datetime.now(pytz.timezone("Asia/Kolkata"))


def __attachIp(request: gr.Request):
    global ipAddress
    x_forwarded_for = request.headers.get('x-forwarded-for')
    if x_forwarded_for:
        ipAddress = x_forwarded_for


def pprint(log: str):
    now = __nowInIST()
    now = now.strftime("%Y-%m-%d %H:%M:%S")
    print(f"[{now}] [{ipAddress}] {log}")


def predict(audio):
    pprint("Starting the job")
    client = Client("https://abidlabs-music-separation.hf.space/")
    result = client.predict(
        audio,
        api_name="/predict"
    )
    pprint(f"{result=}")
    return result


with gr.Interface(
    predict,
    inputs=gr.Audio(type="filepath", label="Input"),
    outputs=[
      gr.Audio(type="filepath", label="Vocals"),
      gr.Audio(type="filepath", label="No Vocals / Instrumental")
    ],
    title="Split your song into vocals & music",
    article="<p style='text-align: center'>Credits: <a href='https://huggingface.co/spaces/abidlabs/music-separation'>abidlabs/music-separation</a> </>",
) as demo:
  demo.load(__attachIp, None, None)

demo.launch(debug=True)