Skip to content

Instantly share code, notes, and snippets.

View yanyaoer's full-sized avatar

yanyaoer yanyaoer

View GitHub Profile
@yanyaoer
yanyaoer / 1.scribe.sh
Last active November 1, 2023 07:04
scribe.sh -- transcribe online video to subtitles
#!/usr/bin/env bash
url=$1
utc=$(date +%s)
whisper_bin=~/Projects/agi/whisper.cpp/main
whisper_model=~/projects/agi/whisper.cpp/models/ggml-large.bin
wav_file=/tmp/$utc.wav
yt-dlp $url -k -x --audio-format wav --postprocessor-args '-ar 16000 -ac 1' -o $wav_file
#ffmpeg -i "$url" -ar 16000 -ac 1 -c:a pcm_s16le $wav_file
@yanyaoer
yanyaoer / sh
Created July 25, 2023 06:39
test whisper.cpp with bilibili video
$ yt-dlp 'https://www.bilibili.com/video/BV15V411K7yE/'
$ ffmpeg -i INPUT.mp4 -ar 16000 -ac 1 -c:a pcm_s16le /tmp/output.wav
$ ~/P/a/whisper.cpp: ./main -m ./models/ggml-base.bin -f /tmp/output.wav -l zh
@yanyaoer
yanyaoer / httpbin.rs
Last active February 23, 2023 06:06
httpbin_rs
// cargo add serde --features derive
// cargo add serde_json
// cargo add reqwest --features json
// cargo add tokio --features full
pub struct Httpbin {
client: reqwest::Client,
token: String,
data: Option<serde_json::Value>,
}
@yanyaoer
yanyaoer / script-template.sh
Created December 16, 2020 01:19 — forked from m-radzikowski/script-template.sh
Minimal safe Bash script template - see the article with full description: https://betterdev.blog/minimal-safe-bash-script-template/
#!/usr/bin/env bash
set -Eeuo pipefail
trap cleanup SIGINT SIGTERM ERR EXIT
script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P)
usage() {
cat <<EOF
Usage: $(basename "${BASH_SOURCE[0]}") [-h] [-v] [-f] -p param_value arg1 [arg2...]
@yanyaoer
yanyaoer / sp.sh
Created July 30, 2020 06:57
spotify cli with web api
#! /bin/bash
client_id=
client_secret=
port=8888
redirect_uri=http%3A%2F%2Flocalhost%3A$port%2Fcallback
auth_endpoint=https://accounts.spotify.com/authorize/?response_type=code\&client_id=$client_id\&redirect_uri=$redirect_uri
tmp_code=/tmp/.sp_code
@yanyaoer
yanyaoer / userChrome.css
Last active February 4, 2020 10:26
firefox compact tabbar only icon
html#main-window {
--color-bg: #1e1f29;
--toolbar-bgcolor: var(--color-bg) !important;
--gap-between-tabs: 0px;
--margin-after-tab-list: 8x;
--margin-before-tab-list: 8px;
--tab-height: 32px;
--tab-icon: 16px;
--tabs-container-height: 85px;
@yanyaoer
yanyaoer / md2ex
Created March 2, 2012 03:30
markdown for v2ex content
// ==UserScript==
// @name markdown for v2ex content
// @namespace http://www.v2ex.com/
// @include http://www.v2ex.com/t/*
// ==/UserScript==
/*
* About = {
* source: 'http://webreflection.blogspot.com/2012/02/js1k-markdown.html',
* preview: 'http://www.v2ex.com/t/28444',
#!/usr/bin/env node
"use strict"
const exec = require('child_process').spawn;
const http = require('http');
const vm = require('vm');
const rl = require('readline');
console.log('=== I 💓 panda ==\n');
get_timestamp_by_object_id = (oid)->
#[ref]:https://github.com/justaprogrammer/ObjectId.js/blob/master/src/main/javascript/Objectid.js#L55
return Number('0x' + oid.substr(0, 8))*1000
import datetime
def parse_date(date_string, format='%Y-%m-%d', seg=','):
''' defualt date_string == 'yesterday'
available alias 'week','month','year' or timestr: '2013-0101'
relativedate = latest_parse_date or today
parse_date('2011-01-01')
=> datetime(2011,01,01)