Skip to content

Instantly share code, notes, and snippets.

View willwade's full-sized avatar
🌏
Working on dasher and a lot of Ace hardware projects

will wade willwade

🌏
Working on dasher and a lot of Ace hardware projects
View GitHub Profile
@willwade
willwade / DotNetSpeech.py
Last active November 6, 2024 12:56
A very rough untested attempt at a .net driver for speech synth
import clr
import threading
import queue
import time
from System.Speech.Synthesis import SpeechSynthesizer, SpeakCompletedEventArgs
clr.AddReference("System.Speech")
class DotNetSpeech:
def __init__(self, proxy):
@willwade
willwade / build.bat
Created November 6, 2024 00:08
test nukita and mediapipe
@echo off
setlocal
rem Capture the Poetry environment path
for /f "delims=" %%i in ('poetry env info --path') do set venv_path=%%i
rem Construct the site-packages path
set site_packages=%venv_path%\Lib\site-packages
rem Convert the path to forward slashes for Nuitka compatibility
import comtypes.client
import winreg
class SAPI4Driver:
def __init__(self, proxy):
# Initialize the SAPI 4 VoiceText COM object
self._tts = comtypes.client.CreateObject("Speech.VoiceText")
self._proxy = proxy
self._speaking = False
self._stopping = False
import objc
from AVFoundation import AVSpeechSynthesizer, AVSpeechUtterance, AVSpeechSynthesisVoice, AVAudioEngine, AVAudioFile, AVAudioSession
from Foundation import NSURL, NSObject
class AVSpeechDriver(NSObject):
def __init__(self):
self._proxy = None
self._tts = None
self._audio_engine = AVAudioEngine.alloc().init()
self._audio_file = None
@willwade
willwade / joy2numpad.ahk
Created August 6, 2024 15:37
joystick 2 number pad. Use with mouse keys if you wo wish
; Initialize variables for joystick
JoyUp:: ; Joystick up
JoyDown:: ; Joystick down
JoyLeft:: ; Joystick left
JoyRight:: ; Joystick right
; Map joystick directions to numpad keys
JoyUp::
Send {Numpad8}
return
@willwade
willwade / Dockerfile
Created July 26, 2024 14:40
Test espeak with docker
# Use the official Python image as a base
FROM python:3.8-slim
# Set environment variables
ENV LANG C.UTF-8
ENV LC_ALL C.UTF-8
# Install dependencies
RUN apt-get update && apt-get install -y \
espeak-ng \
import sounddevice as sd
import time
import logging
import threading
import wave
from abc import ABC, abstractmethod
from typing import Any, List, Literal, Optional, Union, Dict, Callable
FileFormat = Union[Literal["wav"], Literal["mp3"]]
@willwade
willwade / macCapture.py
Last active April 28, 2024 17:10
capture keys - mac and Win code
from Quartz import *
from PyObjCTools.AppHelper import runConsoleEventLoop
def key_callback(proxy, type_, event, refcon):
# Get the key code
key_code = CGEventGetIntegerValueField(event, kCGKeyboardEventKeycode)
print("Key pressed:", key_code)
return event
def main():
import requests
# Azure subscription key and service region
subscription_key = 'YourAzureSubscriptionKey'
service_region = 'YourServiceRegion'
# Set up the TTS endpoint
tts_endpoint = f'https://{service_region}.tts.speech.microsoft.com/cognitiveservices/v1'
# Set up the headers for the HTTP request
@willwade
willwade / autocorrect.py
Last active February 2, 2024 07:57
AutoCorrect using OpenAI
from pynput import keyboard, mouse
from pynput.keyboard import Key, Controller as KeyboardController
import requests
import clipman
clipman.init()
keyboard_controller = KeyboardController()
text_buffer = []
def correct_text(text):