TEXT to MUSIC API

PAID
By Manolis Teletos | Updated 2ヶ月前 | Music
Popularity

8 / 10

Latency

2,135ms

Service Level

99%

Health Check

100%

Back to All Discussions

What Type of response is it giving and how can I read it as .mp3 ?

it is giving me some weird symbols as response. how can i parse it ?

Rapid account: Manosteletos
manosteletos Commented 6ヶ月前

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)

Rapid account: Manosteletos
manosteletos Commented 1年前

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

Join in the discussion - add comment below:

Login / Signup to post new comments