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
# !/usr/bin/python | |
import os | |
import shutil | |
folder_path = "/Users/cobanov/Downloads/audio_files/" | |
dst_folder = "destionat_path" | |
extension = (".mp3", ".mp4") # has to be tuple | |
for root, dirs, files in os.walk(folder_path, topdown=False): |
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
{ | |
"0": "\ud83d\udc69\u200d\ud83d\udc69\u200d\ud83d\udc67\u200d\ud83d\udc67", | |
"1": "\ud83d\udc69\u200d\ud83d\udc69\u200d\ud83d\udc67\u200d\ud83d\udc66", | |
"2": "\ud83d\udc69\u200d\ud83d\udc69\u200d\ud83d\udc66\u200d\ud83d\udc66", | |
"3": "\ud83d\udc68\u200d\ud83d\udc69\u200d\ud83d\udc67\u200d\ud83d\udc67", | |
"4": "\ud83d\udc68\u200d\ud83d\udc69\u200d\ud83d\udc67\u200d\ud83d\udc66", | |
"5": "\ud83d\udc68\u200d\ud83d\udc69\u200d\ud83d\udc66\u200d\ud83d\udc66", | |
"6": "\ud83d\udc68\u200d\ud83d\udc68\u200d\ud83d\udc67\u200d\ud83d\udc67", | |
"7": "\ud83d\udc68\u200d\ud83d\udc68\u200d\ud83d\udc67\u200d\ud83d\udc66", | |
"8": "\ud83d\udc68\u200d\ud83d\udc68\u200d\ud83d\udc66\u200d\ud83d\udc66", |
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 | |
import numpy as np | |
from PIL import Image | |
import soundfile as sf | |
def image_to_audio(image, sr=22050, n_fft=2048, hop_length=512, top_db=80): | |
"""Converts spectrogram to audio. | |
Args: |
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 numpy as np | |
import cv2 | |
import pickle | |
from shapely.geometry import Polygon | |
import matplotlib.pyplot as plt | |
def angle_cos(p0, p1, p2): | |
d1, d2 = (p0-p1).astype('float'), (p2-p1).astype('float') | |
return abs( np.dot(d1, d2) / np.sqrt( np.dot(d1, d1)*np.dot(d2, d2) ) ) |
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 numpy as np | |
import os | |
path = '' | |
files = os.listdir(path) | |
data = np.zeros((1, 128)) | |
identifiers = np.full((data.shape[0]), 0) | |
for file in files: | |
temp = np.load(path+file) |
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 pandas as pd | |
import umap | |
import sys | |
import numpy as np | |
import os | |
def load_data(file_path, dimension=3): | |
# If file path extension is numpy extension, load it as numpy array | |
if file_path.endswith('.npy'): |
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 numpy as np | |
import sys | |
filename = sys.argv[1] | |
def npy2csv(filename): | |
data = np.load(filename) | |
np.savetxt(filename[:-4] + ".csv", data, delimiter=",") |
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 os | |
import pandas as pd | |
all_files = os.listdir() | |
csv_files = [i for i in all_files if i.endswith(".csv")] | |
print(f'Found {len(csv_files)} files.') | |
def merge_csv_files(csv_files): | |
df = pd.DataFrame() |
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 pandas as pd | |
import numpy as np | |
import sys | |
filename = sys.argv[1] | |
def csv2npz(filename): | |
df = pd.read_csv(filename) | |
data = df.values |
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 pandas as pd | |
import numpy as np | |
import sys | |
# for f in rumi*.csv; do python csv2npy.py $f; done | |
filename = sys.argv[1] | |
def csv2npy(filename): |