Skip to content

Instantly share code, notes, and snippets.

import numpy as np
import matplotlib.pylab as plt
f_sample = 22050.
signal = np.sin(2. * np.pi * 20. * np.arange(0, 2., 1/f_sample))
plt.plot(signal);
def frame(x, n_window, n_hop):
n = x.shape[0]
n_frames = 1 + int(np.floor((n - n_window) / n_hop))
@russellizadi
russellizadi / Parseval_theorem.py
Created January 26, 2021 07:45
Parseval's theorem
import numpy as np
import matplotlib.pylab as plt
f_sample = 22050.
signal = np.sin(2. * np.pi * 20. * np.arange(0, 2., 1/f_sample))
plt.plot(signal);
def frame(x, n_window, n_hop):
n = x.shape[0]
n_frames = 1 + int(np.floor((n - n_window) / n_hop))
@russellizadi
russellizadi / project1_solution.ipynb
Last active September 9, 2020 19:39
project1_solution.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
# x^y mod p
def power(x, y, p):
res = 1
x = x % p
while (y > 0):
if (y & 1):
res = (res * x) % p
y = y >> 1
x = (x * x) % p
return res
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.axes_grid1 import make_axes_locatable
ax = plt.subplot()
divider = make_axes_locatable(ax)
cax = divider.append_axes("right", size = "5%", pad = 0.05)
im = ax.imshow(x)
plt.colorbar(im, cax = cax)
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.axes_grid1 import make_axes_locatable
fig = plt.figure(1, figsize=(17, 17))
ax = fig.add_subplot(1, 2, 1)
divider = make_axes_locatable(ax)
cax = divider.append_axes("right", size = "5%", pad = 0.05)
im = ax.imshow(x1)
import os
from pydub import AudioSegment
from pydub.utils import mediainfo
path_flacs = '/home/russell/Documents/audiobooks/Educated_ A Memoir by Tara Westover-20190704T203807Z-001/Educated_ A Memoir by Tara Westover/FLAC'
path_mp3s = 'MP3'
path_cover = '/home/russell/Documents/audiobooks/Educated_ A Memoir by Tara Westover-20190704T203807Z-001/Educated_ A Memoir by Tara Westover/Educated_ A Memoir by Tara Westover.jpg'
def make_dir(path):
if not os.path.exists(path):
import numpy as np
# n is batch size; d_in is input dimension;
# h is hidden dimension; d_out is output dimension.
n, d_in, d_h, d_out = 64, 1000, 100, 10
# Create random input and output data
x = np.random.randn(n, d_in)
y = np.random.randn(n, d_out)
@russellizadi
russellizadi / convolutional_neural_network.py
Created April 30, 2018 02:16
convolutional neural network
import tensorflow as tf
import numpy as np
from datasets import mnist as dataset
tf.reset_default_graph()
class Params:
def __init__(self):
self.experiment = 'calssification'
def model(self):
@russellizadi
russellizadi / convolutional_neural_network.py
Created April 29, 2018 05:25
convolutional neural network
import tensorflow as tf
import numpy as np
from datasets import mnist as dataset
tf.reset_default_graph()
class Params:
def __init__(self):
self.dataset = 'dataset_fn1'
def model(self):