File size: 645 Bytes
4f70466
befd6a5
 
 
 
 
4f70466
 
 
 
 
 
 
 
 
befd6a5
4f70466
 
befd6a5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import os
import csv
import json
from glob import glob
import pandas as pd


direction_speech = os.getenv("DIRECTION_SPEECH", "enA")
direction_text = os.getenv("DIRECTION_TEXT", "jpn")

df = pd.concat([
    pd.read_csv(i, quoting=csv.QUOTE_NONE, encoding='utf-8', sep='\t', header=None, on_bad_lines='skip')
    for i in glob(f'metadata.{direction_speech}-{direction_text}.batch_*')
])
line_no = [int(i.split(" ")[-1]) for i in df[0]]
text = df[1].values.tolist()
os.makedirs("text_corpus", exist_ok=True)
with open(f"text_corpus/text.{direction_speech}-{direction_text}.json", "w") as f:
    json.dump({l: t for l, t in zip(line_no, text)}, f)