HUB
Sign inSign up

gabeserna/songscribe-api

By gabeserna

•Updated about 2 years ago

Songscribe's Python API for isolating instruments and converting audio to midi

Image
API management
Machine learning & AI
0

596

gabeserna/songscribe-api repository overview

⁠Songscribe API Docs

Instrument Splitter & Midi Converter API for Songscribe⁠



⁠Quick Start

If you set up the API without Docker, run the following command to start the local server:

uvicorn moseca.api.main:app

To exit, press ctrl + C on Windows or cmd + C on Mac.

Visit localhost:8000/docs⁠ for a list of all available endpoints with details, along with tools for testing the endpoint.

The Github repo for this project is located here⁠.



⁠Endpoints

⁠Separation Modes Explained
  • Duet:

    • Description: Separates the audio into vocals and instrumental components.
    • Files Generated: vocals.mp3, no_vocals.mp3
  • Small Band:

    • Description: Separates the audio into vocals, drums, bass, and other instruments.
    • Files Generated: vocals.mp3, drums.mp3, bass.mp3, other.mp3
  • Full Band:

    • Description: Separates the audio into vocals, drums, bass, guitar, piano, and other instruments.
    • Files Generated: vocals.mp3, drums.mp3, bass.mp3, guitar.mp3, piano.mp3, other.mp3



⁠/split-audio

Method: POST
Description: Upload an audio file and specify the separation mode to separate the audio tracks.

⁠Request Parameters
ParameterTypeRequiredDescription
audio_filefileYesThe audio file to be processed (.mp3, .wav, .ogg, .flac).
separation_modestringYesThe model to use for separation. Possible values:
- Duet
- Small Band
- Full Band
tempointYesThe tempo in beats per minute of the song.
start_timeintNoThe starting point of audio processing in seconds (default is 0).
end_timeintNoThe endpoint of audio processing in seconds (default is the total duration of the audio).
⁠Request Example

To send a request using cURL, you can use the following command:

curl -X POST "http://127.0.0.1:8000/split-audio" \
  -F "audio_file=@/path/to/your/audiofile.mp3" \
  -F "separation_mode=Duet" \
  -F "tempo=120" \
  -F "start_time=0" \
  -F "end_time=60" \
  --output output.zip



⁠/split-yt-audio

Method: POST
Description: Provide a YouTube URL to download its audio and specify the separation mode to separate the audio tracks.

This endpoint is identical to /split-audio, except this endpoint you provide a YouTube URL instead of an audio file.

⁠Request Parameters
ParameterTypeRequiredDescription
youtube_urlstringYesThe YouTube video URL from which to download the audio.
separation_modestringYesThe model to use for separation. Possible values:
- Duet
- Small Band
- Full Band
tempointYesThe tempo in beats per minute of the song.
start_timeintNoThe starting point of audio processing in seconds (default is 0).
end_timeintNoThe endpoint of audio processing in seconds (default is the total duration of the audio).
⁠Request Example

To send a request using cURL, you can use the following command:

curl -X POST "http://127.0.0.1:8000/split-yt-audio" \
  -F "youtube_url=https://www.youtube.com/watch?v=example" \
  -F "separation_mode=Small Band" \
  -F "tempo=120" \
  -F "start_time=0" \
  -F "end_time=60" \
  --output output.zip



⁠/yt-to-mp3

Method: POST
Description: Converts a YouTube video URL to an MP3 file.

⁠Request Parameters
ParameterTypeRequiredDescription
youtube_urlstringYesThe YouTube video URL from which to download and convert audio.
⁠Request Example

To send a request using cURL, you can use the following command:

curl -X POST "http://127.0.0.1:8000/yt-to-mp3"
  -F "youtube_url=https://www.youtube.com/watch?v=example"
  --output downloaded_audio.mp3



⁠/align-audio

Method: POST
Description: Remove silence from the beginning of a song, and align the start with the first measure.

⁠Request Parameters
ParameterTypeRequiredDescription
audio filefileYesThe audio file to be processed (.mp3, .wav, .ogg, .flac).
tempointYesThe tempo in beats per minute of the song.
start_timeintNoThe starting point of audio alignment in seconds (default is 0).
end_timeintNoThe endpoint of audio alignment in seconds (default is the total duration of the audio).
⁠Request Example

To send a request using cURL, you can use the following command:

curl -X POST "http://127.0.0.1:8000/align-audio" \
  -F "audio_file=@/path/to/your/audiofile.mp3" \
  -F "tempo=120" \
  -F "start_time=0" \
  -F "end_time=60" \
  --output processed_audiofile.mp3



⁠/audio-to-midi

Method: POST
Description: Converts an audio file to a MIDI file by extracting musical notes and events from the audio.

⁠Request Parameters
ParameterTypeRequiredDescription
audio_filefileYesThe audio file to be converted (e.g., MP3, WAV).
onset_thresholdfloatNoThe threshold for detecting the onset of notes (default: 0.5).
frame_thresholdfloatNoThe threshold for detecting individual frames (default: 0.3).
minimum_note_lengthfloatNoThe minimum duration (in seconds) for detected notes (default: 127.70).
minimum_frequencyfloatNoThe minimum frequency for note detection.
maximum_frequencyfloatNoThe maximum frequency for note detection.
tempointNoThe tempo to be applied in the MIDI output (in BPM, default: 120).
percussionbooleanNoDetermines if the audio should be converted as a percussive instrument (default: false).
⁠Request Example
curl -X POST "http://127.0.0.1:8000/audio-to-midi" \
  -F "audio_file=@/path/to/your/audiofile.wav" \
  -F "onset_threshold=0.5" \
  -F "frame_threshold=0.3" \
  -F "minimum_note_length=127.70" \
  -F "minimum_frequency=200" \
  -F "maximum_frequency=8000" \
  -F "tempo=120" \
  -F "percussion=false"
  --output audiofile.mid

Back to Top⁠

Tag summary

Content type

Image

Digest

sha256:68336acb9…

Size

4 GB

Last updated

about 2 years ago

docker pull gabeserna/songscribe-api