Skip to content

Instantly share code, notes, and snippets.

@mknz
mknz / dl.sh
Created February 28, 2023 16:28
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
@mknz
mknz / rec.sh
Created February 28, 2023 16:27
Record audio, transcribe and copy to clipboard
#!/bin/bash
arecord -r 16000 -c 1 -f S16_LE -d 5 /tmp/tmp.wav &> /dev/null
./main -m ./models/ggml-base.bin -l en -f /tmp/tmp.wav -otxt -of /tmp/out &> /dev/null
python -c "import pyperclip; pyperclip.copy(open('/tmp/out.txt', 'r').read().replace('\n', ' ').strip())"
@mknz
mknz / kafka_gpt2.ipynb
Created July 27, 2022 18:54
kafka_gpt2.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mknz
mknz / nvim-terminal-edit.py
Last active January 21, 2017 11:01 — forked from bfredl/nvim-terminal-edit.py
Edit file in host Neovim instance from a :terminal buffer
#!/usr/bin/env python
"""Edit a file in the host nvim instance."""
from __future__ import print_function
import os
import sys
from neovim import attach
args = sys.argv[1:]
if not args: