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
| # copy into new notebook and run. | |
| # ../src is my preferred structure difference need to be updated. | |
| import sys | |
| from pathlib import Path | |
| # Define the src directory path | |
| src_path = str(Path("../src").resolve()) | |
| # Check if it's already in sys.path |
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
| @staticmethod | |
| def pad_trunc(aud, max_ms): | |
| sig, sr = aud | |
| num_rows, sig_len = sig.shape | |
| max_len = sr//1000 * max_ms | |
| if (sig_len > max_len): | |
| # Truncate the signal to the given length | |
| sig = sig[:,:max_len] |
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 csv | |
| # Specify the file path and name | |
| csv_file = '../data/AudioMNIST_Indicies/dummy_labels.csv' | |
| # Specify the number of rows | |
| num_rows = 2997 # change into necessary number of rows | |
| # Open the CSV file in write mode | |
| with open(csv_file, 'w', newline='') as 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 os | |
| import glob | |
| def count_files(folder_path): | |
| file_list = glob.glob(os.path.join(folder_path, '*')) | |
| return len(file_list) | |
| # Specify the folder path you want to check | |
| folder_path = '../data/AudioMNIST' |
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
| from operator import itemgetter | |
| data = [ | |
| 5, | |
| "Harry", | |
| 37.21, | |
| "Berry", | |
| 37.21, | |
| "Tina", | |
| 37.2, |
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
| out = [x for sublist in out for x in sublist] |
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
| Character | Description | Example Pattern Code | Example Match | |
|---|---|---|---|---|
| \d | A digit | file_\d\d | file_25 | |
| \D | A non digit | \D\D\D | ABC | |
| \w | Alphanumeric | \w-\w\w\w | A-b_1 | |
| \W | Non-alphanumeric | \W\W\W\W | !*+) | |
| \s | White space | a\sb\sc | a b c | |
| \S | Non-whitespace | \S\S\S\S | This |