Spaces:
Running
Running
File size: 960 Bytes
f2293ee 67c7dc1 f2293ee 7333778 c63cb22 fd06651 c63cb22 fd06651 c63cb22 f2293ee c63cb22 caa7472 7333778 c63cb22 60795e0 caa7472 fd06651 c63cb22 7333778 |
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 |
import gradio as gr
import re
def convert_url_to_mp3(url: str):
"""
Convert a Suno song URL to the direct MP3 link.
Returns a tuple: (displayed URL, downloadable URL)
"""
match = re.search(r'suno\.com/song/([a-f0-9\-]+)', url)
if not match:
return "Invalid Suno URL", None
song_id = match.group(1)
mp3_url = f"https://cdn1.suno.ai/{song_id}.mp3"
return mp3_url, mp3_url # first displayed, second downloadable
# Define the Gradio interface
demo = gr.Interface(
fn=convert_url_to_mp3, # Use the function name convert_url_to_mp3
inputs=gr.Textbox(label="Enter Suno song URL", placeholder="https://suno.com/song/..."),
outputs=[
gr.Textbox(label="MP3 URL"),
gr.File(label="Download MP3")
],
title="Suno → MP3 Converter",
description="Enter any Suno song URL to get a direct MP3 link."
)
# Launch the Space
if __name__ == "__main__":
demo.launch(share=True, debug=True) |