File size: 1,218 Bytes
0bd62e5
1
{"cells": [{"cell_type": "markdown", "id": "302934307671667531413257853548643485645", "metadata": {}, "source": ["# Gradio Demo: waveform"]}, {"cell_type": "code", "execution_count": null, "id": "272996653310673477252411125948039410165", "metadata": {}, "outputs": [], "source": ["!pip install -q gradio "]}, {"cell_type": "code", "execution_count": null, "id": "288918539441861185822528903084949547379", "metadata": {}, "outputs": [], "source": ["import gradio as gr\n", "import random\n", "\n", "COLORS = [\n", "    [\"#ff0000\", \"#00ff00\"],\n", "    [\"#00ff00\", \"#0000ff\"],\n", "    [\"#0000ff\", \"#ff0000\"],\n", "]\n", "\n", "def audio_waveform(audio, image):\n", "    return (\n", "        audio,\n", "        gr.make_waveform(audio),\n", "        gr.make_waveform(audio, animate=True),\n", "        gr.make_waveform(audio, bg_image=image, bars_color=str(random.choice(COLORS))),\n", "    )\n", "\n", "gr.Interface(\n", "    audio_waveform,\n", "    inputs=[gr.Audio(), gr.Image(type=\"filepath\")],\n", "    outputs=[\n", "        gr.Audio(),\n", "        gr.Video(),\n", "        gr.Video(),\n", "        gr.Video(),\n", "    ],\n", ").launch()\n"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5}