Malith-Rukshan / Suno-API

SunoAI Unofficial Python API Library and REST API for Suno.ai — Create Music with Generative AI ! ✨
https://pypi.org/project/SunoAI
MIT License
56 stars 15 forks source link

Can I use the download method to get the .wav files instead of mp3? #3

Closed mylegitches closed 4 months ago

mylegitches commented 4 months ago

Can I use the download method to get the .wav files instead of mp3?

Malith-Rukshan commented 4 months ago

Hello,

There is no built-in method in the SunoAI library to download a .wav file. However, you can use the pydub library to convert a downloaded .mp3 file to .wav format.

Here's an example code snippet:

import suno
from pydub import AudioSegment
client = suno.Suno(cookie='YOUR_COOKIE_HERE')
songs = client.generate(prompt="A serene landscape", is_custom=False, wait_audio=True)

for song in songs:
    file_path = client.download(song=song)
    print(f"Song downloaded to: {file_path}")

    sound = AudioSegment.from_mp3(file_path)
    sound.export("./file.wav", format="wav")
    print("Converted to Wav Format!")