# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 2
#     language: python
#     name: python2
# ---

# +
'''
Create new category 'source_label' to identify the recording device:
    - assign label 's' (source) to audio segments if recorded by Device A;
    - assign label 't' (target) to audio segments if recorded by other devices.
''' 

import numpy as np 
import pandas as pd
print("numpy version = ",np.__version__)
print("pandas version = ",pd.__version__)

# +
ThisPath = '../../commonData/dcase2020/TAU-urban-acoustic-scenes-2020-mobile-development/'
TrainFile = ThisPath + 'evaluation_setup/fold1_train.csv'
ValFile = ThisPath + 'evaluation_setup/fold1_evaluate.csv'
AllFile = ThisPath + 'meta.csv'
sr = 44100
num_audio_channels = 1

dev_train_df = pd.read_csv(TrainFile,sep='\t', encoding='ASCII')
dev_val_df = pd.read_csv(ValFile,sep='\t', encoding='ASCII')
wavpaths_train = dev_train_df['filename'].tolist()
wavpaths_val = dev_val_df['filename'].tolist()


dev_train_df['source_label'] = 't'
dev_train_df.loc[dev_train_df['filename'].str.contains("-a.wav"),'source_label'] = 's'
dev_val_df['source_label'] = 't'
dev_val_df.loc[dev_val_df['filename'].str.contains("-a.wav"),'source_label'] = 's'


dev_train_df.to_csv(TrainFile[:-4]+'_st.csv', index=False, header = True, sep='\t')
dev_val_df.to_csv(ValFile[:-4]+'_st.csv', index=False, header = True, sep='\t')


# +
all_df = pd.read_csv(AllFile,sep='\t', encoding='ASCII')
wavpaths_all = all_df['filename'].tolist()

all_df['source_label'] = 't'
all_df.loc[all_df['filename'].str.contains("-a.wav"),'source_label'] = 's'

all_df.to_csv(AllFile[:-4]+'_st.csv', index=False, header = True, sep='\t')
# -



StarcoderdataJupyterScriptsDedupFiltered