|
|
|
|
|
""" |
|
|
Script to move preprocessed data to main dataset |
|
|
""" |
|
|
|
|
|
import os |
|
|
import shutil |
|
|
from pathlib import Path |
|
|
import json |
|
|
|
|
|
def move_preprocessed_data(): |
|
|
"""Move preprocessed data to main dataset""" |
|
|
|
|
|
os.makedirs("audio", exist_ok=True) |
|
|
os.makedirs("aitranscripts", exist_ok=True) |
|
|
|
|
|
|
|
|
existing_audio = list(Path("audio").glob("*")) |
|
|
next_id = 1 |
|
|
if existing_audio: |
|
|
|
|
|
ids = [] |
|
|
for f in existing_audio: |
|
|
try: |
|
|
ids.append(int(f.stem)) |
|
|
except ValueError: |
|
|
pass |
|
|
if ids: |
|
|
next_id = max(ids) + 1 |
|
|
|
|
|
|
|
|
queue_files = list(Path("preprocessing/queue").glob("*")) |
|
|
|
|
|
if not queue_files: |
|
|
print("No files in preprocessing queue") |
|
|
return |
|
|
|
|
|
moved_files = [] |
|
|
for queue_file in queue_files: |
|
|
if queue_file.suffix in ['.mp3', '.wav']: |
|
|
|
|
|
new_name = f"{next_id}{queue_file.suffix}" |
|
|
dest_path = Path("audio") / new_name |
|
|
shutil.move(str(queue_file), str(dest_path)) |
|
|
|
|
|
|
|
|
transcript_file = Path("preprocessing/transcripts") / f"{queue_file.stem}.txt" |
|
|
if transcript_file.exists(): |
|
|
dest_transcript = Path("aitranscripts") / f"{next_id}.txt" |
|
|
shutil.move(str(transcript_file), str(dest_transcript)) |
|
|
else: |
|
|
|
|
|
dest_transcript = Path("aitranscripts") / f"{next_id}.txt" |
|
|
dest_transcript.write_text("") |
|
|
|
|
|
moved_files.append((new_name, next_id)) |
|
|
next_id += 1 |
|
|
|
|
|
if moved_files: |
|
|
print(f"Moved {len(moved_files)} files to main dataset:") |
|
|
for filename, file_id in moved_files: |
|
|
print(f" - {filename} (ID: {file_id})") |
|
|
|
|
|
|
|
|
print("\nRegenerating task list and dataset metadata...") |
|
|
os.system("python3 setup_annotation.py") |
|
|
else: |
|
|
print("No audio files found in preprocessing queue") |
|
|
|
|
|
if __name__ == "__main__": |
|
|
move_preprocessed_data() |