Luigi commited on
Commit
c950da9
·
verified ·
1 Parent(s): 7876105

one-click rebuild_voice.sh + generators + text pools

Browse files
Files changed (1) hide show
  1. scripts/build_corpus_v3.py +33 -0
scripts/build_corpus_v3.py ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """Assemble the v3 training manifest: existing clean corpus + new diverse mix + entity/name clips,
3
+ with EVERY text passed through text_norm.normalize so the manifest's phonemization matches the audio
4
+ (the teacher read the same spoken form). Idempotent on already-normalized entity rows. Usage:
5
+ python build_corpus_v3.py --out corpus_v3.norm.jsonl <manifest1.jsonl> <manifest2.jsonl> ...
6
+ """
7
+ import argparse, json, os
8
+ import text_norm as T
9
+
10
+ def main():
11
+ ap = argparse.ArgumentParser()
12
+ ap.add_argument("--out", required=True)
13
+ ap.add_argument("manifests", nargs="+")
14
+ a = ap.parse_args()
15
+ seen, n_in, n_out = set(), 0, 0
16
+ with open(a.out, "w", encoding="utf-8") as o:
17
+ for mf in a.manifests:
18
+ if not os.path.exists(mf):
19
+ print("SKIP missing", mf); continue
20
+ for l in open(mf):
21
+ if not l.strip(): continue
22
+ r = json.loads(l); n_in += 1
23
+ wav = r.get("target_audio")
24
+ if not wav or not os.path.exists(wav): continue
25
+ if wav in seen: continue
26
+ seen.add(wav)
27
+ r["text"] = T.normalize(r.get("text", ""))
28
+ if len(r["text"]) < 2: continue
29
+ o.write(json.dumps(r, ensure_ascii=False) + "\n"); n_out += 1
30
+ print(f"BUILD_CORPUS_V3 in={n_in} out={n_out} -> {a.out}")
31
+
32
+ if __name__ == "__main__":
33
+ main()