Skip to content

Instantly share code, notes, and snippets.

@ProjectEli
ProjectEli / gamma_eqn.m
Created May 9, 2021 09:52
[MATLAB] RGB gamma interpolation 3D
close all; clear; clc;
color_raw=0:0.05:1;
RGB_Lift_raw=(0:0.05:2).';
Ncolor = length(color_raw); vcolor=ones(1,Ncolor);
NLift = length(RGB_Lift_raw); vLift = ones(NLift,1);
color = vLift * color_raw;
RGB_Lift = RGB_Lift_raw * vcolor;
@ProjectEli
ProjectEli / redcolor.py
Created May 9, 2021 09:48
draw red line on windows screen
import win32gui
import win32api
dc = win32gui.GetDC(0)
red = win32api.RGB(255, 0, 0)
x = 3030
y= 100
# for k in range(100):
# win32gui.SetPixel(dc, x, y+k, red) # draw red at 0,0
@ProjectEli
ProjectEli / ExcelControl.py
Created May 5, 2021 17:36
Simple Microsoft Excel controller with win32com.client
import win32com.client, win32ui
class ExcelControl:
def __init__(self):
# Initialize Excel app
self.excel = win32com.client.Dispatch("Excel.Application")
self.excel.Visible=True
def Openfile(self):
# open file
@ProjectEli
ProjectEli / VoiceRecognition.py
Created May 5, 2021 17:33
Voice recognition with speech_recognition and google speech to text API
import speech_recognition
recognizer = speech_recognition.Recognizer()
with speech_recognition.Microphone() as src:
try:
audio = recognizer.adjust_for_ambient_noise(src)
print("Threshold Value After calibration:" + str(recognizer.energy_threshold))
print("Please speak:")
audio = recognizer.listen(src)
@ProjectEli
ProjectEli / recordvoice.py
Created May 5, 2021 17:31
Record voice and save to wav file (PCM)
import speech_recognition
with speech_recognition.Microphone() as src:
audio = speech_recognition.Recognizer().listen(src)
print("Listening...")
with open('recordedaudio.wav','wb') as f:
f.write(audio.get_wav_data())