- Notifications
You must be signed in to change notification settings - Fork1
WeeSee/dockerized-midi2mp3-api
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
REST API for converting MIDI files to MP3 audio files - Provided as Docker container for easy usage.
Upload a JSON with base64 encoded Midi data and get a JSON including the base64 encoded Mp3 file. All details see below.
This is a stateless microservice without volumes. The microservice runs forever and accepts http requests on the specified port.
You need to have installed:
- docker
- docker-compose
- make
Run the container usingthe prebuild image from Dockerhub:
docker run -p 8094:80 midi2mp3
You can build the image and start it up withmake
anddocker-compose
make build up ps
There are more commands in the Makefile, try
make
- Verb : GET
- No parameter
- Content-Type : Application/json
{"apiName":"midi2mp3","version": {"api":"1.0" },"description":"midi to mp3 audio files cnverter"}
- Verb : POST
- Content-Type : Application/json
- Parameters :-- midiData : Base64 encoded MIDI-Data (see test section for an example)
- Content-Type : Application/json
{"statusCode":"OK|ERROR","message":"Information on error","base64MidiData":"....","logs": []}
Or make the test from inside the container:
make bash
and build a request file:
echo -n"{\"midiData\":\""> /tmp/test.json cat /tmp/elton.mid| base64 --wrap=0>> /tmp/test.jsonecho"\"}">> /tmp/test.json
or as a one liner:
{echo -n"{\"midiData\":\"";echo -n"`base64 --wrap=0 /tmp/elton.mid`";echo"\"}"; }> /tmp/test.json
then execute the conversion
curl -X POST -H"Content-Type: application/json" --data"@/tmp/test.json" localhost/convert| jq.
You should get a json output containing the base64 encoded mp3 file as
{"statusCode":"OK","message":"","base64Mp3Data":".......","logs": [] }
You can test the microservice from outside the container (this is more complicated since you need the tools installed in your os):
curl -X POST -H"Content-Type: application/json" --data"@test.json" localhost:8094/convert| jq.
To extract the mp3 file out of the result on the command line, use
curl -X POST -H"Content-Type: application/json" --data"@/tmp/test.json" localhost/convert| jq -r .base64Mp3Data| base64 -d> /tmp/elton.mp3
This repo was inspired by
(C) Copyright, 2020
About
Microservice to convert midi file to mp3 file