File size: 1,213 Bytes
70e5c60
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import os
import csv

# Carpeta donde están los .wav
ruta = "voces"

# Obtener y ordenar archivos .wav
archivos = sorted([f for f in os.listdir(ruta) if f.endswith(".wav")])

# Verifica si hay archivos
if not archivos:
    print("❌ No se encontraron archivos .wav en la carpeta 'voces'.")
    exit()

# Crear archivo dataset.csv
with open("dataset.csv", "w", newline='', encoding='utf-8') as f:
    writer = csv.writer(f)
    writer.writerow(["path", "text"])

    print("🧠 Comenzando anotación de dataset...\n")

    for nombre in archivos:
        ruta_relativa = os.path.join(ruta, nombre)
        print(f"\n🎧 Reproduciendo: {ruta_relativa}")
        os.system(f"aplay '{ruta_relativa}'")  # Compatibilidad con espacios en nombres

        try:
            texto = input(f"📝 ¿Qué dice exactamente '{nombre}'? ").strip()
            if texto:
                writer.writerow([ruta_relativa, texto])
                print("✅ Guardado.")
            else:
                print("⚠️ Entrada vacía. Archivo omitido.")
        except KeyboardInterrupt:
            print("\n⛔ Proceso interrumpido por el usuario.")
            break

print("\n📦 Dataset final guardado como 'dataset.csv'")