Spaces:
Build error
Build error
NTT123 commited on
Commit ·
5ec3478
1
Parent(s): 7911639
expand numbers, new examples.
Browse filesFiles changed (6)
- app.py+7-1
- inference.py+1-1
- mynumbers.pyAdded+73
- requirements.txt+6-5
- text.py+6-1
- wavegru.ckpt+1-1
32 unmodified lines33343536373839404132 unmodified linesfn=speak,inputs="text",examples=["this is a test!","October arrived, spreading a damp chill over the grounds and into the castle. Madam Pomfrey, the nurse, was kept busy by a sudden spate of colds among the staff and students.","Artificial intelligence is intelligence demonstrated by machines, as opposed to natural intelligence displayed by animals including humans.",],outputs="audio",title=title,32 unmodified lines33343536373839404142434445464732 unmodified linesfn=speak,inputs="text",examples=["This is a test!","President Trump met with other leaders at the Group of 20 conference.","The buses aren't the problem, they actually provide a solution.","Generative adversarial network or variational auto-encoder.","Basilar membrane and otolaryngology are not auto-correlations.","There are several variations on the full gated unit, with gating done using the previous hidden state and the bias in various combinations, and a simplified form called minimal gated unit.","October arrived, spreading a damp chill over the grounds and into the castle. Madam Pomfrey, the nurse, was kept busy by a sudden spate of colds among the staff and students.","Artificial intelligence is intelligence demonstrated by machines, as opposed to natural intelligence displayed by animals including humans.",'Uncle Vernon entered the kitchen as Harry was turning over the bacon. "Comb your hair!" he barked, by way of a morning greeting. About once a week, Uncle Vernon looked over the top of his newspaper and shouted that Harry needed a haircut. Harry must have had more haircuts than the rest of the boys in his class put together, but it made no difference, his hair simply grew that way - all over the place.',],outputs="audio",title=title,
27 unmodified lines2829303132333427 unmodified linesreturn alphabet, net, configtacotron_inference_fn = pax.pure(lambda net, text: net.inference(text, max_len=500))def text_to_mel(net, text, alphabet, config):27 unmodified lines2829303132333427 unmodified linesreturn alphabet, net, configtacotron_inference_fn = pax.pure(lambda net, text: net.inference(text, max_len=1200))def text_to_mel(net, text, alphabet, config):
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273""" from https://github.com/keithito/tacotron """
import inflectimport re
_inflect = inflect.engine()_comma_number_re = re.compile(r"([0-9][0-9\,]+[0-9])")_decimal_number_re = re.compile(r"([0-9]+\.[0-9]+)")_pounds_re = re.compile(r"£([0-9\,]*[0-9]+)")_dollars_re = re.compile(r"\$([0-9\.\,]*[0-9]+)")_ordinal_re = re.compile(r"[0-9]+(st|nd|rd|th)")_number_re = re.compile(r"[0-9]+")
def _remove_commas(m): return m.group(1).replace(",", "")
def _expand_decimal_point(m): return m.group(1).replace(".", " point ")
def _expand_dollars(m): match = m.group(1) parts = match.split(".") if len(parts) > 2: return match + " dollars" # Unexpected format dollars = int(parts[0]) if parts[0] else 0 cents = int(parts[1]) if len(parts) > 1 and parts[1] else 0 if dollars and cents: dollar_unit = "dollar" if dollars == 1 else "dollars" cent_unit = "cent" if cents == 1 else "cents" return "%s %s, %s %s" % (dollars, dollar_unit, cents, cent_unit) elif dollars: dollar_unit = "dollar" if dollars == 1 else "dollars" return "%s %s" % (dollars, dollar_unit) elif cents: cent_unit = "cent" if cents == 1 else "cents" return "%s %s" % (cents, cent_unit) else: return "zero dollars"
def _expand_ordinal(m): return _inflect.number_to_words(m.group(0))
def _expand_number(m): num = int(m.group(0)) if num > 1000 and num < 3000: if num == 2000: return "two thousand" elif num > 2000 and num < 2010: return "two thousand " + _inflect.number_to_words(num % 100) elif num % 100 == 0: return _inflect.number_to_words(num // 100) + " hundred" else: return _inflect.number_to_words( num, andword="", zero="oh", group=2 ).replace(", ", " ") else: return _inflect.number_to_words(num, andword="")
def normalize_numbers(text): text = re.sub(_comma_number_re, _remove_commas, text) text = re.sub(_pounds_re, r"\1 pounds", text) text = re.sub(_dollars_re, _expand_dollars, text) text = re.sub(_decimal_number_re, _expand_decimal_point, text) text = re.sub(_ordinal_re, _expand_ordinal, text) text = re.sub(_number_re, _expand_number, text) return text12345678910jax==0.3.1jaxlib==0.3.0numpy==1.22.3librosa==0.9.1pax3==0.5.6gradiojinja2toml==0.10.2unidecode==1.3.4pyyaml==6.01234567891011gradioinflect==5.4.0jax==0.3.1jaxlib==0.3.0jinja2librosa==0.9.1numpy==1.22.3pax3==0.5.6pyyaml==6.0toml==0.10.2unidecode==1.3.4
12 unmodified lines1314151617181931 unmodified lines51525354555625 unmodified lines82838485868712 unmodified lines"""import refrom unidecode import unidecode# Regular expression matching whitespace:31 unmodified linesreturn textdef lowercase(text):return text.lower()25 unmodified lines"""Pipeline for English text, including number and abbreviation expansion."""text = convert_to_ascii(text)text = lowercase(text)text = expand_abbreviations(text)text = collapse_whitespace(text)return text12 unmodified lines1314151617181931 unmodified lines5152535455565758596025 unmodified lines8687888990919212 unmodified lines"""import refrom mynumbers import normalize_numbersfrom unidecode import unidecode# Regular expression matching whitespace:31 unmodified linesreturn textdef expand_numbers(text):return normalize_numbers(text)def lowercase(text):return text.lower()25 unmodified lines"""Pipeline for English text, including number and abbreviation expansion."""text = convert_to_ascii(text)text = lowercase(text)text = expand_numbers(text)text = expand_abbreviations(text)text = collapse_whitespace(text)return text
123version https://git-lfs.github.com/spec/v1oid sha256:64b1ce6558cfe09b95bb29d48c34900ed0c3490d17c81fd6190969b226f4617asize 58039876123version https://git-lfs.github.com/spec/v1oid sha256:377de02cc88587e3562bdc709d48a43d00c901198d6b018bf6e1734211036577size 58039876
app.py+7-1
inference.py+1-1
mynumbers.pyAdded+73
requirements.txt+6-5
text.py+6-1
wavegru.ckpt+1-1