Skip to content

Commit

Permalink
Merge pull request #2126 from MycroftAI/bugfix/no_split_at_initials
Browse files Browse the repository at this point in the history
Remove additional space after initials
  • Loading branch information
forslund committed May 17, 2019
2 parents fc7a3af + d2514b0 commit 5e7a468
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions mycroft/audio/speech.py
Expand Up @@ -76,6 +76,11 @@ def handle_speak(event):
# so we likely will want to get rid of this when not running on Mimic
if (config.get('enclosure', {}).get('platform') != "picroft" and
len(re.findall('<[^>]*>', utterance)) == 0):
# Remove any whitespace present after the period,
# if a character (only alpha) ends with a period
# ex: A. Lincoln -> A.Lincoln
# so that we don't split at the period
utterance = re.sub(r'\b([A-za-z][\.])(\s+)', r'\g<1>', utterance)
chunks = re.split(r'(?<!\w\.\w.)(?<![A-Z][a-z]\.)(?<=\.|\;|\?)\s',
utterance)
for chunk in chunks:
Expand Down

0 comments on commit 5e7a468

Please sign in to comment.