Skip to main content
Glama

load

Extracts audio time series from a file by specifying file path, offset, and optional duration. Supports local audio analysis without revealing song information.

Instructions

Loads an audio file and returns the path to the audio time series Offset and duration are optional, in seconds. Be careful, you will never know the name of the song.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
durationNo
file_pathYes
offsetNo

Implementation Reference

  • The 'load' tool handler: decorated with @mcp.tool(), loads audio using librosa.load(), saves the waveform 'y' to a CSV file in tempdir, computes STFT and HPSS (comments out saving them), returns dict with 'y_path'.
    @mcp.tool() def load( file_path: str, offset: float = 0.0, duration: float = None, ) -> dict: """ Loads an audio file and returns the path to the audio time series Offset and duration are optional, in seconds. Be careful, you will never know the name of the song. """ y, sr = librosa.load(path=file_path, offset=offset, duration=duration) # stock y inside a csv file name = file_path.split("/")[-1].split(".")[0] + "_y" y_path = os.path.join(tempfile.gettempdir(), name + ".csv") np.savetxt(y_path, y, delimiter=";") D = librosa.stft(y) harmonics, percussion = librosa.decompose.hpss(D) # Save the harmonic and percussive components to separate files # name_harmonic = file_path.split("/")[-1].split(".")[0] + "_harmonic" # name_percussive = file_path.split("/")[-1].split(".")[0] + "_percussive" # harmonic_path = os.path.join(tempfile.gettempdir(), name_harmonic + ".csv") # percussive_path = os.path.join(tempfile.gettempdir(), name_percussive + ".csv") # np.savetxt(harmonic_path, harmonics, delimiter=";") # np.savetxt(percussive_path, percussion, delimiter=";") return { "y_path": y_path, # "y_harmonic_path": harmonic_path, # "y_percussive_path": percussive_path, }
  • Registration of the 'load' tool via FastMCP's @mcp.tool() decorator.
    @mcp.tool()
  • Input schema defined by function parameters: file_path (str), offset (float=0.0), duration (float=None); returns dict.
    def load( file_path: str, offset: float = 0.0, duration: float = None, ) -> dict:
  • The 'load' tool is listed in the analyze_audio prompt with its signature.
    "- load(file_path: str, offset: float = 0.0, duration: float = None) -> dict\n" "- tempo(path_audio_time_series_y: str, hop_length: int = 512, start_bpm: float = 120, " "std_bpm: float = 1.0, ac_size: float = 8.0, max_tempo: float = 320.0) -> float\n" "- chroma_cqt(path_audio_time_series_y: str, hop_length: int = 512, fmin: float = None, " "n_chroma: int = 12, n_octaves: int = 7) -> str\n" "- beat_track(path_audio_time_series_y: str, hop_length: int = 512, start_bpm: float = 120, " "tightness: int = 100, units: str = 'frames') -> dict\n" "- get_duration(path_audio_time_series_y: str) -> float\n" "- download_from_url(url: str) -> str\n" "- download_from_youtube(youtube_url: str) -> str\n" )

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/hugohow/mcp-music-analysis'

If you have feedback or need assistance with the MCP directory API, please join our Discord server