mirror of
https://github.com/storytold/storyteller-ml.git
synced 2026-10-28 09:08:54 +00:00
docs
This commit is contained in:
@@ -10,23 +10,35 @@ Inspired by and including code from original Tacotron2 by Keith Ito.
|
|||||||
import re
|
import re
|
||||||
from typing import List, Union, Any
|
from typing import List, Union, Any
|
||||||
|
|
||||||
|
|
||||||
# Regular expression matching text enclosed in curly braces:
|
# Regular expression matching text enclosed in curly braces:
|
||||||
_curly_re = re.compile(r'(.*?)\{(.+?)\}(.*)')
|
_curly_re = re.compile(r'(.*?)\{(.+?)\}(.*)')
|
||||||
|
|
||||||
|
|
||||||
class ArpabetSequence:
|
class ArpabetSequence:
|
||||||
|
"""
|
||||||
|
Denotes an Arpabet phoneme sequence corresponding to a single word.
|
||||||
|
"""
|
||||||
def __init__(self, sequence: str):
|
def __init__(self, sequence: str):
|
||||||
self.sequence = sequence
|
self.sequence = sequence
|
||||||
def __eq__(self, other: Any) -> bool:
|
def __eq__(self, other: Any) -> bool:
|
||||||
return isinstance(other, ArpabetSequence) and self.sequence == other.sequence
|
return isinstance(other, ArpabetSequence) and self.sequence == other.sequence
|
||||||
|
|
||||||
|
|
||||||
class GraphemeSequence:
|
class GraphemeSequence:
|
||||||
|
"""
|
||||||
|
Denotes any string of non-Arpabet text, which may include multiple words,
|
||||||
|
spacing, and punctuation characters.
|
||||||
|
"""
|
||||||
def __init__(self, sequence: str):
|
def __init__(self, sequence: str):
|
||||||
self.sequence = sequence
|
self.sequence = sequence
|
||||||
def __eq__(self, other: Any) -> bool:
|
def __eq__(self, other: Any) -> bool:
|
||||||
return isinstance(other, GraphemeSequence) and self.sequence == other.sequence
|
return isinstance(other, GraphemeSequence) and self.sequence == other.sequence
|
||||||
|
|
||||||
|
|
||||||
ParsedSequence = List[Union[ArpabetSequence, GraphemeSequence]]
|
ParsedSequence = List[Union[ArpabetSequence, GraphemeSequence]]
|
||||||
|
|
||||||
|
|
||||||
def parse_grapheme_and_arpabet_sequence(input_text: str) -> ParsedSequence:
|
def parse_grapheme_and_arpabet_sequence(input_text: str) -> ParsedSequence:
|
||||||
"""
|
"""
|
||||||
Parse a string into a list of ArpabetSequence and GraphemeSequence so that each
|
Parse a string into a list of ArpabetSequence and GraphemeSequence so that each
|
||||||
|
|||||||
Reference in New Issue
Block a user