sob111 commited on
Commit
40457d3
·
verified ·
1 Parent(s): 46b2d52

Update finetune_xtts_hf.py

Browse files
Files changed (1) hide show
  1. finetune_xtts_hf.py +22 -2
finetune_xtts_hf.py CHANGED
@@ -1,10 +1,11 @@
1
  import os
2
  import subprocess
3
  from huggingface_hub import HfApi, HfFolder
 
4
 
5
  # === Configuración ===
6
- HF_TOKEN = os.environ.get("HF_TOKEN") # asegúrate de tenerlo en Secrets del Space
7
- HF_REPO_ID = "sob111/xttsv2-es-finetuned" # cambia por tu repo destino
8
  OUTPUT_PATH = "./output_model"
9
  CONFIG_PATH = "./config.json"
10
 
@@ -12,6 +13,24 @@ CONFIG_PATH = "./config.json"
12
  print("=== Guardando token de Hugging Face ===")
13
  HfFolder.save_token(HF_TOKEN)
14
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
  # === Iniciar entrenamiento XTTSv2 ===
16
  print("=== Iniciando entrenamiento XTTSv2 ===")
17
  try:
@@ -40,3 +59,4 @@ api.upload_folder(
40
  )
41
 
42
  print(f"✅ Fine-tuning completado y subido a {HF_REPO_ID}")
 
 
1
  import os
2
  import subprocess
3
  from huggingface_hub import HfApi, HfFolder
4
+ from datasets import load_dataset
5
 
6
  # === Configuración ===
7
+ HF_TOKEN = os.environ.get("HF_TOKEN") # define en los Secrets del Space
8
+ HF_REPO_ID = "sob111/xttsv2-es-finetuned" # tu repo de destino
9
  OUTPUT_PATH = "./output_model"
10
  CONFIG_PATH = "./config.json"
11
 
 
13
  print("=== Guardando token de Hugging Face ===")
14
  HfFolder.save_token(HF_TOKEN)
15
 
16
+ # === Descargar dataset desde Hugging Face ===
17
+ print("=== Descargando dataset sob111/voxpopuli_es_500 ===")
18
+ ds = load_dataset("sob111/voxpopuli_es_500", split="train", token=HF_TOKEN)
19
+
20
+ # Guardar metadata.json en el formato esperado por Coqui TTS
21
+ os.makedirs("./voxpopuli_es_500", exist_ok=True)
22
+ meta_file = "./voxpopuli_es_500/metadata.json"
23
+ with open(meta_file, "w", encoding="utf-8") as f:
24
+ for sample in ds:
25
+ f.write(
26
+ f'{{"audio_file": "{sample["audio_file"]}", '
27
+ f'"text": "{sample["text"]}", '
28
+ f'"speaker_name": "{sample.get("speaker_name", "speaker")}"}}
29
+ '
30
+ )
31
+
32
+ print(f"✅ Metadata guardada en {meta_file}")
33
+
34
  # === Iniciar entrenamiento XTTSv2 ===
35
  print("=== Iniciando entrenamiento XTTSv2 ===")
36
  try:
 
59
  )
60
 
61
  print(f"✅ Fine-tuning completado y subido a {HF_REPO_ID}")
62
+