def plot(alignment, info, text): char_len, audio_len = alignment.shape # 145, 200 fig, ax = plt.subplots(figsize=(char_len/5, 5)) im = ax.imshow( alignment.T, aspect='auto', origin='lower', interpolation='none') xlabel = 'Encoder timestep' ylabel = 'Decoder timestep' if info is not None: xlabel += '\n{}'.format(info) plt.xlabel(xlabel) plt.ylabel(ylabel) if text: jamo_text = j2hcj(h2j(normalize(text))) pad = [PAD] * (char_len - len(jamo_text) - 1) plt.xticks(range(char_len), [tok for tok in jamo_text] + [EOS] + pad) if text is not None: while True: if text[-1] in [EOS, PAD]: text = text[:-1] else: break plt.title(text) plt.tight_layout()
def plot(alignment, info, text, isKorean=True): char_len, audio_len = alignment.shape # 145, 200 fig, ax = plt.subplots(figsize=(char_len / 5, 5)) im = ax.imshow(alignment.T, aspect='auto', origin='lower', interpolation='none') xlabel = 'Encoder timestep' ylabel = 'Decoder timestep' if info is not None: xlabel += '\n{}'.format(info) plt.xlabel(xlabel) plt.ylabel(ylabel) # plt.legend('19000step',fontsize=15, loc='upper left') if text: if isKorean: jamo_text = j2hcj(h2j(normalize(text))) else: jamo_text = text pad = [PAD] * (char_len - len(jamo_text) - 1) A = [tok for tok in jamo_text] + [EOS] + pad A = [x if x != ' ' else '' for x in A] # 공백이 있으면 그 뒤가 출력되지 않는 문제... plt.xticks(range(char_len), A) if text is not None: while True: if text[-1] in [EOS, PAD]: text = text[:-1] else: break plt.title('90000 step inna \n' + text) #plt.title('90000 step kss \n' + text) plt.tight_layout()
import json import csv from jamo import hangul_to_jamo import argparse from utils import load_json from text.korean import normalize if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument('--alignment_path', required=True) parser.add_argument('--remove_prefix', required=True) config = parser.parse_args() data = load_json(config.alignment_path, encoding="utf8") out_txt = config.alignment_path.replace('alignment.json','transcript.txt') f = csv.writer(open(out_txt, "w"), delimiter='|') for file in data: filename = file.replace(config.remove_prefix, '') text = data[file] norm = normalize(text) decomp = list(hangul_to_jamo(norm)) f.writerow([filename, text, norm, ''.join(decomp), "0.0"])