Skip to content

Instantly share code, notes, and snippets.

@mknz
Created February 28, 2023 16:28
Show Gist options
  • Save mknz/8fb841b6827f48f8163cf2baed21167e to your computer and use it in GitHub Desktop.
Save mknz/8fb841b6827f48f8163cf2baed21167e to your computer and use it in GitHub Desktop.
Download YouTube video, extract audio and convert it to whisper-cpp compatible wav
#!/bin/bash
WORKDIR=/tmp/whisper
rm -rf $WORKDIR
mkdir $WORKDIR
URL=\'$1\'
SAVEFILE=\'$WORKDIR/tmp.3gpp\'
python -c "from pytube import YouTube; YouTube($URL).streams.first().download(filename=$SAVEFILE)"
ffmpeg -i $WORKDIR/tmp.3gpp -ar 16000 -ac 1 -c:a pcm_s16le $WORKDIR/tmp.wav &> /dev/null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment