MCPcopy
hub / github.com/babysor/MockingBird / text_to_sequence

Function text_to_sequence

synthesizer/utils/text.py:13–40  ·  view source on GitHub ↗

Converts a string of text to a sequence of IDs corresponding to the symbols in the text. The text can optionally have ARPAbet sequences enclosed in curly braces embedded in it. For example, "Turn left on {HH AW1 S S T AH0 N} Street." Args: text: string to convert to a sequence

(text, cleaner_names)

Source from the content-addressed store, hash-verified

11
12
13def text_to_sequence(text, cleaner_names):
14 """Converts a string of text to a sequence of IDs corresponding to the symbols in the text.
15
16 The text can optionally have ARPAbet sequences enclosed in curly braces embedded
17 in it. For example, "Turn left on {HH AW1 S S T AH0 N} Street."
18
19 Args:
20 text: string to convert to a sequence
21 cleaner_names: names of the cleaner functions to run the text through
22
23 Returns:
24 List of integers corresponding to the symbols in the text
25 """
26 sequence = []
27
28 # Check for curly braces and treat their contents as ARPAbet:
29 while len(text):
30 m = _curly_re.match(text)
31 if not m:
32 sequence += _symbols_to_sequence(_clean_text(text, cleaner_names))
33 break
34 sequence += _symbols_to_sequence(_clean_text(m.group(1), cleaner_names))
35 sequence += _arpabet_to_sequence(m.group(2))
36 text = m.group(3)
37
38 # Append EOS token
39 sequence.append(_symbol_to_id["~"])
40 return sequence
41
42
43def sequence_to_text(sequence):

Callers 2

__getitem__Method · 0.90

Calls 4

_symbols_to_sequenceFunction · 0.85
_clean_textFunction · 0.85
_arpabet_to_sequenceFunction · 0.85
appendMethod · 0.80

Tested by

no test coverage detected