File size: 2,369 Bytes
6158f1c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/usr/bin/env python3
"""
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"""
    # Create directories if they don't exist
    os.makedirs("audio", exist_ok=True)
    os.makedirs("aitranscripts", exist_ok=True)
    
    # Get the next available ID
    existing_audio = list(Path("audio").glob("*"))
    next_id = 1
    if existing_audio:
        # Extract numbers from existing files and find the max
        ids = []
        for f in existing_audio:
            try:
                ids.append(int(f.stem))
            except ValueError:
                pass
        if ids:
            next_id = max(ids) + 1
    
    # Move files from preprocessing queue
    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']:
            # Move audio file
            new_name = f"{next_id}{queue_file.suffix}"
            dest_path = Path("audio") / new_name
            shutil.move(str(queue_file), str(dest_path))
            
            # Look for corresponding transcript
            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:
                # Create empty transcript file
                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})")
        
        # Regenerate task list and dataset metadata
        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()