| 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 |
|
|
| |
| demo = gr.Interface( |
| fn=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." |
| ) |
|
|
| |
| if __name__ == "__main__": |
| demo.launch(share=True, debug=True) |