Skip to content

APIs and Controller

Raef Maroof edited this page Dec 9, 2022 · 27 revisions

Identify Song Clip - Query Custom ML Model

Django API endpoint to save audio clip and call our machine learning model. Requires the audio file of a sound clip. Returns the identified song title.

Endpoint: POST /postAudio/

Request Parameters (Multipart Form):

Key Value
audio 16-bit mono pcm audio file to identify

Returns (JSON): Response title of input audio clip

Key Type Value
songName String The title of the song identified by the ML model.

Response Codes:

Response Code Interpretation
200 OK Successfully identified the song; name supplied in return JSON.
404 Bad Request Invalid request format.

Django API endpoint to retrieve relevant movie/song information. Returns information for movies that contain a given song.

Endpoint: POST /getsongs/

Request Parameters:

Key Value
songName The name of the song on which movie data is desired.

Returns (JSON):

Key Type Value
movies Array of String Arrays An array of movie information that contain the song passed in the request body.

Here's a breakdown of the arrays contained in movies:

Index Type Value
0 String The name of the movie.
1 String The year the movie was released.
2 String The director of the movie.
3 String Link to movie poster.

Response Codes:

Response Code Interpretation
200 OK Successfully located related movies and associated data. Returns json results as above.
400 Bad Request Invalid request format.
404 Not Found Unrecognized song.

Interactions with 3rd party SDKs

ShazamKit

Pass 16-bit mono audio pcm byte array to ShazamKit exactly as documented on ShazamKit documentation for Basic Audio recognition using Session.

Returns MatchResult object.

Used to identify songs in skeletal product version. Not used in MVP

Interactions with 3rd party APIs (Spotify)

Post to https://accounts.spotify.com/api/token with clientID and clientSecret generated on Spotify Developer Dashboard.

Returns OAuth token.

Used to authenticate for other API calls.

See documentation

GET to https://api.spotify.com/v1/search with parameters q=<songName> and type=track.

Returns all search results for tracks matching the provided songName.

Used to get all trackIDs for all songs in database when generating training data

See documentation

GET to https://api.spotify.com/v1/audio-analysis/<trackID>.

Returns comprehensive audio analysis on the trackID provided, including pitch analysis.

Used to get all pitch data when generating training data.

See documentation