Saturday, September 20, 2008

IRC games: Customizing Festival voice

Setting basics up:
I use x-chat2 with uberscripts and festival plugin. Tired of the default festival voice, Today's effort was to change the voices ;). I found this to be the best available resource.
Here are the instructions in command format. You can just copy paste the following.
sudo apt-get install festival festlex-cmu festlex-poslex festlex-oald libestools1.2 unzip
sudo apt-get install festvox-don festvox-rablpc16k festvox-kallpc16k festvox-kdlpc16
cd ~/tmp
mkdir hts_tmp
cd hts_tmp/
wget -c http://hts.sp.nitech.ac.jp/archives/2.0.1/festvox_nitech_us_awb_arctic_hts-2.0.1.tar.bz2
wget -c http://hts.sp.nitech.ac.jp/archives/2.0.1/festvox_nitech_us_bdl_arctic_hts-2.0.1.tar.bz2
wget -c http://hts.sp.nitech.ac.jp/archives/2.0.1/festvox_nitech_us_clb_arctic_hts-2.0.1.tar.bz2
wget -c http://hts.sp.nitech.ac.jp/archives/2.0.1/festvox_nitech_us_rms_arctic_hts-2.0.1.tar.bz2
wget -c http://hts.sp.nitech.ac.jp/archives/2.0.1/festvox_nitech_us_slt_arctic_hts-2.0.1.tar.bz2
wget -c http://hts.sp.nitech.ac.jp/archives/2.0.1/festvox_nitech_us_jmk_arctic_hts-2.0.1.tar.bz2
wget -c http://hts.sp.nitech.ac.jp/archives/1.1.1/cmu_us_kal_com_hts.tar.gz
wget -c http://hts.sp.nitech.ac.jp/archives/1.1.1/cstr_us_ked_timit_hts.tar.gz
for t in `ls` ; do tar xvf $t ; done
sudo mkdir -p /usr/share/festival/voices/us
sudo mv lib/voices/us/* /usr/share/festival/voices/us/
sudo mv lib/hts.scm /usr/share/festival/hts.scm
cd ../
rm -rf hts_tmp/

NOTE: I have chosen just the smallest of the voices. In the link I provided previously, MonkeeSage explains other voices.

Testing, Selecting and Configuring the default voice
Start up festival. Note that festival is a "lispy". () form each sentence. (quit) is to quit, (SayText "Hello World") causes festival to speak "Hello World".
Procedure for testing and selecting voice
  1. (voice.list) - list all voices available.
  2. (voice_) - select as the current voice
  3. (SayText "Hello World") - Say the text Hello World
  4. Repeat steps 2 and 3 till you find the voice which you are ok with.
  5. (quit) - to exit from festival
Example:
(voice.list)
(voice_rab_diphone)
(SayText "magnetic interferance from money/credit cards")
(voice_ked_diphone)
(SayText "waste water tank overflowed onto computer")
(voice_kal_diphone)
(SayText "nesting roaches shorted out the ether cable")
(voice_nitech_us_jmk_arctic_hts)
(SayText "need to wrap system in aluminum foil to fix problem")
(voice_nitech_us_bdl_arctic_hts)
(SayText "Groundskeepers stole the root password")
(voice_nitech_us_rms_arctic_hts)
(SayText "your keyboard's space bar is generating spurious keycodes")
(voice_nitech_us_slt_arctic_hts)
(SayText "Communications satellite used by the military for star wars")
(voice_nitech_us_clb_arctic_hts)
(SayText "We didn't pay the Internet bill and it's been cut off")
(voice_nitech_us_awb_arctic_hts)
(SayText "Your cat tried to eat the mouse.")
(Disclaimer: all of the above wordings were "borrowed" from bofh.txt from uberscript)

Next step will be to create/edit your own ~/.festivalrc file using your fav editor(gedit, vim etc..). Mine is as follows:
(set! default_after_synth_hooks
(list (lambda (utt) (utt.wave.rescale utt 1.6 t))))
(set! voice_default 'voice_nitech_us_slt_arctic_hts)
Note: you can change the voice_nitech_us_slt_artic_hts to which ever voice you choose. IRC: xchat configuration:
#!/usr/bin/perl
#
# An X-Chat interface to the Festival speech synthesis system 
#
# Based on ircspeal.pl v0.2 by Gareth Watts 1998 
#
# For more information 
# Festival http://www.cstr.ed.ac.uk/projects/festival/
#  ircspeak.pl http://www.omnipotent.net/ircspeak/
#
###################################
## CONFIGURE THIS BIT!

# I react only when any of the case insensitive regex is found in list below.
@MyKeyWordsRegeXs=("NishanthMenon");

# I react only for the following events:
#@HANDLERS=("PRIVMSG", "NOTICE", "TOPIC", "NICK", "JOIN", "PART", "QUIT", "INVITE");
@HANDLERS=("PRIVMSG", "INVITE");
#
# Adjust this so it reflects the location of your festival executable
$festival='/usr/bin/festival --pipe';

# Adjust this to your preferred Voice 
#$VOICE = "voice_don_diphone"; # A British voice.
#$VOICE = "voice_rab_diphone"; # A muted British-esque voice
#$VOICE = "voice_kal_diphone"; # An American male voice
$VOICE = "voice_ked_diphone"; # A less mechanical American male voice

# Smaller numbers = faster speech
$SPEED = ".75";

## YOU CAN STOP CONFIGURING!
###################################
# 
# Commands 
#  Enable speech using /speechon
#  Disable speech using /speechoff
#
# Uncomment for Debugging printing in IRC
#$DEBUG = 1;
#
# Released WITHOUT WARRANTY under version 2 of the GNU Public License
# See the end of this file for the full text
#
 
$MY_NAME = "xchat_speak.pl by SCK based on ircspeak.pl by Gareth Watts";
$VERSION = "0.3.2";

# Changelog:
# 25/Oct/2002
#  v0.03 released
#  + First code release by SCK
# 08/Nov/2002
#  v0.03.1 released
#  + Removed un-needed strippuunct sub routine that failed under Perl 5.8
# 09/Nov/2002
#  v0.03.2 released
#  + Fixed return code issue with xchat.

# IRC translator data below.  Feel free to add to the list
# Be sure it is is all lowercase, and escape any contractions
%regex_convert = (
  'privmsg' => 'says',
  'topic'  => 'changes topic to',
  'join'  => 'has joined',
  'part'  => 'has left',
  'quit'  => 'has quit',
  'invite' => 'has invited you to',
);

%wordsub = (
        '..'=> '\,',
        '...'=> '\,',
        '2nd'=> 'second',
        '31337'=> 'eleet',
        '56k'=> '56 k',
        ':)'=> 'smiles',
        ':-)'=> 'smiles',
        ':-p'=> 'sticks tongue out',
        ':>'=> 'smiles',
        ':p'=> 'sticks tongue out',
        ';)'=> 'winks',
        ';-)'=> 'winks',
        'aamof'=> 'as a matter of fact',
        'ad'=> 'add',
        'adn'=> 'any day now',
        'afaik'=> 'as far as i know',
        'afair'=> 'as far as i remember',
        'afj'=> 'april fool\'s joke',
        'afk'=> 'away from the keyboard',
        'asap'=> 'as soon as possible',
        'at0mic_'=> 'atomic',
        'atm'=> 'at the moment',
        'awc'=> 'after while, crocodile',
        'awgthtgtwta?'=> 'are we going to have to go through with this again?',
        'ayt'=> 'are you there?',
        'b4'=> 'before',
        'b4n'=> 'bye for now',
        'bak'=> 'back at keyboard',
        'bakerw0rk'=> 'baker-work',
        'bbfn'=> 'bye bye for now',
 'bbiab'=> 'be back in a bit',
        'bbiaf'=> 'be back in a few',
        'bbialb'=> 'be back in a little bit',
        'bbl'=> 'be back later',
        'bcnu'=> 'be seeing you',
        'bf'=> 'boy friend',
        'brb'=> 'be right back',
        'bta'=> 'but then again',
        'btw'=> 'by the way',
        'bye?'=> 'are you ready to say goodbye',
        'bykt'=> 'but you knew that',
        'byob'=> 'bring your own bottle',
        'byom'=> 'bring your own mac',
        'cmiiw'=> 'correct me if i\'m wrong',
        'cu'=> 'see you',
        'cul'=> 'see you later',
        'cul8r'=> 'see you later',
        'cula'=> 'see you later, alligator',
        'cya'=> 'see ya',
        'd/l'=> 'download',
        'd00d'=> 'dood',
        'diku?'=> 'do i know you?',
        'dtrt'=> 'do the right thing',
 'dvd'=> 'd v d',
        'esad'=> 'eat shit and die',
        'f2f'=> 'face to face',
        'fcfs'=> 'first come, first served',
        'fitb'=> 'fill in the blank',
        'flyaway'=> 'fly away',
        'foad'=> 'feck off and die',
        'foaf'=> 'friend of a friend',
        'freebsd'=> 'free bsd',
        'fs'=> 'for sale',
        'fubar'=> 'fecked up beyond all repair',
        'fud'=> 'fear, uncertainty and doubt',
        'fwiw'=> 'for what it\'s worth',
        'fya'=> 'for your amusement',
        'fyi'=> 'for your information',
        'ga'=> 'go ahead',
        'gal'=> 'get a life',
        'gb'=> 'gigabytes',
        'gd\&r'=> 'grinning, ducking and running',
        'gd\&wvvf'=> 'grinning, ducking, and walking very, very fast',
        'gf'=> 'girl friend',
        'giwist'=> 'gee, i wish i\'d said that',
        'gmta'=> 'great minds think alike',
        'hhoj'=> 'ha ha only joking',
        'hhok'=> 'ha ha only kidding',
        'hhos'=> 'ha ha only serious',
 'hmm'=> 'hurrmmm',
        'hoyew'=> 'hanging on your every word',
        'hp/ux'=> 'hp ux',
        'hrm'=> 'herm',
        'hth'=> 'hope that helps!',
        'i8urdog'=> 'I ate your dog',
        'iac'=> 'in any case',
        'ianal'=> 'i am not a lawyer',
        'iaw'=> 'in accordance with',
        'ic'=> 'i see',
        'identd'=> 'ident d',
        'iirc'=> 'if i remember correctly',
        'ijwtk'=> 'i just want to know',
        'ijwts'=> 'i just want to say',
        'ikwum'=> 'i know what you mean',
        'ima'=> 'i might add',
        'imao'=> 'in my arrogant opinion',
        'imco'=> 'in my considered opinion',
        'ime'=> 'in my experience',
        'imho'=> 'in my humble opinion',
        'imnsho'=> 'in my not so humble opinion',
        'imo'=> 'in my opinion',
        'inpo'=> 'in no particular order',
 'irq'=> 'i r q',
        'iow'=> 'in other words',
        'ip'=> 'i p',
        'ipx'=> 'i p x',
        'irl'=> 'in real life',
 'isdn'=> 'i s d n',
        'iss'=> 'i\'m so sure',
        'issygti'=> 'i\'m so sure you get the idea!',
        'iswim'=> 'if you see what i mean',
        'iwbni'=> 'it would be nice if',
        'iyfeg'=> 'insert your favorite ethnic group',
        'iyswim'=> 'if you see what i mean',
        'jam'=> 'just a minute',
        'jic'=> 'just in case',
        'k3nny'=> 'kenny',
        'kb'=> 'kilobytes',
        'kibo'=> 'knowledge in, bullshit out',
        'kwim'=> 'know what i mean?',
        'kyfc'=> 'keep your fingers crossed',
        'l8r'=> 'later',
        'lin0x'=> 'linux',
        'ljbf'=> 'let\'s just be friends',
        'lol'=> 'laughing out loud',
        'lshmba'=> 'laughing so hard my belly aches',
        'lthtt'=> 'laughing too hard to type',
        'ltns'=> 'long time no see',
        'mb'=> 'megabytes',
        'motas'=> 'member of the appropriate sex',
        'motd'=> 'message of the day',
        'motos'=> 'member of the opposite sex',
        'motss'=> 'member of the same sex',
        'msg'=> 'message',
        'myob'=> 'mind your own business',
        'n-tropy'=> 'entropy',
        'nah'=> 'no',
        'ne1'=> 'anyone',
        'netbsd'=> 'net bsd',
        'nhoh'=> 'never heard of him slash her',
        'np'=> 'no problem',
        'obo'=> 'or best offer',
        'obtw'=> 'oh, by the way',
        'oic'=> 'oh, i see',
        'ok'=> 'o k',
        'openbsd'=> 'open bsd',
        'otf'=> 'on the floor',
        'otfl'=> 'on the floor laughing',
        'otoh'=> 'on the other hand',
        'ott'=> 'over the top',
        'pci'=> 'p c i',
        'pmf'=> 'pardon my french',
        'pmfbi'=> 'pardon me for butting in',
        'pmfji'=> 'pardon me for jumping in',
        'pmji'=> 'pardon my jumping in',
        'pncah'=> 'please, no cursing allowed here',
        'pnpisa'=> 'p n p i s a',
        'po0p'=> 'poop',
        'ppl'=> 'people',
 'pstn'=> 'p s t n',
        'ptmm'=> 'please tell me more',
        'quazwork'=> 'quaz-work',
        'r u there?'=> 'are you there?',
        're'=> 'regreet',
        'redhat'=> 'red hat',
        'rehi'=> 'hi again',
        'rl'=> 'real life',
        'rotf'=> 'rolling on the floor',
        'rotfl'=> 'rolling on the floor laughing',
        'rotflol'=> 'rolling on the floor laughing out loud',
        'rsn'=> 'real soon now',
        'rsvp'=> 'please reply',
        'rtbm'=> 'read the bloody manual',
        'rtfaq'=> 'read the frequently asked questions',
        'rtfm'=> 'read the fecking manual',
        'rtm'=> 'read the manual',
        'ryfm'=> 'read your friendly manual',
        'scsi'=> 'scuzy',
        'sec'=> 'wait a second',
        'secs'=> 'seconds',
        'snafu'=> 'situation normal, all fouled up',
        'sol'=> 'shit out of luck',
        'sos'=> 'help!',
        'swim'=> 'see what i mean?',
        'tafn'=> 'that\'s all for now',
        'tanj'=> 'there ain\'t no justice',
        'tanstaafl'=> 'there ain\'t no such thing as a free lunch',
        'tcp'=> 't c p',
        'thankx'=> 'thanks',
        'thx'=> 'thanks',
        'tia'=> 'thanks in advance',
        'tic'=> 'tongue in cheek',
        'tntl'=> 'trying not to laugh',
        'tnx'=> 'thanks',
        'tnxe6'=> 'thanks a million',
        'tptb'=> 'the powers that be',
        'ttbomk'=> 'to the best of my knowledge',
        'ttfn'=> 'ta ta for now',
        'ttksf'=> 'trying to keep a straight face',
        'ttyl'=> 'talk to you later',
        'tyvm'=> 'thank you very much',
        'uok'=> 'are you ok?',
        'w/o'=> 'without',
        'wb'=> 'welcome back',
        'wdyt'=> 'what do you think?',
        'wibni'=> 'wouldn\t it be nice if',
        'willg'=> 'will g',
        'wrt'=> 'with regard to,  or with respect to',
        'wtb'=> 'want to buy',
        'wtf'=> 'what the feck',
        'wtg'=> 'way to go!',
        'wtgp'=> 'want to go private?',
        'wth'=> 'what the hell?',
        'wygiswypf'=> 'what you get is what you pay for',
        'xoxoxo'=> 'kisses and hugs',
        'yaba'=> 'yet another bloody acronym',
        'yaun'=> 'yet another unix nerd',
        'ygti'=> 'you get the idea?',
        'ygwypf'=> 'you get what you pay for',
        'yiu'=> 'yes, i understand',
        'yiwgp'=> 'yes, i will go private',
        'ymmv'=> 'your mileage may vary',
);


%spellcorrect = (
        'Ameria'=> 'America',
        'I\"m'=> 'I\'m',
        'I\;d'=> 'I\'d',
        'I\;ll'=> 'I\'ll',
        'UnitedStates'=> 'United States',
        'abbout'=> 'about',
        'abotu'=> 'about',
        'abouta'=> 'about a',
        'aboutit'=> 'about it',
        'aboutthe'=> 'about the',
        'abscence'=> 'absence',
        'accesories'=> 'accessories',
        'accidant'=> 'accident',
        'accomodate'=> 'accommodate',
        'accordingto'=> 'according to',
        'accross'=> 'across',
        'acheive'=> 'achieve',
        'acheived'=> 'achieved',
        'acheiving'=> 'achieving',
        'acn'=> 'can',
        'acommodate'=> 'accommodate',
        'acomodate'=> 'accommodate',
        'actualyl'=> 'actually',
        'additinal'=> 'additional',
        'addtional'=> 'additional',
        'adequit'=> 'adequate',
        'adequite'=> 'adequate',
        'adn'=> 'and',
        'advanage'=> 'advantage',
        'affraid'=> 'afraid',
        'afterthe'=> 'after the',
        'againstt he'=> 'against the',
        'aganist'=> 'against',
        'aggresive'=> 'aggressive',
        'agian'=> 'again',
        'agreemeent'=> 'agreement',
        'agreemeents'=> 'agreements',
        'agreemnet'=> 'agreement',
        'agreemnets'=> 'agreements',
        'agressive'=> 'aggressive',
        'ahppen'=> 'happen',
        'ahve'=> 'have',
        'allwasy'=> 'always',
        'allwyas'=> 'always',
        'almots'=> 'almost',
        'almsot'=> 'almost',
        'alomst'=> 'almost',
        'alot'=> 'a lot',
        'alraedy'=> 'already',
        'alreayd'=> 'already',
        'alreday'=> 'already',
        'alwasy'=> 'always',
        'alwats'=> 'always',
        'alway'=> 'always',
        'alwyas'=> 'always',
        'amde'=> 'made',
        'amke'=> 'make',
        'amkes'=> 'makes',
        'anbd'=> 'and',
        'andone'=> 'and one',
        'andt he'=> 'and the',
        'andteh'=> 'and the',
        'andthe'=> 'and the',
        'anothe'=> 'another',
        'anual'=> 'annual',
        'apparant'=> 'apparent',
        'apparrent'=> 'apparent',
        'appearence'=> 'appearance',
        'appeares'=> 'appears',
        'applicaiton'=> 'application',
        'applicaitons'=> 'applications',
        'applyed'=> 'applied',
        'appointiment'=> 'appointment',
        'approrpiate'=> 'appropriate',
        'approrpriate'=> 'appropriate',
        'aquisition'=> 'acquisition',
        'aquisitions'=> 'acquisitions',
        'aren\;t'=> 'aren\'t',
        'arguement'=> 'argument',
        'arguements'=> 'arguments',
        'arn\'t'=> 'aren\'t',
        'arond'=> 'around',
        'artical'=> 'article',
        'articel'=> 'article',
        'asdvertising'=> 'advertising',
        'askt he'=> 'ask the',
        'assistent'=> 'assistant',
        'asthe'=> 'as the',
        'atention'=> 'attention',
        'atmospher'=> 'atmosphere',
        'attentioin'=> 'attention',
        'atthe'=> 'at the',
        'audeince'=> 'audience',
        'audiance'=> 'audience',
        'availalbe'=> 'available',
        'awya'=> 'away',
        'aywa'=> 'away',
        'bakc'=> 'back',
        'balence'=> 'balance',
        'ballance'=> 'balance',
        'baout'=> 'about',
        'bcak'=> 'back',
        'beacuse'=> 'because',
        'becasue'=> 'because',
        'becaus'=> 'because',
        'becausea'=> 'because a',
        'becauseof'=> 'because of',
        'becausethe'=> 'because the',
        'becauseyou'=> 'because you',
        'becomeing'=> 'becoming',
        'becomming'=> 'becoming',
        'becuase'=> 'because',
        'becuse'=> 'because',
        'befoer'=> 'before',
        'beggining'=> 'beginning',
        'begining'=> 'beginning',
        'beginining'=> 'beginning',
        'beleiev'=> 'believe',
        'beleieve'=> 'believe',
        'beleif'=> 'belief',
        'beleive'=> 'believe',
        'beleived'=> 'believed',
        'beleives'=> 'believes',
        'benifit'=> 'benefit',
        'benifits'=> 'benefits',
        'betwen'=> 'between',
        'beutiful'=> 'beautiful',
        'blase'=> 'blas\E9',
        'boxs'=> 'boxes',
        'brodcast'=> 'broadcast',
        'butthe'=> 'but the',
        'bve'=> 'be',
        'byt he'=> 'by the',
        'cafe'=> 'caf\E9',
        'caharcter'=> 'character',
        'calcullated'=> 'calculated',
        'calulated'=> 'calculated',
        'can\'t of been'=> 'can\'t have been',
        'can\;t'=> 'can\'t',
        'candidtae'=> 'candidate',
        'candidtaes'=> 'candidates',
        'catagory'=> 'category',
        'categiory'=> 'category',
        'certian'=> 'certain',
        'challange'=> 'challenge',
        'challanges'=> 'challenges',
        'chaneg'=> 'change',
        'chanegs'=> 'changes',
        'changable'=> 'changeable',
        'changeing'=> 'changing',
        'changng'=> 'changing',
        'charachter'=> 'character',
        'charachters'=> 'characters',
        'charactor'=> 'character',
        'charecter'=> 'character',
        'charector'=> 'character',
        'cheif'=> 'chief',
        'chekc'=> 'check',
        'chnage'=> 'change',
        'cieling'=> 'ceiling',
        'circut'=> 'circuit',
        'claer'=> 'clear',
        'claered'=> 'cleared',
        'claerly'=> 'clearly',
        'cliant'=> 'client',
        'cliche'=> 'clich\E9',
        'cna'=> 'can',
        'colection'=> 'collection',
        'comanies'=> 'companies',
        'comany'=> 'company',
        'comapnies'=> 'companies',
        'comapny'=> 'company',
        'combintation'=> 'combination',
        'comited'=> 'committed',
        'comittee'=> 'committee',
        'commadn'=> 'command',
        'comming'=> 'coming',
        'commitee'=> 'committee',
        'committe'=> 'committee',
        'committment'=> 'commitment',
        'committments'=> 'commitments',
        'committy'=> 'committee',
        'comntain'=> 'contain',
        'comntains'=> 'contains',
        'compair'=> 'compare',
        'company\;s'=> 'company\'s',
        'compleated'=> 'completed',
        'compleatly'=> 'completely',
        'compleatness'=> 'completeness',
        'completly'=> 'completely',
        'completness'=> 'completeness',
        'composate'=> 'composite',
        'comtain'=> 'contain',
        'comtains'=> 'contains',
        'comunicate'=> 'communicate',
        'comunity'=> 'community',
        'condolances'=> 'condolences',
        'conected'=> 'connected',
        'conferance'=> 'conference',
        'confirmmation'=> 'confirmation',
        'considerit'=> 'considerate',
        'considerite'=> 'considerate',
        'consonent'=> 'consonant',
        'conspiricy'=> 'conspiracy',
        'consultent'=> 'consultant',
        'convertable'=> 'convertible',
        'cooparate'=> 'cooperate',
        'cooporate'=> 'cooperate',
        'corproation'=> 'corporation',
        'corproations'=> 'corporations',
        'corruptable'=> 'corruptible',
        'cotten'=> 'cotton',
        'coudl'=> 'could',
        'coudln\'t'=> 'couldn\'t',
        'coudn\'t'=> 'couldn\'t',
        'could of been'=> 'could have been',
        'could of had'=> 'could have had',
        'couldn\;t'=> 'couldn\'t',
        'couldnt'=> 'couldn\'t',
        'couldthe'=> 'could the',
        'cpoy'=> 'copy',
        'creme'=> 'cr\E8me',
        'ctaegory'=> 'category',
        'cusotmer'=> 'customer',
        'cusotmers'=> 'customers',
        'cutsomer'=> 'customer',
        'cutsomers'=> 'customers',
        'cxan'=> 'can',
        'danceing'=> 'dancing',
        'dcument'=> 'document',
        'deatils'=> 'details',
        'decison'=> 'decision',
        'decisons'=> 'decisions',
        'decor'=> 'd\E9cor',
        'defendent'=> 'defendant',
        'definately'=> 'definitely',
        'deja vu'=> 'd\E9j\E0 vu',
        'deptartment'=> 'department',
        'desicion'=> 'decision',
        'desicions'=> 'decisions',
        'desision'=> 'decision',
        'desisions'=> 'decisions',
        'detente'=> 'd\E9tente',
        'develeoprs'=> 'developers',
        'devellop'=> 'develop',
        'develloped'=> 'developed',
        'develloper'=> 'developer',
        'devellopers'=> 'developers',
        'develloping'=> 'developing',
        'devellopment'=> 'development',
        'devellopments'=> 'developments',
        'devellops'=> 'develop',
        'develope'=> 'develop',
        'developement'=> 'development',
        'developements'=> 'developments',
        'developor'=> 'developer',
        'developors'=> 'developers',
        'develpment'=> 'development',
        'diaplay'=> 'display',
        'didint'=> 'didn\'t',
        'didn\;t'=> 'didn\'t',
        'didnot'=> 'did not',
        'didnt'=> 'didn\'t',
        'difefrent'=> 'different',
        'diferences'=> 'differences',
        'differance'=> 'difference',
        'differances'=> 'differences',
        'differant'=> 'different',
        'differemt'=> 'different',
        'differnt'=> 'different',
        'diffrent'=> 'different',
        'directer'=> 'director',
        'directers'=> 'directors',
        'directiosn'=> 'direction',
        'disatisfied'=> 'dissatisfied',
        'discoverd'=> 'discovered',
        'disign'=> 'design',
        'dispaly'=> 'display',
        'dissonent'=> 'dissonant',
        'distribusion'=> 'distribution',
        'divsion'=> 'division',
        'do\'nt'=> 'don\'t',
        'docuement'=> 'documents',
        'docuemnt'=> 'document',
        'documetn'=> 'document',
        'documnet'=> 'document',
        'documnets'=> 'documents',
        'doe snot'=> 'does not',
        'doens\'t'=> 'doesn\'t',
        'doese'=> 'does',
        'doesn\;t'=> 'doesn\'t',
        'doesnt'=> 'doesn\'t',
        'doign'=> 'doing',
        'doimg'=> 'doing',
        'doind'=> 'doing',
        'dollers'=> 'dollars',
        'don\'t no'=> 'don\'t know',
        'don\;t'=> 'don\'t',
        'donig'=> 'doing',
        'dont'=> 'don\'t',
        'dosn\'t'=> 'doesn\'t',
        'driveing'=> 'driving',
        'drnik'=> 'drink',
        'eclair'=> '\E9clair',
        'efel'=> 'feel',
        'effecient'=> 'efficient',
        'efort'=> 'effort',
        'eforts'=> 'efforts',
        'ehr'=> 'her',
        'eligable'=> 'eligible',
        'embarass'=> 'embarrass',
        'emigre'=> '\E9migr\E9',
        'enought'=> 'enough',
        'entree'=> 'entr\E9e',
        'equippment'=> 'equipment',
        'equivalant'=> 'equivalent',
        'esle'=> 'else',
        'especally'=> 'especially',
        'especialyl'=> 'especially',
        'espesially'=> 'especially',
        'excellant'=> 'excellent',
        'excercise'=> 'exercise',
        'exchagne'=> 'exchange',
        'exchagnes'=> 'exchanges',
        'excitment'=> 'excitement',
        'exhcange'=> 'exchange',
        'exhcanges'=> 'exchanges',
        'experiance'=> 'experience',
        'experienc'=> 'experience',
        'exprience'=> 'experience',
        'exprienced'=> 'experienced',
        'eyt'=> 'yet',
        'facade'=> 'fa\E7ade',
        'faeture'=> 'feature',
        'faetures'=> 'features',
        'familair'=> 'familiar',
        'familar'=> 'familiar',
        'familliar'=> 'familiar',
        'fammiliar'=> 'familiar',
        'feild'=> 'field',
        'feilds'=> 'fields',
        'fianlly'=> 'finally',
        'fidn'=> 'find',
        'finalyl'=> 'finally',
        'firends'=> 'friends',
        'firts'=> 'first',
        'follwo'=> 'follow',
        'follwoing'=> 'following',
        'fora'=> 'for a',
        'foriegn'=> 'foreign',
        'forthe'=> 'for the',
        'forwrd'=> 'forward',
        'forwrds'=> 'forwards',
        'foudn'=> 'found',
        'foward'=> 'forward',
        'fowards'=> 'forwards',
        'freind'=> 'friend',
        'freindly'=> 'friendly',
        'freinds'=> 'friends',
        'frmo'=> 'from',
        'fromt he'=> 'from the',
        'fromthe'=> 'from the',
        'furneral'=> 'funeral',
        'fwe'=> 'few',
        'garantee'=> 'guarantee',
        'gaurd'=> 'guard',
        'gemeral'=> 'general',
        'gerat'=> 'great',
        'geting'=> 'getting',
        'gettin'=> 'getting',
        'gievn'=> 'given',
        'giveing'=> 'giving',
        'gloabl'=> 'global',
        'goign'=> 'going',
        'gonig'=> 'going',
        'govenment'=> 'government',
        'goverment'=> 'government',
        'gruop'=> 'group',
        'gruops'=> 'groups',
        'grwo'=> 'grow',
        'guidlines'=> 'guidelines',
        'hadbeen'=> 'had been',
        'hadn\;t'=> 'hadn\'t',
        'haev'=> 'have',
        'hapen'=> 'happen',
        'hapened'=> 'happened',
        'hapening'=> 'happening',
        'hapens'=> 'happens',
        'happend'=> 'happened',
        'hasbeen'=> 'has been',
        'hasn\;t'=> 'hasn\'t',
        'hasnt'=> 'hasn\'t',
        'havebeen'=> 'have been',
        'haveing'=> 'having',
        'haven\;t'=> 'haven\'t',
        'hda'=> 'had',
        'he\;ll'=> 'he\'ll',
        'hearign'=> 'hearing',
        'helpfull'=> 'helpful',
        'herat'=> 'heart',
        'here\;s'=> 'here\'s',
        'hesaid'=> 'he said',
        'hewas'=> 'he was',
        'hge'=> 'he',
        'hismelf'=> 'himself',
        'hlep'=> 'help',
        'hsa'=> 'has',
        'hsi'=> 'his',
        'hte'=> 'the',
        'htere'=> 'there',
        'htese'=> 'these',
        'htey'=> 'they',
        'hting'=> 'thing',
        'htink'=> 'think',
        'htis'=> 'this',
        'hvae'=> 'have',
        'hvaing'=> 'having',
        'hwich'=> 'which',
        'i snot'=> 'is not',
        'idae'=> 'idea',
        'idaes'=> 'ideas',
        'identofy'=> 'identify',
        'ihs'=> 'his',
        'iits the'=> 'it\'s the',
        'imediate'=> 'immediate',
        'imediatly'=> 'immediately',
        'immediatly'=> 'immediately',
        'importent'=> 'important',
        'importnat'=> 'important',
        'impossable'=> 'impossible',
        'improvemnt'=> 'improvement',
        'improvment'=> 'improvement',
        'includ'=> 'include',
        'indecate'=> 'indicate',
        'indenpendence'=> 'independence',
        'indenpendent'=> 'independent',
        'indepedent'=> 'independent',
        'independance'=> 'independence',
        'independant'=> 'independent',
        'influance'=> 'influence',
        'infomation'=> 'information',
        'informatoin'=> 'information',
        'inital'=> 'initial',
        'instaleld'=> 'installed',
        'insted'=> 'instead',
        'insurence'=> 'insurance',
        'int he'=> 'in the',
        'inteh'=> 'in the',
        'interum'=> 'interim',
        'inthe'=> 'in the',
        'inwhich'=> 'in which',
        'isn\;t'=> 'isn\'t',
        'isthe'=> 'is the',
        'it snot'=> 'it\'s not',
        'it\' snot'=> 'it\'s not',
        'it\;ll'=> 'it\'ll',
        'it\;s'=> 'it\'s',
        'itis'=> 'it is',
        'ititial'=> 'initial',
        'itnerest'=> 'interest',
        'itnerested'=> 'interested',
        'itneresting'=> 'interesting',
        'itnerests'=> 'interests',
        'its a'=> 'it\'s a',
        'its the'=> 'it\'s the',
        'itwas'=> 'it was',
        'iwll'=> 'will',
        'iwth'=> 'with',
        'jsut'=> 'just',
        'jugment'=> 'judgment',
        'knowldge'=> 'knowledge',
        'knowlege'=> 'knowledge',
        'knwo'=> 'know',
        'knwon'=> 'known',
        'knwos'=> 'knows',
        'konw'=> 'know',
        'konwn'=> 'known',
        'konws'=> 'knows',
        'labratory'=> 'laboratory',
        'lastyear'=> 'last year',
        'learnign'=> 'learning',
        'lenght'=> 'length',
        'let\'s him'=> 'lets him',
        'let\'s it'=> 'lets it',
        'let\;s'=> 'let\'s',
        'levle'=> 'level',
        'libary'=> 'library',
        'librarry'=> 'library',
        'librery'=> 'library',
        'liek'=> 'like',
        'liekd'=> 'liked',
        'lieutenent'=> 'lieutenant',
        'liev'=> 'live',
        'likly'=> 'likely',
        'lisense'=> 'license',
        'littel'=> 'little',
        'litttle'=> 'little',
        'liuke'=> 'like',
        'liveing'=> 'living',
        'loev'=> 'love',
        'lonly'=> 'lonely',
        'lookign'=> 'looking',
        'maintenence'=> 'maintenance',
        'makeing'=> 'making',
        'managment'=> 'management',
        'mantain'=> 'maintain',
        'marraige'=> 'marriage',
        'may of been'=> 'may have been',
        'may of had'=> 'may have had',
        'memeber'=> 'member',
        'merchent'=> 'merchant',
        'mesage'=> 'message',
        'mesages'=> 'messages',
        'might of been'=> 'might have been',
        'might of had'=> 'might have had',
        'mispell'=> 'misspell',
        'mispelling'=> 'misspelling',
        'mispellings'=> 'misspellings',
        'mkae'=> 'make',
        'mkaes'=> 'makes',
        'mkaing'=> 'making',
        'moeny'=> 'money',
        'morgage'=> 'mortgage',
        'mroe'=> 'more',
        'msot'=> 'most',
        'must of been'=> 'must have been',
        'must of had'=> 'must have had',
        'mysefl'=> 'myself',
        'myu'=> 'my',
        'naive'=> 'na\EFve',
        'necassarily'=> 'necessarily',
        'necassary'=> 'necessary',
        'neccessarily'=> 'necessarily',
        'neccessary'=> 'necessary',
        'necesarily'=> 'necessarily',
        'necesary'=> 'necessary',
        'negotiaing'=> 'negotiating',
        'nkow'=> 'know',
        'nothign'=> 'nothing',
        'nver'=> 'never',
        'nwe'=> 'new',
        'nwo'=> 'now',
        'obediant'=> 'obedient',
        'ocasion'=> 'occasion',
        'occassion'=> 'occasion',
        'occured'=> 'occurred',
        'occurence'=> 'occurrence',
        'occurrance'=> 'occurrence',
        'ocur'=> 'occur',
        'oeprator'=> 'operator',
        'ofits'=> 'of its',
        'oft he'=> 'of the',
        'ofthe'=> 'of the',
        'oging'=> 'going',
        'ohter'=> 'other',
        'omre'=> 'more',
        'oneof'=> 'one of',
        'onepoint'=> 'one point',
        'ont he'=> 'on the',
        'onthe'=> 'on the',
        'onyl'=> 'only',
        'oppasite'=> 'opposite',
        'opperation'=> 'operation',
        'oppertunity'=> 'opportunity',
        'opposate'=> 'opposite',
        'opposible'=> 'opposable',
        'opposit'=> 'opposite',
        'oppotunities'=> 'opportunities',
        'oppotunity'=> 'opportunity',
        'orginization'=> 'organization',
        'orginized'=> 'organized',
        'otehr'=> 'other',
        'otu'=> 'out',
        'outof'=> 'out of',
        'overthe'=> 'over the',
        'owrk'=> 'work',
        'owuld'=> 'would',
        'oxident'=> 'oxidant',
        'papaer'=> 'paper',
        'parliment'=> 'parliament',
        'partof'=> 'part of',
        'paymetn'=> 'payment',
        'paymetns'=> 'payments',
        'pciture'=> 'picture',
        'peice'=> 'piece',
        'peices'=> 'pieces',
        'peolpe'=> 'people',
        'peopel'=> 'people',
        'percentof'=> 'percent of',
        'percentto'=> 'percent to',
        'performence'=> 'performance',
        'perhasp'=> 'perhaps',
        'perhpas'=> 'perhaps',
        'permanant'=> 'permanent',
        'perminent'=> 'permanent',
        'personalyl'=> 'personally',
        'pleasent'=> 'pleasant',
        'poeple'=> 'people',
        'porblem'=> 'problem',
        'porblems'=> 'problems',
        'porvide'=> 'provide',
        'possable'=> 'possible',
        'postition'=> 'position',
        'potentialy'=> 'potentially',
        'pregnent'=> 'pregnant',
        'presance'=> 'presence',
        'probelm'=> 'problem',
        'probelms'=> 'problems',
        'prominant'=> 'prominent',
        'protege'=> 'prot\E9g\E9',
        'protoge'=> 'prot\E9g\E9',
        'psoition'=> 'position',
        'ptogress'=> 'progress',
        'puting'=> 'putting',
        'pwoer'=> 'power',
        'quater'=> 'quarter',
        'quaters'=> 'quarters',
        'quesion'=> 'question',
        'quesions'=> 'questions',
        'questioms'=> 'questions',
        'questiosn'=> 'questions',
        'questoin'=> 'question',
        'quetion'=> 'question',
        'quetions'=> 'questions',
        'realyl'=> 'really',
        'reccomend'=> 'recommend',
        'reccommend'=> 'recommend',
        'receieve'=> 'receive',
        'recieve'=> 'receive',
        'recieved'=> 'received',
        'recieving'=> 'receiving',
        'recomend'=> 'recommend',
        'recomendation'=> 'recommendation',
        'recomendations'=> 'recommendations',
        'recomended'=> 'recommended',
        'reconize'=> 'recognize',
        'recrod'=> 'record',
        'religous'=> 'religious',
        'reluctent'=> 'reluctant',
        'remeber'=> 'remember',
        'reommend'=> 'recommend',
        'representativs'=> 'representatives',
        'representives'=> 'representatives',
        'represetned'=> 'represented',
        'represnt'=> 'represent',
        'reserach'=> 'research',
        'resollution'=> 'resolution',
        'resorces'=> 'resources',
        'respomd'=> 'respond',
        'respomse'=> 'response',
        'responce'=> 'response',
        'responsability'=> 'responsibility',
        'responsable'=> 'responsible',
        'responsibile'=> 'responsible',
        'responsiblity'=> 'responsibility',
        'restaraunt'=> 'restaurant',
        'restuarant'=> 'restaurant',
        'reult'=> 'result',
        'reveiw'=> 'review',
        'reveiwing'=> 'reviewing',
        'rumers'=> 'rumors',
        'rwite'=> 'write',
        'rythm'=> 'rhythm',
        'saidhe'=> 'said he',
        'saidit'=> 'said it',
        'saidt he'=> 'said the',
        'saidthat'=> 'said that',
        'saidthe'=> 'said the',
        'scedule'=> 'schedule',
        'sceduled'=> 'scheduled',
        'seance'=> 's\E9ance',
        'secratary'=> 'secretary',
        'sectino'=> 'section',
        'seh'=> 'she',
        'selectoin'=> 'selection',
        'sentance'=> 'sentence',
        'separeate'=> 'separate',
        'seperate'=> 'separate',
        'sercumstances'=> 'circumstances',
        'shcool'=> 'school',
        'she\;ll'=> 'she\'ll',
        'shesaid'=> 'she said',
        'shineing'=> 'shining',
        'shiped'=> 'shipped',
        'shoudl'=> 'should',
        'shoudln\'t'=> 'shouldn\'t',
        'should of been'=> 'should have been',
        'should of had'=> 'should have had',
        'shouldent'=> 'shouldn\'t',
        'shouldn\;t'=> 'shouldn\'t',
        'shouldnt'=> 'shouldn\'t',
        'showinf'=> 'showing',
        'signifacnt'=> 'significant',
        'simalar'=> 'similar',
        'similiar'=> 'similar',
        'simpyl'=> 'simply',
        'sincerly'=> 'sincerely',
        'sitll'=> 'still',
        'smae'=> 'same',
        'smoe'=> 'some',
        'soem'=> 'some',
        'sohw'=> 'show',
        'soical'=> 'social',
        'somethign'=> 'something',
        'someting'=> 'something',
        'somewaht'=> 'somewhat',
        'somthing'=> 'something',
        'somtimes'=> 'sometimes',
        'sot hat'=> 'so that',
        'soudn'=> 'sound',
        'soudns'=> 'sounds',
        'speach'=> 'speech',
        'specificaly'=> 'specifically',
        'specificalyl'=> 'specifically',
        'statment'=> 'statement',
        'statments'=> 'statements',
        'stnad'=> 'stand',
        'stopry'=> 'story',
        'stoyr'=> 'story',
        'stpo'=> 'stop',
        'strentgh'=> 'strength',
        'stroy'=> 'story',
        'struggel'=> 'struggle',
        'strugle'=> 'struggle',
        'studnet'=> 'student',
        'successfull'=> 'successful',
        'successfuly'=> 'successfully',
        'successfulyl'=> 'successfully',
        'sucess'=> 'success',
        'sucessfull'=> 'successful',
        'sufficiant'=> 'sufficient',
        'suposed'=> 'supposed',
        'suppossed'=> 'supposed',
        'suprise'=> 'surprise',
        'suprised'=> 'surprised',
        'swiming'=> 'swimming',
        'tahn'=> 'than',
        'taht'=> 'that',
        'talekd'=> 'talked',
        'talkign'=> 'talking',
        'tath'=> 'that',
        'tecnical'=> 'technical',
        'teh'=> 'the',
        'tehy'=> 'they',
        'tellt he'=> 'tell the',
        'termoil'=> 'turmoil',
        'tghe'=> 'the',
        'tghis'=> 'this',
        'thansk'=> 'thanks',
        'thats'=> 'that\'s',
        'thatt he'=> 'that the',
        'thatthe'=> 'that the',
        'thecompany'=> 'the company',
        'thefirst'=> 'the first',
        'thegovernment'=> 'the government',
        'their are'=> 'there are',
        'their is'=> 'there is',
        'themself'=> 'themselves',
        'themselfs'=> 'themselves',
        'thenew'=> 'the new',
        'there\'s is'=> 'theirs is',
        'theri'=> 'their',
        'thesame'=> 'the same',
        'thetwo'=> 'the two',
        'they\'re are'=> 'there are',
        'they\'re is'=> 'there is',
        'they\;l'=> 'they\'ll',
        'they\;ll'=> 'they\'ll',
        'they\;r'=> 'they\'re',
        'they\;re'=> 'they\'re',
        'they\;v'=> 'they\'ve',
        'they\;ve'=> 'they\'ve',
        'theyll'=> 'they\'ll',
        'theyve'=> 'they\'ve',
        'thgat'=> 'that',
        'thge'=> 'the',
        'thier'=> 'their',
        'thigsn'=> 'things',
        'thisyear'=> 'this year',
        'thna'=> 'than',
        'thne'=> 'then',
        'thnig'=> 'thing',
        'thnigs'=> 'things',
        'threatend'=> 'threatened',
        'thsi'=> 'this',
        'thsoe'=> 'those',
        'thta'=> 'that',
        'tihs'=> 'this',
        'timne'=> 'time',
        'tiogether'=> 'together',
        'tje'=> 'the',
        'tjhe'=> 'the',
        'tkae'=> 'take',
        'tkaes'=> 'takes',
        'tkaing'=> 'taking',
        'tlaking'=> 'talking',
        'todya'=> 'today',
        'togehter'=> 'together',
        'toldt he'=> 'told the',
        'tomorow'=> 'tomorrow',
        'tongiht'=> 'tonight',
        'tonihgt'=> 'tonight',
        'totaly'=> 'totally',
        'totalyl'=> 'totally',
        'tothe'=> 'to the',
        'towrad'=> 'toward',
        'traditionalyl'=> 'traditionally',
        'transfered'=> 'transferred',
        'truely'=> 'truly',
        'truley'=> 'truly',
        'tryed'=> 'tried',
        'tthe'=> 'the',
        'tyhat'=> 'that',
        'tyhe'=> 'the',
        'udnerstand'=> 'understand',
        'understnad'=> 'understand',
        'undert he'=> 'under the',
        'unliek'=> 'unlike',
        'unpleasently'=> 'unpleasantly',
        'untilll'=> 'until',
        'useing'=> 'using',
        'usualyl'=> 'usually',
        'veyr'=> 'very',
        'virtualyl'=> 'virtually',
        'vis-a-vis'=> 'vis-\E0-vis',
        'vrey'=> 'very',
        'vulnerible'=> 'vulnerable',
        'wa snot'=> 'was not',
        'waht'=> 'what',
        'warrent'=> 'warrant',
        'wasnt'=> 'wasn\'t',
        'watn'=> 'want',
        'we\;d'=> 'we\'d',
        'we\;ll'=> 'we\'ll',
        'we\;re'=> 'we\'re',
        'we\;ve'=> 'we\'ve',
        'wehn'=> 'when',
        'wern\'t'=> 'weren\'t',
        'werre'=> 'were',
        'what\;s'=> 'what\'s',
        'whcih'=> 'which',
        'whent he'=> 'when the',
        'where\;s'=> 'where\'s',
        'wherre'=> 'where',
        'whic'=> 'which',
        'whicht he'=> 'which the',
        'whihc'=> 'which',
        'who\;s'=> 'who\'s',
        'who\;ve'=> 'who\'ve',
        'whta'=> 'what',
        'wief'=> 'wife',
        'wierd'=> 'weird',
        'wihch'=> 'which',
        'wiht'=> 'with',
        'will of been'=> 'will have been',
        'will of had'=> 'will have had',
        'willbe'=> 'will be',
        'windoes'=> 'windows',
        'witha'=> 'with a',
        'withe'=> 'with',
        'witht he'=> 'with the',
        'withthe'=> 'with the',
        'wiull'=> 'will',
        'wnat'=> 'want',
        'wnated'=> 'wanted',
        'wnats'=> 'wants',
        'wo\'nt'=> 'won\'t',
        'woh'=> 'who',
        'wohle'=> 'whole',
        'wokr'=> 'work',
        'won\;t'=> 'won\'t',
        'woudl'=> 'would',
        'woudln\'t'=> 'wouldn\'t',
        'would of been'=> 'would have been',
        'would of had'=> 'would have had',
        'wouldbe'=> 'would be',
        'wouldn\;t'=> 'wouldn\'t',
        'wouldnt'=> 'wouldn\'t',
        'wriet'=> 'write',
        'writting'=> 'writing',
        'wrod'=> 'word',
        'wroet'=> 'wrote',
        'wroking'=> 'working',
        'wtih'=> 'with',
        'wuould'=> 'would',
        'wya'=> 'way',
        'yera'=> 'year',
        'yeras'=> 'years',
        'yersa'=> 'years',
        'yoiu'=> 'you',
        'you\'re own'=> 'your own',
        'you\;d'=> 'you\'d',
        'you\;re'=> 'you\'re',
        'youare'=> 'you are',
        'your a'=> 'you\'re a',
        'your an'=> 'you\'re an',
        'your her'=> 'you\'re her',
        'your here'=> 'you\'re here',
        'your his'=> 'you\'re his',
        'your my'=> 'you\'re my',
        'your the'=> 'you\'re the',
        'your their'=> 'you\'re their',
        'your your'=> 'you\'re your',
        'youve'=> 'you\'ve',
        'ytou'=> 'you',
        'yuo'=> 'you',
        'yuor'=> 'your',
);

IRC::register ($MY_NAME, $VERSION, "cmd_speechoff", "");
IRC::print("*** \0038,2$MY_NAME text->speech module $VERSION loaded \003");
IRC::add_command_handler("speechon", cmd_speechon); 
IRC::add_command_handler("speechoff", cmd_speechoff); 

$lastthingsaid = "";

sub spch_substitute {
 my $linein=$_[0];
 my ($sub,$lineout);
 foreach my $word (split(' ',$linein)) {
 # $sub=$wordsub{$word};
  $sub=$wordsub{$word} unless $sub;
  if ($sub) {
   $lineout.=" $sub ";
  } else {
   $lineout.=" $word ";
  }
  undef($sub);
 }
 return($lineout);
}

sub spch_spellcorrect {
 my $linein=$_[0];
 my ($sub,$lineout);
 foreach my $word (split(' ',$linein)) {
  $sub=$spellcorrect{$word};
  $sub=$spellcorrect{$word} unless $sub;
  if ($sub) {
   $lineout.=" $sub ";
  } else {
   $lineout.=" $word ";
  }
 }
 return($lineout);
}

sub cmd_speechon {

 if (!defined($speech_pipe)) {
  open(SPEECH,"|$festival 2>&1 >/dev/null") || do { &print("*E* Error opening pipe to $festival"); return; };
  $fhcp=select(SPEECH);
  $|=1;
  select($fhcp);
  $speech_pipe=1;
  IRC::print("*** Speech activated!");
  $DEBUG && IRC::add_message_handler("NOTICE","speak");

  for my $handle ( @HANDLERS ) {
   IRC::add_message_handler($handle, "speak");
  }

  print SPEECH "($VOICE)\n";
  print SPEECH "(Parameter.set 'Duration_Stretch $SPEED)\n";
  &speak("Speech activated");
  return(1);
 }
}

sub cmd_speechoff {
 defined($speech_pipe) || return;
 IRC::print("*** Speech disabled");
 &speak("Speech disabled");
 undef($speech_pipe);
 close(SPEECH);
 return(1);
}

sub speak {
 defined($speech_pipe) || return;
 my $speakline;
 my $talk = 0;

 $speakline=$_[0];
 $speakline = lc($speakline);
 # parse the privmsg
 if ($DEBUG) { IRC::print("incoming: $speakline\n"); }

 if ($speakline eq $lastthingsaid) {
  if ($DEBUG) {IRC::print("Repeating last line\n");}
  return 0;
 }

 $lastthingsaid = $speakline;

 # Cleanup text
 foreach my $convert (keys %regex_convert) {
  if ($speakline=~/^:(.*)!.*$convert[^:]*:(.*)/) {
   $speakline = "$1 $regex_convert{$convert} $2";
   if ($DEBUG) {IRC::print("event_match $convert\n,");}
   break;
  }
 }

 if ($DEBUG) {if ($speakline=~/.*notice[^:]*:(.*)/) { $speakline="Server says $1"; $talk = 1; }}

 # Find match
 for my $regex ( @MyKeyWordsRegeXs ) {
  if ( $speakline=~ /$regex/i) {
   $talk = 1;
   if ($DEBUG) {IRC::print("Match found for $regex\n");}
   break;
  }
 }

 if ($talk == 0) {
  if ($DEBUG) {IRC::print("No Match found for '$speakline' - no words\n");}
  return 0;
 }

 $speakline=&spch_substitute($speakline);
 $speakline=&spch_spellcorrect($speakline);
 $speakline =~ tr/a-z0-9,.<>?'@+=&%$\A3!\/: ]//cd;
 $speakline =~ s/ +/ /g; # Collapse spaces
 $speakline =~ s/\.{2,}/ /g; # Collapse multiple dots
 $DEBUG && IRC::print("Will say '$speakline'\n\$1 = $speaker \$2 = $message talk=$talk\n");
 print SPEECH "(SayText \"$speakline\")\n";
 return 0;
}

IRC::command("/speechon");

#END OF PROGRAM
######################################################################################
## LICENSE INFORMATION
#
#       GNU GENERAL PUBLIC LICENSE
#          Version 2, June 1991
# 
#  Copyright (C) 1989, 1991 Free Software Foundation, Inc.
#                           675 Mass Ave, Cambridge, MA 02139, USA
#  Everyone is permitted to copy and distribute verbatim copies
#  of this license document, but changing it is not allowed.
# 
#        Preamble
# 
#   The licenses for most software are designed to take away your
# freedom to share and change it.  By contrast, the GNU General Public
# License is intended to guarantee your freedom to share and change free
# software--to make sure the software is free for all its users.  This
# General Public License applies to most of the Free Software
# Foundation's software and to any other program whose authors commit to
# using it.  (Some other Free Software Foundation software is covered by
# the GNU Library General Public License instead.)  You can apply it to
# your programs, too.
# 
#   When we speak of free software, we are referring to freedom, not
# price.  Our General Public Licenses are designed to make sure that you
# have the freedom to distribute copies of free software (and charge for
# this service if you wish), that you receive source code or can get it
# if you want it, that you can change the software or use pieces of it
# in new free programs; and that you know you can do these things.
# 
#   To protect your rights, we need to make restrictions that forbid
# anyone to deny you these rights or to ask you to surrender the rights.
# These restrictions translate to certain responsibilities for you if you
# distribute copies of the software, or if you modify it.
# 
#   For example, if you distribute copies of such a program, whether
# gratis or for a fee, you must give the recipients all the rights that
# you have.  You must make sure that they, too, receive or can get the
# source code.  And you must show them these terms so they know their
# rights.
# 
#   We protect your rights with two steps: (1) copyright the software, and
# (2) offer you this license which gives you legal permission to copy,
# distribute and/or modify the software.
# 
#   Also, for each author's protection and ours, we want to make certain
# that everyone understands that there is no warranty for this free
# software.  If the software is modified by someone else and passed on, we
# want its recipients to know that what they have is not the original, so
# that any problems introduced by others will not reflect on the original
# authors' reputations.
# 
#   Finally, any free program is threatened constantly by software
# patents.  We wish to avoid the danger that redistributors of a free
# program will individually obtain patent licenses, in effect making the
# program proprietary.  To prevent this, we have made it clear that any
# patent must be licensed for everyone's free use or not licensed at all.
# 
#   The precise terms and conditions for copying, distribution and
# modification follow.
#  
#       GNU GENERAL PUBLIC LICENSE
#    TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
# 
#   0. This License applies to any program or other work which contains
# a notice placed by the copyright holder saying it may be distributed
# under the terms of this General Public License.  The "Program", below,
# refers to any such program or work, and a "work based on the Program"
# means either the Program or any derivative work under copyright law:
# that is to say, a work containing the Program or a portion of it,
# either verbatim or with modifications and/or translated into another
# language.  (Hereinafter, translation is included without limitation in
# the term "modification".)  Each licensee is addressed as "you".
# 
# Activities other than copying, distribution and modification are not
# covered by this License; they are outside its scope.  The act of
# running the Program is not restricted, and the output from the Program
# is covered only if its contents constitute a work based on the
# Program (independent of having been made by running the Program).
# Whether that is true depends on what the Program does.
# 
#   1. You may copy and distribute verbatim copies of the Program's
# source code as you receive it, in any medium, provided that you
# conspicuously and appropriately publish on each copy an appropriate
# copyright notice and disclaimer of warranty; keep intact all the
# notices that refer to this License and to the absence of any warranty;
# and give any other recipients of the Program a copy of this License
# along with the Program.
# 
# You may charge a fee for the physical act of transferring a copy, and
# you may at your option offer warranty protection in exchange for a fee.
# 
#   2. You may modify your copy or copies of the Program or any portion
# of it, thus forming a work based on the Program, and copy and
# distribute such modifications or work under the terms of Section 1
# above, provided that you also meet all of these conditions:
# 
#     a) You must cause the modified files to carry prominent notices
#     stating that you changed the files and the date of any change.
# 
#     b) You must cause any work that you distribute or publish, that in
#     whole or in part contains or is derived from the Program or any
#     part thereof, to be licensed as a whole at no charge to all third
#     parties under the terms of this License.
# 
#     c) If the modified program normally reads commands interactively
#     when run, you must cause it, when started running for such
#     interactive use in the most ordinary way, to print or display an
#     announcement including an appropriate copyright notice and a
#     notice that there is no warranty (or else, saying that you provide
#     a warranty) and that users may redistribute the program under
#     these conditions, and telling the user how to view a copy of this
#     License.  (Exception: if the Program itself is interactive but
#     does not normally print such an announcement, your work based on
#     the Program is not required to print an announcement.)
# 
# These requirements apply to the modified work as a whole.  If
# identifiable sections of that work are not derived from the Program,
# and can be reasonably considered independent and separate works in
# themselves, then this License, and its terms, do not apply to those
# sections when you distribute them as separate works.  But when you
# distribute the same sections as part of a whole which is a work based
# on the Program, the distribution of the whole must be on the terms of
# this License, whose permissions for other licensees extend to the
# entire whole, and thus to each and every part regardless of who wrote it.
# 
# Thus, it is not the intent of this section to claim rights or contest
# your rights to work written entirely by you; rather, the intent is to
# exercise the right to control the distribution of derivative or
# collective works based on the Program.
# 
# In addition, mere aggregation of another work not based on the Program
# with the Program (or with a work based on the Program) on a volume of
# a storage or distribution medium does not bring the other work under
# the scope of this License.
# 
#   3. You may copy and distribute the Program (or a work based on it,
# under Section 2) in object code or executable form under the terms of
# Sections 1 and 2 above provided that you also do one of the following:
# 
#     a) Accompany it with the complete corresponding machine-readable
#     source code, which must be distributed under the terms of Sections
#     1 and 2 above on a medium customarily used for software interchange; or,
# 
#     b) Accompany it with a written offer, valid for at least three
#     years, to give any third party, for a charge no more than your
#     cost of physically performing source distribution, a complete
#     machine-readable copy of the corresponding source code, to be
#     distributed under the terms of Sections 1 and 2 above on a medium
#     customarily used for software interchange; or,
# 
#     c) Accompany it with the information you received as to the offer
#     to distribute corresponding source code.  (This alternative is
#     allowed only for noncommercial distribution and only if you
#     received the program in object code or executable form with such
#     an offer, in accord with Subsection b above.)
# 
# The source code for a work means the preferred form of the work for
# making modifications to it.  For an executable work, complete source
# code means all the source code for all modules it contains, plus any
# associated interface definition files, plus the scripts used to
# control compilation and installation of the executable.  However, as a
# special exception, the source code distributed need not include
# anything that is normally distributed (in either source or binary
# form) with the major components (compiler, kernel, and so on) of the
# operating system on which the executable runs, unless that component
# itself accompanies the executable.
# 
# If distribution of executable or object code is made by offering
# access to copy from a designated place, then offering equivalent
# access to copy the source code from the same place counts as
# distribution of the source code, even though third parties are not
# compelled to copy the source along with the object code.
# 
#   4. You may not copy, modify, sublicense, or distribute the Program
# except as expressly provided under this License.  Any attempt
# otherwise to copy, modify, sublicense or distribute the Program is
# void, and will automatically terminate your rights under this License.
# However, parties who have received copies, or rights, from you under
# this License will not have their licenses terminated so long as such
# parties remain in full compliance.
# 
#   5. You are not required to accept this License, since you have not
# signed it.  However, nothing else grants you permission to modify or
# distribute the Program or its derivative works.  These actions are
# prohibited by law if you do not accept this License.  Therefore, by
# modifying or distributing the Program (or any work based on the
# Program), you indicate your acceptance of this License to do so, and
# all its terms and conditions for copying, distributing or modifying
# the Program or works based on it.
# 
#   6. Each time you redistribute the Program (or any work based on the
# Program), the recipient automatically receives a license from the
# original licensor to copy, distribute or modify the Program subject to
# these terms and conditions.  You may not impose any further
# restrictions on the recipients' exercise of the rights granted herein.
# You are not responsible for enforcing compliance by third parties to
# this License.
# 
#   7. If, as a consequence of a court judgment or allegation of patent
# infringement or for any other reason (not limited to patent issues),
# conditions are imposed on you (whether by court order, agreement or
# otherwise) that contradict the conditions of this License, they do not
# excuse you from the conditions of this License.  If you cannot
# distribute so as to satisfy simultaneously your obligations under this
# License and any other pertinent obligations, then as a consequence you
# may not distribute the Program at all.  For example, if a patent
# license would not permit royalty-free redistribution of the Program by
# all those who receive copies directly or indirectly through you, then
# the only way you could satisfy both it and this License would be to
# refrain entirely from distribution of the Program.
# 
# If any portion of this section is held invalid or unenforceable under
# any particular circumstance, the balance of the section is intended to
# apply and the section as a whole is intended to apply in other
# circumstances.
# 
# It is not the purpose of this section to induce you to infringe any
# patents or other property right claims or to contest validity of any
# such claims; this section has the sole purpose of protecting the
# integrity of the free software distribution system, which is
# implemented by public license practices.  Many people have made
# generous contributions to the wide range of software distributed
# through that system in reliance on consistent application of that
# system; it is up to the author/donor to decide if he or she is willing
# to distribute software through any other system and a licensee cannot
# impose that choice.
# 
# This section is intended to make thoroughly clear what is believed to
# be a consequence of the rest of this License.
# 
#   8. If the distribution and/or use of the Program is restricted in
# certain countries either by patents or by copyrighted interfaces, the
# original copyright holder who places the Program under this License
# may add an explicit geographical distribution limitation excluding
# those countries, so that distribution is permitted only in or among
# countries not thus excluded.  In such case, this License incorporates
# the limitation as if written in the body of this License.
# 
#   9. The Free Software Foundation may publish revised and/or new versions
# of the General Public License from time to time.  Such new versions will
# be similar in spirit to the present version, but may differ in detail to
# address new problems or concerns.
# 
# Each version is given a distinguishing version number.  If the Program
# specifies a version number of this License which applies to it and "any
# later version", you have the option of following the terms and conditions
# either of that version or of any later version published by the Free
# Software Foundation.  If the Program does not specify a version number of
# this License, you may choose any version ever published by the Free Software
# Foundation.
# 
#   10. If you wish to incorporate parts of the Program into other free
# programs whose distribution conditions are different, write to the author
# to ask for permission.  For software which is copyrighted by the Free
# Software Foundation, write to the Free Software Foundation; we sometimes
# make exceptions for this.  Our decision will be guided by the two goals
# of preserving the free status of all derivatives of our free software and
# of promoting the sharing and reuse of software generally.
# 
#        NO WARRANTY
# 
#   11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
# FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
# OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
# PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
# OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
# TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
# PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
# REPAIR OR CORRECTION.
# 
#   12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
# WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
# REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
# INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
# OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
# TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
# YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
# PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGES.
# 
#        END OF TERMS AND CONDITIONS

No comments: