Converting from MP4 video to audio

#51
by christ1 - opened

Can anyone help me with the above?
Are the downloads always a video or am I doing something wrong?

bro, easy stuff. just look up mp4 to mp3 converter on google

For an entirely Python based method, first pip install the Gradio Client library:

pip install -U gradio_client

Then run the following code snippet:

from gradio_client import Client

client = Client("https://facebook-musicgen.hf.space/")
result = client.predict(
   "Piano ballad", # text description
   None,
   fn_index=0,
)

This will return an mp4 video, where the sound is the generated audio. You can then convert this to an mp3 file using ffmpeg:

import subprocess

command = "ffmpeg -i {result} audio.mp3"

subprocess.call(command.replace("{result}", result), shell=True)

Sign up or log in to comment