Skip to content

Instantly share code, notes, and snippets.

@ketanhdoshi
Last active November 1, 2023 09:18
Show Gist options
  • Save ketanhdoshi/51af76ba8bf6f21ed56698ff3bbc8126 to your computer and use it in GitHub Desktop.
Save ketanhdoshi/51af76ba8bf6f21ed56698ff3bbc8126 to your computer and use it in GitHub Desktop.
Audio Classification Metadata
# ----------------------------
# Prepare training data from Metadata file
# ----------------------------
import pandas as pd
from pathlib import Path
download_path = Path.cwd()/'UrbanSound8K'
# Read metadata file
metadata_file = download_path/'metadata'/'UrbanSound8K.csv'
df = pd.read_csv(metadata_file)
df.head()
# Construct file path by concatenating fold and file name
df['relative_path'] = '/fold' + df['fold'].astype(str) + '/' + df['slice_file_name'].astype(str)
# Take relevant columns
df = df[['relative_path', 'classID']]
df.head()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment