Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def bin_freqs(x, nbins): | |
| return ( | |
| x.T.reshape((-1, int(x.shape[0] / nbins))).mean(axis=-1).reshape((-1, nbins)).T | |
| ) | |
| def compact_freqs(x): | |
| return np.vstack( | |
| ( | |
| x[:16], |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def cirm(y, s, K=10, C=0.1, flat=True): | |
| y = librosa.core.stft(y.astype('float64'), 256, 64).astype('complex128') | |
| s = librosa.core.stft(s.astype('float64'), 256, 64).astype('complex128') | |
| mr = (np.real(y) * np.real(s) + np.imag(y) * np.imag(s))/(np.real(y)**2 + np.imag(y)**2) | |
| mi = (np.real(y) * np.imag(s) - np.imag(y) * np.real(s))/(np.real(y)**2 + np.imag(y)**2) | |
| m = mr + 1j * mi | |
| if flat: | |
| return m | |
| else: | |
| return K * ((1 - np.exp(-C * m))/(1 + np.exp(-C * m))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import librosa | |
| from scipy.signal import butter, lfilter | |
| SR = 8000 | |
| NFFT = 256 # change ~proportionally to SR | |
| def butter_bandpass(lowcut, highcut, fs, order=5): | |
| nyq = 0.5 * fs | |
| low = lowcut / nyq |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import requests | |
| import os | |
| url = 'http://' + os.environ['COLAB_TPU_ADDR'].split(':')[0] + ':8475/requestversion/2.2.0-dev20200311' | |
| resp = requests.post(url) | |
| print(resp) | |
| %pip install tf-nightly==2.2.0-dev20200311 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| if __name__ == '__main__': | |
| import dask.distributed | |
| client = dask.distributed.Client() | |
| queue = dask.distributed.Queue('queue1') | |
| def f(): | |
| return 42 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class PickleableCtypesFuncPtr: | |
| """A version of a ctypes._FuncPtr that can be pickled. The shared library | |
| must be available in the depickling environment. | |
| """ | |
| def __init__(self, dll_type, lib, name): | |
| self.__setstate__((dll_type, lib, name)) | |
| def __setstate__(self, state): | |
| self.state = state | |
| dll_type, lib, func = self.state |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Use libc in ctypes "PyDLL" mode, which prevents CPython from | |
| # releasing the GIL during procedure calls. | |
| _libc_name = ctypes.util.find_library("c") | |
| if _libc_name is None: | |
| raise RuntimeError("Cannot find libc") | |
| libc_py = ctypes.PyDLL(_libc_name) | |
| ... | |
| libc_py.usleep(...) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!doctype html> | |
| <script type="application/javascript"> | |
| const s = ` | |
| application/mp4 | |
| application/mp4; codecs=bogus | |
| application/octet-stream | |
| application/octet-stream; codecs='avc1.42E01E, mp4a.40.2' | |
| application/octet-stream; codecs='mp4a.40.2' | |
| application/octet-stream; codecs='theora, vorbis' | |
| application/octet-stream; codecs='vorbis' |