Skip to content

Instantly share code, notes, and snippets.

@mill1000
mill1000 / transcribe.py
Last active April 8, 2023 22:43
Bulk audio file transcription using Whisper.
#!/usr/bin/env python3
import whisper
import argparse
import os
import math
import datetime
import sys
if __name__ == "__main__":
# Tucker's preferred style
#AlignConsecutiveAssignments : Consecutive
#AlignConsecutiveDeclarations: Consecutive
AlignConsecutiveBitFields: Consecutive
AlignConsecutiveMacros: Consecutive
AllowShortIfStatementsOnASingleLine: false
BreakBeforeBraces: Allman
ColumnLimit: 0
ContinuationIndentWidth: 2
IndentCaseLabels: true
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# If not running interactively, don't do anything
case $- in
*i*) ;;
*) return;;
esac
@mill1000
mill1000 / ntpviz.service
Last active April 17, 2022 15:57
Scripts to generate NTP Visualizations and pruning old stats files.
[Unit]
Description=Generate ntpviz webpage and plots
Documentation=man:ntpviz(1)
ConditionACPower=true
[Service]
User=ntp
Group=ntp
Type=oneshot
ExecStart=/usr/local/bin/ntpviz --name %H -d /var/log.hdd/ntpstats/ -o /var/www/ntpviz
@mill1000
mill1000 / git_editor
Last active October 1, 2021 19:57
Use VScode as git editor when available otherwise fallback to vim. Good for remote development via VScode.
#! /bin/bash
# Put in path and make executable
# Configure with git config --global core.editor git_editor
if type code 2> /dev/null; then
code --wait $*
else
vim $*
fi
@mill1000
mill1000 / audio_custom.js
Last active May 10, 2023 04:00
Custom Gerbera Import Scripts
// Helper to access first element of an array if it exists
function get(item, fallback) {
return (item && item[0]) || fallback;
}
// Custom audio import script
function addAudioCustom(obj) {
var title = get(obj.metaData[M_TITLE], obj.title);
var artist = get(obj.metaData[M_ARTIST], "Unknown");
var album = get(obj.metaData[M_ALBUM], "Unknown");
@mill1000
mill1000 / log.h
Created March 9, 2021 18:44
Simple ESP32 log wrapper that adds function name and line number to output
#ifndef __LOG__
#define __LOG__
#include "esp_log.h"
#define __FORMAT(FORMAT) "(%s:%d) " FORMAT
#define LOGD(TAG, FORMAT, ...) ESP_LOGD(TAG, __FORMAT(FORMAT), __func__, __LINE__, ##__VA_ARGS__)
#define LOGI(TAG, FORMAT, ...) ESP_LOGI(TAG, __FORMAT(FORMAT), __func__, __LINE__, ##__VA_ARGS__)
#define LOGW(TAG, FORMAT, ...) ESP_LOGW(TAG, __FORMAT(FORMAT), __func__, __LINE__, ##__VA_ARGS__)
@mill1000
mill1000 / README.md
Last active February 20, 2023 09:03
PPS-GPIO on Rock64 with Armbian legacy (4.4.X) kernel

PPS-GPIO on Rock64 with Armbian legacy (4.4.X) kernel

About

This gist covers how to enable PPS input via GPIO for Rock64 SBCs running Armbian legacy (4.4.X) kernels. It may also be applicable to Pine64 SBCs and other kernel versions but I have not personally tested them.

This gist will not cover configuring ntpd or gpsd to utilize the PPS signal, only enabling pps-gpio via modifying the device tree. For help configuring ntpd or gpsd I recommend the links under Motivation

Motivation

A PPS (Pulse Per Second) signal allows a time server to improve its clock accuracy and therefore achieve Stratum 1 status. Typically a PPS signal is provided via a GPS receiver attached to the server. The GPS receiver also provides a coarse time via USB or serial connection.

@mill1000
mill1000 / raspbianmonitor.sh
Created January 25, 2020 16:56
raspibanmonitor - Raspberry Pi 3 Monitor Script
#!/bin/bash
# Continuously queries RPi3 GPU for temperature, clock rates and throttled status
# Original from https://www.raspberrypi.org/forums/viewtopic.php?t=244320
echo -e "Time Temp CPU Core Health Vcore"
while true ; do
Temp=$(vcgencmd measure_temp | cut -f2 -d=)
Clockspeed=$(vcgencmd measure_clock arm | awk -F"=" '{printf ("%0.0f",$2/1000000); }' )
Corespeed=$(vcgencmd measure_clock core | awk -F"=" '{printf ("%0.0f",$2/1000000); }' )
Health=$(vcgencmd get_throttled | awk -F"=" '{printf("0x%08x\n",$2)}')
CoreVolt=$(vcgencmd measure_volts | cut -f2 -d=)
@mill1000
mill1000 / README.md
Last active July 5, 2024 08:18
Headless A2DP Audio Streaming on Raspbian Stretch

About

This gist will show how to setup Raspbian Stretch as a headless Bluetooth A2DP audio sink. This will allow your phone, laptop or other Bluetooth device to play audio wirelessly through a Rasperry Pi.

Motivation

A quick search will turn up a plethora of tutorials on setting up A2DP on the Raspberry Pi. However, I felt this gist was necessary because this solution is:

  • Automatic & Headless - Once setup, the system is entirely automatic. No user iteration is required to pair, connect or start playback. Therefore the Raspberry Pi can be run headless.
  • Simple - This solution has few dependencies, readily available packages and minimal configuration.
  • Up to date - As of December 2017. Written for Raspbian Stretch & Bluez 5.43

Prerequisites