Skip to content

Instantly share code, notes, and snippets.

View skittleson's full-sized avatar

Spencer Kittleson skittleson

View GitHub Profile
import wsl_shell
import simpleaudio as sa
import os
class GenerativeAudioService:
"""
Create and manage playback with text to speech audio files
"""
@skittleson
skittleson / scrape_who_is_hiring.py
Created September 29, 2023 05:23
Who Is Hiring
from bs4 import BeautifulSoup
import requests
import re
if __name__ == '__main__':
html = requests.get(r'https://news.ycombinator.com/item?id=37351667&p=1')
soup = BeautifulSoup(html.text,'html.parser')
all_spans = soup.find_all('span', class_='commtext')
for span in all_spans:
comment_content = span.text.strip()
@skittleson
skittleson / record.cs
Created July 6, 2023 16:55
Record ffmpeg
public static async Task RecordAsync(Stream stream, string microphone, CancellationToken cancellationToken, Action<double> detectedSilenceCallback = null)
{
// do this to get audio device with a mic
// ffmpeg -list_devices true -f dshow -i dummy
// pick one then add it to the audio device
// ffmpeg -f dshow -i audio="Microphone (HD Pro Webcam C920)" -ar 16000 output.wav
using var gracefulCts = new CancellationTokenSource();
try
{
// ffmpeg -f dshow -i audio="Microphone Array (Intel® Smart Sound Technology for Digital Microphones)" -ar 16000 -preset ultrafast -tune zerolatency -b 900k -f mpegts udp://127.0.0.1:9876
@skittleson
skittleson / dslr_process_files.py
Created April 16, 2023 21:15
Process files from a DSLR camera
import shutil
import wmi
import os
from time import strftime, localtime
def copy(device_id):
""" Copy all files in camera directory to users directoy for human processing
"""
# bug only works for Windows
src = os.path.join(device_id, "\\", "DCIM", "100MSDCF")
@skittleson
skittleson / gpsPoller.js
Last active June 19, 2023 17:05
Get GPS data from usb device and print it to the screen
const GPS = require("gps");
const { SerialPort, ReadlineParser } = require('serialport')
const gps = new GPS;
// Use a `\r\n` as a line terminator
const parser = new ReadlineParser({
delimiter: '\n',
})
const port = new SerialPort({
@skittleson
skittleson / mppt.js
Created February 23, 2023 06:39
Basic MPPT for JS
setInterval(function() {
// Define the parameters
var vpv = 18; // The solar panel's output voltage
var ipv = 2; // The solar panel's output current
var vbat = 14.8; // The battery's voltage (4-series lithium polymer battery)
var ibat = 0; // The battery's current
var vmax = 20; // The maximum power voltage of the solar panel
var imax = 2.5; // The maximum power current of the solar panel
var max_vbat = 16.8; // Maximum voltage of the 4-series lithium polymer battery
var min_vbat = 12.0; // Minimum voltage of the 4-series lithium polymer battery
@skittleson
skittleson / method-example.cs
Last active April 26, 2023 19:08
Cross platform audio player in dotnet
// I've used a lot of libs including the popular ones for dotnet such as NAudio but all seem to be overly complicated or not cross platform.
// 1. install ffplay on your platform. for Windows `choco install ffplay`. Debian `apt install ffmpeg`.
// 2. install nuget pkg `CliWrap`
// 3. send your audio stream to the method.
public static async Task PlayAsync(Stream stream, CancellationToken cancellationToken)
{
var result = await Cli.Wrap("ffplay")
.WithStandardInputPipe(PipeSource.FromStream(stream))
.WithArguments($"-autoexit -nodisp -hide_banner -loglevel error -fs -")
@skittleson
skittleson / pi-router.md
Last active January 9, 2023 04:27
Pi Router Steps
@skittleson
skittleson / tasmotaWaterPump.sh
Last active January 1, 2022 23:09
Tasmota Water Pump
Rule1 on power1#state=1 do backlog RuleTimer2 30; counter1 +1 endon on Rules#Timer=2 do power1 off endon
Rule1 on
Timer1 {"Enable":1,"Time":"4:00","Window":15,"Days":"SMTWTFS","Repeat":1,"Output":1,"Action":1}
Timers on
Timezone -8
PowerOnState 0
@skittleson
skittleson / tempRules.md
Last active March 28, 2022 01:22
Temp Control a Fridge