def from_sentences(cls, sentences: SentenceList, accents: AccentsDict, symbols: SymbolIdDict): res = cls() for sentence in sentences.items(): infer_sent = InferSentence( sent_id=sentence.sent_id, symbols=symbols.get_symbols(sentence.serialized_symbols), accents=accents.get_accents(sentence.serialized_accents) ) assert len(infer_sent.symbols) == len(infer_sent.accents) res.append(infer_sent) return res
def sents_accent_template(sentences: SentenceList, text_symbols: SymbolIdDict, accent_ids: AccentsDict) -> AccentedSymbolList: res = AccentedSymbolList() for i, sent in enumerate(sentences.items()): symbols = text_symbols.get_symbols(sent.serialized_symbols) accents = accent_ids.get_accents(sent.serialized_accents) for j, symbol_accent in enumerate(zip(symbols, accents)): symbol, accent = symbol_accent accented_symbol = AccentedSymbol( position=f"{i}-{j}", symbol=symbol, accent=accent ) res.append(accented_symbol) return res