Datasets:
Is the CommonLanguage Dataset samples actually 200k?
#8
by
calvinadi
- opened
I downloaded the dataset and try to merge all audio, because I want to try split with different number, however I only 34k audio samples, which is not even 50% of 200k
audio path
dataset_path = '/content/CommonLanguage/common_voice_kpd'
Function to load audio data
def load_audio(file_path):
try:
audio_data, sample_rate = librosa.load(file_path, sr=None)
return audio_data, sample_rate
except Exception as e:
print(f"Error processing file {file_path}: {e}")
return None, None
Function to load audio data with multithreading
def load_audio_multithreaded(dataset_path):
audio_list = []
labels = []
def process_subfolder(subfolder_path, label):
if os.path.isdir(subfolder_path):
for file in os.listdir(subfolder_path):
file_path = os.path.join(subfolder_path, file)
if file_path.endswith(".wav"):
futures.append(executor.submit(load_audio, file_path))
labels.append(label)
def process_folder(folder_path, label):
if os.path.isdir(folder_path):
for subfolder in os.listdir(folder_path):
subfolder_path = os.path.join(folder_path, subfolder)
if os.path.isdir(subfolder_path):
process_subfolder(subfolder_path, label)
with ThreadPoolExecutor(max_workers=4) as executor:
futures = []
start_time = time.time()
for language_folder in os.listdir(dataset_path):
language_folder_path = os.path.join(dataset_path, language_folder)
if os.path.isdir(language_folder_path):
train_path = os.path.join(language_folder_path, 'train')
test_path = os.path.join(language_folder_path, 'test')
dev_path = os.path.join(language_folder_path, 'dev')
# Process files in train, test, and dev folders
process_folder(train_path, language_folder)
process_folder(test_path, language_folder)
process_folder(dev_path, language_folder)
# Retrieve results from futures
for future in futures:
audio_data, sample_rate = future.result()
if audio_data is not None:
audio_list.append((audio_data, sample_rate))
end_time = time.time()
print(f"Total time taken to load audio data: {end_time - start_time:.2f} seconds")
return audio_list, labels
Load audio data
audio_list, labels = load_audio_multithreaded(dataset_path)