def sequence_to_text(sequence, symbols, skip_eos_and_pad=False, combine_jamo=False): """Converts a sequence of IDs back to a string""" _id_to_symbol = {i: s for i, s in enumerate(symbols)} # print(_id_to_symbol) PAD = "_" EOS = "~" result = "" for symbol_id in sequence: if symbol_id in _id_to_symbol: s = _id_to_symbol[symbol_id] # print(s) # Enclose ARPAbet back in curly braces: if len(s) > 1 and s[0] == "@": s = "{%s}" % s[1:] if not skip_eos_and_pad or s not in [EOS, PAD]: result += s result = result.replace("}{", " ") if combine_jamo: return jamo_to_korean(result) else: return result
def sequence_to_text(sequence, skip_eos_and_pad=False, combine_jamo=False): result = '' for symbol_id in sequence: if symbol_id in _id_to_symbol: s = _id_to_symbol[symbol_id] # Enclose ARPAbet back in curly braces: if len(s) > 1 and s[0] == '@': s = '{%s}' % s[1:] if not skip_eos_and_pad or s not in [EOS, PAD]: result += s result = result.replace('}{', ' ') if combine_jamo: return jamo_to_korean(result) else: return result
def sequence_to_text(sequence, skip_eos_and_pad=False, combine_jamo=False): '''Converts a sequence of IDs back to a string''' cleaner_names = [x.strip() for x in hparams.cleaners.split(',')] if 'english_cleaners' in cleaner_names and isEn == False: convert_to_en_symbols() result = '' for symbol_id in sequence: if symbol_id in _id_to_symbol: s = _id_to_symbol[symbol_id] # Enclose ARPAbet back in curly braces: if len(s) > 1 and s[0] == '@': s = '{%s}' % s[1:] if not skip_eos_and_pad or s not in [EOS, PAD]: result += s result = result.replace('}{', ' ') if combine_jamo: return jamo_to_korean(result) else: return result