Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove empty files. #53

Merged
merged 2 commits into from
Nov 30, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/coral_models/prepare_raw_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,9 +344,16 @@ def prepare_raw_data(
# audio.
read_aloud_duration = 0.0
conversation_duration = 0.0
rows_to_remove = []
AJDERS marked this conversation as resolved.
Show resolved Hide resolved
for row_i, row in tqdm(recordings.iterrows()):
filename = input_path / row["filename"]

# Check if the file is empty, and if it is, remove it from the dataframe
# and continue to the next file
if filename.stat().st_size < 200000: # Any file smaller than this is empty
rows_to_remove.append(row_i)
continue

# Get the new filename
# New filename is in the format is for conversations:
# "recording_id_speaker_id1_speaker_id2_recorder_speaker_id_conversation.wav"
Expand Down Expand Up @@ -400,6 +407,9 @@ def prepare_raw_data(
except FileNotFoundError:
pass

# Remove rows with empty files
recordings = recordings.drop(rows_to_remove).reset_index(drop=True)

# Write a README file
readme = make_readme()
with open(output_path / "README.md", "w") as f:
Expand Down