From d31fabf8cff5dae02e3fc759a4203bd374dddc99 Mon Sep 17 00:00:00 2001 From: schneefux Date: Sun, 30 Mar 2014 16:03:44 -0400 Subject: Initial commit --- client/alteration.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 client/alteration.py (limited to 'client/alteration.py') diff --git a/client/alteration.py b/client/alteration.py new file mode 100644 index 0000000..e381cd4 --- /dev/null +++ b/client/alteration.py @@ -0,0 +1,20 @@ +import re + + +def detectYears(input): + YEAR_REGEX = re.compile(r'(\b)(\d\d)([1-9]\d)(\b)') + return YEAR_REGEX.sub('\g<1>\g<2> \g<3>\g<4>', input) + + +def clean(input): + """ + Manually adjust output text before it's translated into + actual speech by the TTS system. This is to fix minior + idiomatic issues, for example, that 1901 is pronounced + "one thousand, ninehundred and one" rather than + "nineteen ninety one". + + Arguments: + input -- original speech text to-be modified + """ + return detectYears(input) -- cgit v1.3.1