Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Pranav Natekar pranav6670

🎯
Focusing
View GitHub Profile
@pranav6670
pranav6670 / autoDet_test.py
Last active Jul 27, 2020
Test Arduino autoDetect with blink example.
View autoDet_test.py
import pyfirmata
import time
import serial.tools.list_ports
ports = list(serial.tools.list_ports.comports())
Arduino_ports = []
for p in ports:
if 'Arduino' in p.description:
@pranav6670
pranav6670 / detectArduino.py
Created Jul 27, 2020
Detect arduino connected to any of ports.
View detectArduino.py
import serial.tools.list_ports
ports = list(serial.tools.list_ports.comports())
Arduino_ports = []
for p in ports:
if 'Arduino' in p.description:
Arduino_ports.append(p)
print("Board detected at")
if len(Arduino_ports) == 0:
print("no Arduino board detected")
@pranav6670
pranav6670 / model.py
Last active Aug 18, 2019
Audio Classification Model
View model.py
def conv_model():
model = Sequential()
model.add(Conv2D(16, (3, 3), activation='relu', strides=(1, 1),
padding='same', input_shape=input_shape))
model.add(Conv2D(32, (3, 3), activation='relu', strides=(1,1),
padding='same'))
model.add(Conv2D(64, (3, 3), activation='relu', strides=(1,1),
padding='same'))
model.add(Conv2D(128, (3, 3), activation='relu', strides=(1,1),
padding='same'))
@pranav6670
pranav6670 / preprocess.py
Last active Aug 18, 2019
A envelope detection to downsample and clean audio data
View preprocess.py
def envelope(y, rate, threshold):
mask = []
y = pd.Series(y).apply(np.abs)
y_mean = y.rolling(window=int(rate/10), min_periods=1, center=True).mean()
for mean in y_mean:
if mean > threshold:
mask.append(True)
else:
mask.append(False)
return mask
@pranav6670
pranav6670 / recordaudio_realtime.py
Last active Aug 18, 2019
Record audio using PyAudio in real-time
View recordaudio_realtime.py
self.FORMAT = pyaudio.paInt16
self.CHANNELS = 1
self.RATE = 44100
self.CHUNK = 1024
self.WAVE_OUTPUT_FILENAME = "file.wav"
self.RECORD_SECONDS = 20
def record(self):
self.audio = pyaudio.PyAudio()
# start Recording
You can’t perform that action at this time.