Spaces:
Running
Running
MCP ready
Browse files
app.py
CHANGED
|
@@ -143,9 +143,22 @@ def spectrogram_image_from_file(filename, max_volume: float = 50, power_for_imag
|
|
| 143 |
return spectrogram_image_from_wav(wav_bytes, max_volume=max_volume, power_for_image=power_for_image, ms_duration=length_in_ms)
|
| 144 |
|
| 145 |
def convert(audio):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 146 |
|
| 147 |
image = spectrogram_image_from_file(audio, 50)
|
| 148 |
|
| 149 |
return image
|
| 150 |
|
| 151 |
-
gr.Interface(fn=convert, inputs=[gr.Audio(sources=["upload"], type="filepath")], outputs=[gr.Image()]).launch()
|
|
|
|
| 143 |
return spectrogram_image_from_wav(wav_bytes, max_volume=max_volume, power_for_image=power_for_image, ms_duration=length_in_ms)
|
| 144 |
|
| 145 |
def convert(audio):
|
| 146 |
+
"""
|
| 147 |
+
Convert an uploaded audio file to a spectrogram image.
|
| 148 |
+
|
| 149 |
+
This function is the main entry point for the MCP interface.
|
| 150 |
+
|
| 151 |
+
Args:
|
| 152 |
+
audio: A file path to the uploaded audio file (MP3, WAV, etc.)
|
| 153 |
+
|
| 154 |
+
Returns:
|
| 155 |
+
A spectrogram image (PIL.Image) representing the waveform content
|
| 156 |
+
of the audio input, transformed into a visual format using mel-scaling
|
| 157 |
+
and power adjustments.
|
| 158 |
+
"""
|
| 159 |
|
| 160 |
image = spectrogram_image_from_file(audio, 50)
|
| 161 |
|
| 162 |
return image
|
| 163 |
|
| 164 |
+
gr.Interface(fn=convert, inputs=[gr.Audio(sources=["upload"], type="filepath")], outputs=[gr.Image()]).launch(ssr_mode=False, mcp_server=True)
|