ANNNOUNNNCCCEEERRR VOICCCEEE Write a function that takes a string of letters and spaces (no need to handle non-letters) and performs the ANNOUNCER VOICE translation algorithm as follows:


First, uppercase everything.
For each word,


Elongate each consonant cluster by tripling each letter; except, if the word begins with a consonant cluster, do not elongate that cluster. For example, other should become OTTTHHHEEERRR but mother should become MOTTTHHHEEERRR.
Elongate the final vowel by tripling it.

In both cases of elongation, if you're tripling a letter, first coalesce it with duplicate letters on either side. For example, hill should become HIIILLL and bookkeeper should become BOOKKKEEPPPEEERRR.
For the purposes of this challenge, y counts as a consonant.
Clarification/simplification: You may assume that each pair of words is separated by a single space, and that the input contains no consecutive spaces, and that the input will not be the empty string.
Shortest code wins!


Test vectors:

&gt; sunday sunday
SUNNNDDDAAAYYY SUNNNDDDAAAYYY
&gt; mia hamm
MIAAA HAAAMMM
&gt; chester alan arthur
CHESSSTTTEEERRR ALLLAAANNN ARRRTTTHHHUUURRR
&gt; attention please
ATTTENNNTTTIOOONNN PLEASSSEEE
&gt; supercalifragilisticexpialidocious
SUPPPERRRCCCALLLIFFFRRRAGGGILLLISSSTTTICCCEXXXPPPIALLLIDDDOCCCIOUUUSSS
&gt; moo
MOOO
&gt; Aachen
AACCCHHHEEENNN
&gt; Oooh
OOOHHH
&gt; grifffest
GRIFFFEEESSSTTT
&gt; k
K
&gt; aaaabbbbc
AAAABBBBCCC




Here's a reference implementation which I would move to an answer except that as of this morning the question's been closed. :P

import itertools,re
def j(s):return re.match('^[AEIOU]+$',s)
def c(s):return ''.join(sum(([h,h,h]for h in[k for k,g in itertools.groupby(s)]),[]))
def v(s):
 while len(s)&gt;=2 and s[-2]==s[-1]:s=s[:-1]
 return s+s[-1]+s[-1]
def a(n):
 r=''
 for w in n.split():
  if r:r+=' '
  ss=re.split('([AEIOU]+)', w.upper())
  for i,s in enumerate(ss):
   r += [v(s),s][any(j(t) for t in ss[i+1:])]if j(s)else[s,c(s)][i&gt;0]
 return r
while 1:print a(raw_input('&gt; '))
APL (Dyalog), 175 bytes



1↓' +'⎕R' '⊢'[AEIOU][^AEIOU]+ '⎕R{m/⍨1,3×2≠/m←⍵.Match}'([AEIOU])\1*([^AEIOU]*? )' ' [AEIOU]' ' [^ AEIOU]+' '([^AEIOU ])\1*'⎕R'\1\1\1\2' '&amp;' '&amp;' '\1\1\1'⊢'$| |^'⎕R'  '⊢1(819⌶)⍞


Try it online!

⍞ prompt for character input

1(819⌶) convert to uppercase (819 ≈ Big)

⊢ pass the result further (serves to separate the strings and the 1)

'$| |^'⎕R'  ' Replace:
 the end, any space, and the beginning
 → two spaces

⊢ pass the result further (serves to separate two groups of strings)

'([AEIOU])\1*([^AEIOU]*? )' ' [AEIOU]' ' [^ AEIOU]+' '([^AEIOU ])\1*'⎕R'\1\1\1\2' '&amp;' '&amp;' '\1\1\1' Replace:
 any number of identical vowels and any number of non-vowels and a space
 → the vowel thrice and the unmodified consonants
 a space and a vowel
 → themselves
 a space and a consonant cluster
 → themselves
 a run of identical consonants
 → three of those vowels

'[AEIOU][^AEIOU]+ '⎕R{…} Replace:
 a run of non-vowels and a space
 → the result of the following anonymous function with the namespace ⍵ as argument:
  ⍵.Match the text that was found
  m← assign that to m
  2≠/ pair-wise different-from
  3× multiply by three
  1, prepend one
  m/⍨ use that to replicate m

⊢ pass the result further (serves to separate two strings)

' +'⎕R' ' Replace:
 one or more spaces
 → with a single space

1↓ drop the initial letter (a space)