diff --git a/notebook/yohane.ipynb b/notebook/yohane.ipynb index 1edb63a6..1ad7d631 100644 --- a/notebook/yohane.ipynb +++ b/notebook/yohane.ipynb @@ -10,7 +10,7 @@ "\n", "---\n", "\n", - "Please click the badge below to open the latest version of the notebook:\n", + "Click the badge below to open the latest version of the notebook:\n", "\n", "\n", " \"Open\n", @@ -18,7 +18,7 @@ "\n", "---\n", "\n", - "**Before proceeding, change your runtime type to GPU (Toolbar > Runtime > Change runtime type > T4 GPU).**\n" + "**Before proceeding, change your runtime type to T4 GPU (Toolbar > Runtime > Change runtime type > T4 GPU).**\n" ] }, { @@ -61,17 +61,12 @@ "uv pip install --system git+$REPO_URL@$LATEST_TAG" ] }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Restart the runtime if prompted." - ] - }, { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "id": "l8b80QOHWjHQ" + }, "outputs": [], "source": [ "!pip3 show yohane" @@ -85,7 +80,7 @@ "source": [ "## Parameters\n", "\n", - "The next cells will set the parameters for the yohane pipeline." + "The next cells will set the parameters for the yohane pipeline.\n" ] }, { @@ -96,16 +91,55 @@ }, "outputs": [], "source": [ - "# @title Song { display-mode: \"form\" }\n", - "# @markdown Run this cell and use the form below to **upload your song**.\n", + "# @title Song Upload\n", + "# @markdown Run this cell to **upload your song** using the form below.\n", "#\n", - "# @markdown It can be either an audio or video file.\n", + "# @markdown Accepted formats: audio or video files.\n", "#\n", - "# @markdown **If it fails, try another browser or upload your file manually in the Files section of the left side bar.**\n", + "# @markdown **Note**: If the upload fails, try using a different browser or upload the file manually in the Files section on the left sidebar.\n", "\n", "from google.colab import files\n", "\n", - "files.upload_file(\"song\")" + "upload = files.upload()\n", + "for file in upload:\n", + " song_filename = file\n", + " break" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "2Kg99ykCWjHR" + }, + "outputs": [], + "source": [ + "# @markdown **If you uploaded the file manually, enter the song filename here.**\n", + "\n", + "song_filename_override = \"\" # @param {type:\"string\"}\n", + "song_filename = song_filename_override or song_filename" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "sp0sHZPCWjHS" + }, + "outputs": [], + "source": [ + "# @title Song Download (yt-dlp)\n", + "# @markdown **Enter** the remote URL below, **then execute** this cell to download the song.\n", + "\n", + "!uv pip install -q --system yt-dlp[default]\n", + "\n", + "from yt_dlp import YoutubeDL\n", + "\n", + "song_url = \"\" # @param {type:\"string\"}\n", + "\n", + "with YoutubeDL({\"format_sort\": [\"res:1080\", \"vcodec:h264\", \"acodec:aac\"]}) as ydl:\n", + " info = ydl.extract_info(song_url)\n", + " song_filename = ydl.prepare_filename(info)" ] }, { @@ -117,7 +151,7 @@ "outputs": [], "source": [ "# @title Lyrics { display-mode: \"form\", run: \"auto\" }\n", - "# @markdown Run this cell and **paste your lyrics** in the box below.\n", + "# @markdown Run this cell, then **paste your lyrics** in the box below.\n", "\n", "from IPython.display import display\n", "from ipywidgets import Layout, Textarea\n", @@ -135,10 +169,10 @@ "outputs": [], "source": [ "# @title Source Separator { display-mode: \"form\", run: \"auto\" }\n", - "# @markdown Run this cell and select the desired **Source Separator**:\n", - "# @markdown - `VocalRemoverSeparator` is based on the [`vocal-remover`](https://github.com/tsurumeso/vocal-remover) library. Take this one if you don't know what to choose.\n", - "# @markdown - `HybridDemucsSeparator` uses `torchaudio`'s [Hybrid Demucs model](https://pytorch.org/audio/2.1.0/tutorials/hybrid_demucs_tutorial.html) which is faster but less aggressive.\n", - "# @markdown - `None` if you don't care and want to skip the vocals extraction step.\n", + "# @markdown Run this cell and select a **Source Separator**:\n", + "# @markdown - **VocalRemoverSeparator**: Based on the [`vocal-remover`](https://github.com/tsurumeso/vocal-remover) library. Choose this if you're unsure.\n", + "# @markdown - **HybridDemucsSeparator**: Uses `torchaudio`'s [Hybrid Demucs model](https://pytorch.org/audio/2.1.0/tutorials/hybrid_demucs_tutorial.html), which is faster but less aggressive.\n", + "# @markdown - **None**: Skips the vocal extraction step if it's not needed.\n", "\n", "from yohane.audio import VocalRemoverSeparator, HybridDemucsSeparator\n", "\n", @@ -166,7 +200,6 @@ "outputs": [], "source": [ "# @title Generate\n", - "# @markdown **Replace the song filename here if you uploaded it manually**\n", "\n", "import logging\n", "from pathlib import Path\n", @@ -174,10 +207,10 @@ "\n", "logging.basicConfig(level=\"INFO\", force=True)\n", "\n", - "song_filename = \"song\" # @param {type:\"string\"}\n", + "song_path = Path(song_filename)\n", "\n", "yohane = Yohane(separator)\n", - "yohane.load_song(Path(song_filename))\n", + "yohane.load_song(song_path)\n", "yohane.load_lyrics(lyrics_area.value)\n", "yohane.extract_vocals()\n", "yohane.force_align()\n", @@ -192,12 +225,26 @@ }, "outputs": [], "source": [ - "# @title Save and download\n", + "# @title Save and download karaoke file\n", "\n", "from google.colab import files\n", "\n", - "subs.save(\"karaoke.ass\")\n", - "files.download(\"karaoke.ass\")" + "subs_path = song_path.with_suffix('.ass')\n", + "subs.save(subs_path)\n", + "files.download(subs_path)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "Qy3iC4WFYuc9" + }, + "outputs": [], + "source": [ + "# @title Download song file\n", + "\n", + "files.download(song_path)" ] }, { @@ -206,7 +253,7 @@ "id": "YVB0lS8ENJvo" }, "source": [ - "The karaoke should have been downloaded. If not, open Files in the left side bar and look for `karaoke.ass`.\n", + "The karaoke file should have downloaded. If not, open Files in the left sidebar and look for `*.ass`.\n", "\n", "**Next recommended steps in Aegisub:**\n", "\n", @@ -231,12 +278,13 @@ "provenance": [] }, "kernelspec": { - "display_name": "Python 3", + "display_name": ".venv", + "language": "python", "name": "python3" }, "language_info": { "name": "python", - "version": "3.11.6" + "version": "3.11.10" } }, "nbformat": 4,