res = conn.getresponse()
if res.status == 200:
# Save the response content (MIDI or MP3 data) to a local file
with open(“output”, “wb”) as file:
file.write(res.read())
print(“MIDI or MP3 file saved as output”)
else:
print(“Failed to retrieve the file. Status code:”, res.status)
The response is in .mid format and instantly it downloads it to your browser.
Convert MIDI to audio: MIDI files contain musical instructions, but they do not contain actual audio data. To convert MIDI to audio, you’ll need to use a software or library that can interpret the MIDI instructions and generate audio output. One popular library for this purpose is FluidSynth.
In future version in July I plan to choose what type of response you want to download in this case .mp3.
Thanks for your comment.
Emmanuel
Únase a la conversación, añada un comentario a continuación:
Inicie sesió/Regístrese para publicar nuevos comentarios
Arman the mp3 version is out . In python you can parse it like this :
import http.client
conn = http.client.HTTPSConnection(“text-to-music-api.p.rapidapi.com”)
headers = {
‘X-RapidAPI-Key’: “XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX”,
‘X-RapidAPI-Host’: “text-to-music-api.p.rapidapi.com”
}
conn.request(“GET”, “/play?ascii_text=IaMaTextThatWillGiveMusic”, headers=headers)
res = conn.getresponse()
if res.status == 200:
# Save the response content (MIDI or MP3 data) to a local file
with open(“output”, “wb”) as file:
file.write(res.read())
print(“MIDI or MP3 file saved as output”)
else:
print(“Failed to retrieve the file. Status code:”, res.status)
Hello Arman.
The response is in .mid format and instantly it downloads it to your browser.
Convert MIDI to audio: MIDI files contain musical instructions, but they do not contain actual audio data. To convert MIDI to audio, you’ll need to use a software or library that can interpret the MIDI instructions and generate audio output. One popular library for this purpose is FluidSynth.
In future version in July I plan to choose what type of response you want to download in this case .mp3.
Thanks for your comment.
Emmanuel