Namazlol commited on
Commit
fbac62d
·
verified ·
1 Parent(s): 05ccd18

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -8
app.py CHANGED
@@ -1,17 +1,20 @@
1
  import gradio as gr
 
2
 
3
- # Function to return the MP3 file URL
4
- def get_audio():
5
- return "https://huggingface.co/spaces/Namazlol/resolve/main/mysong.mp3"
 
 
 
 
6
 
7
- # Gradio UI with an audio player
8
  demo = gr.Interface(
9
- fn=get_audio,
10
- inputs=[],
11
- outputs="audio",
12
  title="Audio Player",
13
  description="Click play to listen to the song."
14
  )
15
 
16
- # Launch the Space
17
  demo.launch()
 
1
  import gradio as gr
2
+ import requests
3
 
4
+ AUDIO_URL = "https://huggingface.co/spaces/Namazlol/my-audio-hosting/resolve/main/mysong.mp3"
5
+
6
+ def download_audio():
7
+ response = requests.get(AUDIO_URL)
8
+ with open("mysong.mp3", "wb") as f:
9
+ f.write(response.content)
10
+ return "mysong.mp3"
11
 
 
12
  demo = gr.Interface(
13
+ fn=download_audio,
14
+ inputs=[],
15
+ outputs=gr.Audio(type="filepath"),
16
  title="Audio Player",
17
  description="Click play to listen to the song."
18
  )
19
 
 
20
  demo.launch()