Skip to content

Instantly share code, notes, and snippets.

@tlk
Last active February 13, 2020 23:42
Show Gist options
  • Select an option

  • Save tlk/e4872f9dd8a418a29966c4dafc2664f2 to your computer and use it in GitHub Desktop.

Select an option

Save tlk/e4872f9dd8a418a29966c4dafc2664f2 to your computer and use it in GitHub Desktop.
youtube-spleeter.ipynb
Display the source blob
Display the rendered blob
Raw
{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"name": "youtube-spleeter.ipynb",
"provenance": [],
"collapsed_sections": [],
"include_colab_link": true
},
"kernelspec": {
"display_name": "Python 3",
"name": "python3"
}
},
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "view-in-github",
"colab_type": "text"
},
"source": [
"<a href=\"https://colab.research.google.com/gist/tlk/e4872f9dd8a418a29966c4dafc2664f2/youtube-spleeter.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
]
},
{
"cell_type": "markdown",
"metadata": {
"colab_type": "text",
"id": "K6mcSc0mmp3i"
},
"source": [
"# Install spleeter"
]
},
{
"cell_type": "code",
"metadata": {
"colab_type": "code",
"id": "f8Brdfh6mzEz",
"colab": {}
},
"source": [
"!apt install ffmpeg"
],
"execution_count": 0,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"colab_type": "code",
"id": "V_6Ram1lmc1F",
"colab": {}
},
"source": [
"pip install spleeter"
],
"execution_count": 0,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"colab_type": "code",
"id": "W0LktyMypXqE",
"colab": {}
},
"source": [
"from IPython.display import Audio"
],
"execution_count": 0,
"outputs": []
},
{
"cell_type": "markdown",
"metadata": {
"id": "HJeBgLJngNY3",
"colab_type": "text"
},
"source": [
"# Download source material"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "Ae2901ptmPEj",
"colab_type": "text"
},
"source": [
"* Copy this URL: https://www.youtube.com/watch?v=06cYf5LHpYQ\n",
"* Paste it into https://en.savefrom.net/1-youtube-downloader/\n",
"* Right-click the download button on savefrom.net and copy the link\n",
"* Edit the command below and replace the URL"
]
},
{
"cell_type": "code",
"metadata": {
"id": "n36m4TgcgRaW",
"colab_type": "code",
"colab": {}
},
"source": [
"!wget -O video.mp4 \"https://r2---sn-p5qs7nee.googlevideo.com/videoplayback?expire=1581653245&ei=nchFXuSYOe-LhwazpZfoBg&ip=70.169.149.231&id=o-ADB_vCfgp_GDhF7jWmeb-zrE3YO5ntdoNARxkmYRQ-76&itag=22&source=youtube&requiressl=yes&mm=31%2C26&mn=sn-p5qs7nee%2Csn-ab5szn76&ms=au%2Conr&mv=m&mvi=1&pl=19&initcwndbps=2106250&vprv=1&mime=video%2Fmp4&ratebypass=yes&dur=191.169&lmt=1555421840600256&mt=1581631558&fvip=2&fexp=23842630&c=WEB&txp=5535432&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Cvprv%2Cmime%2Cratebypass%2Cdur%2Clmt&lsparams=mm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lsig=AHylml4wRQIgE_8qb6gVsD5TPokZro_rt_KS8kUA7kAPFtWZ8DdslCUCIQDplz7oqj4ITRvksNGBjsKN_F5nzYqo3aRnqC-UOBNoqw%3D%3D&sig=ALgxI2wwRQIgNFaDhjnvauGSWCb-JRI99yDRQlTXSg0PwJ2oxfB8w34CIQDMbKDAQ3ZLAx_6lBazHtJ1t360i6ZI6pfCJTS_WAiZVw%3D%3D&contentlength=10765100&video_id=0pLCDnbBEk0\""
],
"execution_count": 0,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "L8Fm9ILInJNy",
"colab_type": "code",
"colab": {}
},
"source": [
"!ffmpeg -i video.mp4 audio_example.mp3"
],
"execution_count": 0,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "Qn6-hGsGsJqs",
"colab_type": "code",
"colab": {}
},
"source": [
"Audio('audio_example.mp3')"
],
"execution_count": 0,
"outputs": []
},
{
"cell_type": "markdown",
"metadata": {
"colab_type": "text",
"id": "afbcUSken16L"
},
"source": [
"# Separate audio into vocals and accompaniment"
]
},
{
"cell_type": "code",
"metadata": {
"colab_type": "code",
"id": "dGL-k5xxoKbu",
"colab": {}
},
"source": [
"!spleeter separate -i audio_example.mp3 -p spleeter:2stems -o output/"
],
"execution_count": 0,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "ELSjwB_bsbM_",
"colab_type": "code",
"colab": {}
},
"source": [
"!ffmpeg -i output/audio_example/vocals.wav output/audio_example/vocals.mp3\n",
"!ffmpeg -i output/audio_example/accompaniment.wav output/audio_example/accompaniment.mp3"
],
"execution_count": 0,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"colab_type": "code",
"id": "IDuPWcAMoZP_",
"colab": {}
},
"source": [
"!ls -la output/audio_example"
],
"execution_count": 0,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"colab_type": "code",
"id": "e7CHpyiloxrk",
"colab": {}
},
"source": [
"Audio('output/audio_example/vocals.mp3')"
],
"execution_count": 0,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"colab_type": "code",
"id": "ibXd-WCTpT0w",
"colab": {}
},
"source": [
"Audio('output/audio_example/accompaniment.mp3')"
],
"execution_count": 0,
"outputs": []
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment