ORI-Muchim commited on
Commit
da5b2dc
·
1 Parent(s): 739b7a5

Update text/__init__.py

Browse files
Files changed (1) hide show
  1. text/__init__.py +3 -27
text/__init__.py CHANGED
@@ -1,14 +1,8 @@
1
  """ from https://github.com/keithito/tacotron """
2
  from text import cleaners
3
- from text.symbols import symbols
4
 
5
 
6
- # Mappings from symbol to numeric ID and vice versa:
7
- _symbol_to_id = {s: i for i, s in enumerate(symbols)}
8
- _id_to_symbol = {i: s for i, s in enumerate(symbols)}
9
-
10
-
11
- def text_to_sequence(text, cleaner_names):
12
  '''Converts a string of text to a sequence of IDs corresponding to the symbols in the text.
13
  Args:
14
  text: string to convert to a sequence
@@ -16,6 +10,8 @@ def text_to_sequence(text, cleaner_names):
16
  Returns:
17
  List of integers corresponding to the symbols in the text
18
  '''
 
 
19
  sequence = []
20
 
21
  clean_text = _clean_text(text, cleaner_names)
@@ -27,26 +23,6 @@ def text_to_sequence(text, cleaner_names):
27
  return sequence
28
 
29
 
30
- def cleaned_text_to_sequence(cleaned_text):
31
- '''Converts a string of text to a sequence of IDs corresponding to the symbols in the text.
32
- Args:
33
- text: string to convert to a sequence
34
- Returns:
35
- List of integers corresponding to the symbols in the text
36
- '''
37
- sequence = [_symbol_to_id[symbol] for symbol in cleaned_text if symbol in _symbol_to_id.keys()]
38
- return sequence
39
-
40
-
41
- def sequence_to_text(sequence):
42
- '''Converts a sequence of IDs back to a string'''
43
- result = ''
44
- for symbol_id in sequence:
45
- s = _id_to_symbol[symbol_id]
46
- result += s
47
- return result
48
-
49
-
50
  def _clean_text(text, cleaner_names):
51
  for name in cleaner_names:
52
  cleaner = getattr(cleaners, name)
 
1
  """ from https://github.com/keithito/tacotron """
2
  from text import cleaners
 
3
 
4
 
5
+ def text_to_sequence(text, symbols, cleaner_names):
 
 
 
 
 
6
  '''Converts a string of text to a sequence of IDs corresponding to the symbols in the text.
7
  Args:
8
  text: string to convert to a sequence
 
10
  Returns:
11
  List of integers corresponding to the symbols in the text
12
  '''
13
+ _symbol_to_id = {s: i for i, s in enumerate(symbols)}
14
+
15
  sequence = []
16
 
17
  clean_text = _clean_text(text, cleaner_names)
 
23
  return sequence
24
 
25
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
  def _clean_text(text, cleaner_names):
27
  for name in cleaner_names:
28
  cleaner = getattr(cleaners, name)