{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from pathlib import Path\n", "\n", "repo_path = Path(\"/content/AudioSep\")\n", "if not repo_path.exists():\n", " !git clone https://github.com/Audio-AGI/AudioSep.git\n", "\n", "%cd /content/AudioSep" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "id": "pjIhw5ECS_3_" }, "outputs": [], "source": [ "!pip install torchlibrosa==0.1.0 gradio==3.47.1 gdown lightning transformers==4.28.1 ftfy braceexpand webdataset soundfile wget h5py" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "id": "t6h9KB3CcjBd" }, "outputs": [], "source": [ "checkpoints_dir = Path(\"checkpoint\")\n", "checkpoints_dir.mkdir(exist_ok=True)\n", "\n", "models = (\n", " (\n", " \"https://huggingface.co/spaces/badayvedat/AudioSep/resolve/main/checkpoint/audiosep_base_4M_steps.ckpt\",\n", " checkpoints_dir / \"audiosep_base_4M_steps.ckpt\"\n", " ),\n", " (\n", " \"https://huggingface.co/spaces/badayvedat/AudioSep/resolve/main/checkpoint/music_speech_audioset_epoch_15_esc_89.98.pt\",\n", " checkpoints_dir / \"music_speech_audioset_epoch_15_esc_89.98.pt\"\n", " )\n", ")\n", "\n", "for model_url, model_path in models:\n", " if not model_path.exists():\n", " !wget {model_url} -O {model_path}" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "id": "3uDrzCQyY58h" }, "outputs": [], "source": [ "!wget \"https://audio-agi.github.io/Separate-Anything-You-Describe/demos/exp31_water drops_mixture.wav\"" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "id": "0nr77CGXTwO1" }, "outputs": [], "source": [ "import torch\n", "from pipeline import build_audiosep, inference\n", "\n", "device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')\n", "\n", "model = build_audiosep(\n", " config_yaml='config/audiosep_base.yaml',\n", " checkpoint_path=str(models[0][1]),\n", " device=device)\n", "\n", "audio_file = 'exp31_water drops_mixture.wav'\n", "text = 'water drops'\n", "output_file='separated_audio.wav'\n", "\n", "# AudioSep processes the audio at 32 kHz sampling rate\n", "inference(model, audio_file, text, output_file, device)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "id": "kssOe0pbPSWp" }, "outputs": [], "source": [ "print(f\"The separated audio is saved to: '{output_file}' file.\")" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "id": "sl35U3dAR6KN" }, "outputs": [], "source": [] } ], "metadata": { "colab": { "provenance": [] }, "kernelspec": { "display_name": "Python 3", "name": "python3" }, "language_info": { "name": "python" } }, "nbformat": 4, "nbformat_minor": 0 }