gradio/demo/spectogram/run.ipynb
Archit-Kohli 921716f618
Fixed visibility issue for all notebooks on GitHub (#5917)
* fixed visibility error in notebooks in github

* Delete fixNotebooks.py

deleted script used to fix notebooks

* Update generate_notebooks.py

fixed a small bug that prevented visibility of notebooks in GitHub
2023-10-15 18:16:57 -07:00

1 line
1.1 KiB
Plaintext

{"cells": [{"cell_type": "markdown", "id": "302934307671667531413257853548643485645", "metadata": {}, "source": ["# Gradio Demo: spectogram"]}, {"cell_type": "code", "execution_count": null, "id": "272996653310673477252411125948039410165", "metadata": {}, "outputs": [], "source": ["!pip install -q gradio scipy numpy matplotlib"]}, {"cell_type": "code", "execution_count": null, "id": "288918539441861185822528903084949547379", "metadata": {}, "outputs": [], "source": ["import matplotlib.pyplot as plt\n", "import numpy as np\n", "from scipy import signal\n", "\n", "import gradio as gr\n", "\n", "\n", "def spectrogram(audio):\n", " sr, data = audio\n", " if len(data.shape) == 2:\n", " data = np.mean(data, axis=0)\n", " frequencies, times, spectrogram_data = signal.spectrogram(\n", " data, sr, window=\"hamming\"\n", " )\n", " plt.pcolormesh(times, frequencies, np.log10(spectrogram_data))\n", " return plt\n", "\n", "\n", "demo = gr.Interface(spectrogram, \"audio\", \"plot\")\n", "\n", "if __name__ == \"__main__\":\n", " demo.launch()\n"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5}