Add spectrogram to mp3 in huggingface space

#2
by oxysoft - opened

Hi, I know we can test at https://www.riffusion.com/ but the servers are completely in ruin and don't return anything for any prompt I enter. On the other hand I can get a spectrogram very easily and quickly here on this space. Surely we can add this directly in the space and display the mp3 with gradio?

edit: Sorry, I just realized the inference API and spaces are different things

For the impatient ones, simply run this script: https://github.com/hmartiro/riffusion-inference/blob/main/riffusion/audio.py

Copy and paste the image from the huggingface and convert it into wav adding this to the script above:

def write_bytesio_to_file(filename, bytesio):
"""
Write the contents of the given BytesIO to a file.
Creates the file or overwrites the file if it does
not exist yet.
"""
with open(filename, "wb") as outfile:
# Copy the BytesIO stream to the output file
outfile.write(bytesio.getbuffer())

img = Image.open("9b1d3101-81d6-49d2-9de9-62ce7a2e5be3.jpg")
wav = wav_bytes_from_spectrogram_image(img)
write_bytesio_to_file("some_path/music.wav", wav[0])

Riffusion org

Efforts are underway to release a simple interface to help with this process! Thanks for the short term solution fermg

sethforsgren changed discussion status to closed

Sign up or log in to comment