Skip to content

Instantly share code, notes, and snippets.

Rohith Gandhi G grohith327

Block or report user

Report or block grohith327

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View predict_perform.py
import pyaudio
import wave
from keras.models import load_model
import librosa
import numpy as np
import warnings
import osascript
import webbrowser
import os
import cv2
View picture.py
import cv2
cam = cv2.VideoCapture(0)
cv2.namedWindow("take a picture")
img_counter = 0
while True:
ret, frame = cam.read()
cv2.imshow("test", frame)
if not ret:
View Open_Google.py
import webbrowser
webbrowser.open('http://google.com')
View Increase_Volume.py
import osascript
vol = osascript.osascript('get volume settings')
cur_vol = int(vol[1].split(':')[1].split(',')[0])
cur_vol = cur_vol + 20
if(cur_vol > 100):
cur_vol = 100
osascript.osascript("set volume output volume "+str(cur_vol))
View Decrease_volume.py
import osascript
vol = osascript.osascript('get volume settings')
cur_vol = int(vol[1].split(':')[1].split(',')[0])
cur_vol = cur_vol - 20
if(cur_vol < 0):
cur_vol = 0
osascript.osascript("set volume output volume "+str(cur_vol))
View Train.py
@tf.function
def train_step(images, labels):
with tf.GradientTape() as tape:
predictions = model(images)
loss = loss_object(labels, predictions)
gradients = tape.gradient(loss, model.trainable_variables)
optimizer.apply_gradients(zip(gradients, model.trainable_variables))
train_loss(loss)
train_accuracy(labels, predictions)
View CNN.py
import tensorflow as tf
from tensorflow.keras.layers import Dense, Flatten, Conv2D, MaxPool2D, Dropout
# Create training and testing datasets from tensors
train_ds = tf.data.Dataset.from_tensor_slices((X_train, y_train)).batch(1)
test_ds = tf.data.Dataset.from_tensor_slices((X_test, y_test)).batch(1)
# CNN Model
class Command(Model):
def __init__(self):
View shuffle_split.py
from sklearn.utils import shuffle
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import OneHotEncoder
enc = OneHotEncoder()
y_data = enc.fit_transform(y_data).toarray()
x_data, y_data = shuffle(x_data, y_data)
X_train, X_test, y_train, y_test = train_test_split(x_data, y_data, test_size=0.2,stratify=y_data,random_state=42)
X_train = X_train.reshape((-1,1025,87,1))
View spectrogram.py
import librosa
import matplotlib.pyplot as plt
import numpy as np
import librosa.display
data, sr = librosa.load('Dataset/decrease_volume/1.wav')
D = np.abs(librosa.stft(data))
plt.figure(figsize=(20,8))
librosa.display.specshow(librosa.amplitude_to_db(D,ref=np.max),y_axis='log', x_axis='time')
plt.title('Spectrogram')
You can’t perform that action at this time.