Spaces:
Runtime error
Runtime error
Create convert_to_ljspeech.py
Browse files- convert_to_ljspeech.py +19 -0
convert_to_ljspeech.py
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import json, csv, os
|
| 2 |
+
|
| 3 |
+
root = "/tmp/dataset/voxpopuli_es_500"
|
| 4 |
+
|
| 5 |
+
with open(os.path.join(root, "metadata.json"), "r", encoding="utf-8") as f:
|
| 6 |
+
data = json.load(f)
|
| 7 |
+
|
| 8 |
+
with open(os.path.join(root, "metadata.csv"), "w", encoding="utf-8") as f:
|
| 9 |
+
writer = csv.writer(f, delimiter="|", quoting=csv.QUOTE_NONE, escapechar="\\")
|
| 10 |
+
for entry in data:
|
| 11 |
+
# Quitar prefijo "voxpopuli_es_500/" si está presente
|
| 12 |
+
path = entry["audio_filepath"]
|
| 13 |
+
if path.startswith("voxpopuli_es_500/"):
|
| 14 |
+
path = path.replace("voxpopuli_es_500/", "", 1)
|
| 15 |
+
|
| 16 |
+
text = entry["text"].replace("\n", " ").strip()
|
| 17 |
+
speaker = entry["speaker"]
|
| 18 |
+
|
| 19 |
+
writer.writerow([path, text, speaker])
|