where is Microsoft Speech Object Library 5.1 option inPythonWin 2.5?

Jussi Salmela tiedon_jano at hotmail.com
Fri Jan 5 21:41:32 CET 2007

Siggi kirjoitti:
> Gabriel Genellina wrote:
>> After you download and install version 5.1, it should appear on the list.
> It should, but it does not! Shutting down and starting the WinXP Home system 
> anew did not help.
> The SDK 5.1 installation went smoothly, however. What can I do to find out
> what is wrong?
> siggi

(Sorry for the long post!)

Unfortunately I can't comment on this 5.0/5.1 issue but if you look at page
you'll find the pyTTS system. I've used it and everything works.

The funny thing is that the page has a link named "Microsoft SAPI 5.1 
redistributable" which links to
ie. a SAPI 5 installer. So I'm starting to wonder if it matters at all 
whether the speech kit is a version 5 or 5.1.

Anyway: pyTTS works with Python 2.4 as advertized in the accompanying 
examples. I've used it to resolve the following dilemma: how to 
guarantee that I'm aware of new mail appearing on my ISP.

I had an unfortunate experience where a guy I was working with sent me 
(to my home) mail that I didn't expect to receive just at the moment and 
to which I would have liked to react immediately. Why I didn't notice 
the mail coming: I was outside my house pumping more air to my wife's 
bicycle tires! The mail notification was shown and erased and one more 
icon among the more than dozen icons on my Windows System Tray didn't 
account for much.

So I figured out that a voice to remind me would be nice. I have a low 
rate inbox, usually only a maximum of hald a dozen messages per day so I 
wouldn't have to listen the voice all day long. So the voice keeps 
repeating that I have new mail at my ISP until I download the mail and 
otherwise keeps quiet. So here is my program and a skeleton of the INI 
file it uses. The program is not finished (I have a few ideas still) but 
it runs all day long on my computer keeping me happy.

New Email Notifier.py

     License: MIT License. See License.txt. If that file is not attached,
     the license is http://www.opensource.org/licenses/mit-license.php, 
     <year> = 2006 and <copyright holders> = Jussi Salmela, Turku, Finland

# This program checks for new email at ISP and notifies if new email is 

import win32serviceutil
import win32service
import win32event
import pyTTS, sys, os, poplib, logging, time
import ConfigParser,pywintypes

print '\nThis is the New Mail Notifier window\n'
notifierDirectory = r'C:\Python\OMAT___PROJEKTIT\New Email Notifier Service'
                     format='%(asctime)s %(levelname)-8s %(message)s',
logging.info('New Email Notifier Service started')
config = ConfigParser.ConfigParser()
config.readfp(open(notifierDirectory+r'\New Email Notifier.INI'))
POP3Server = config.get('POP3','server')
POP3Account = config.get('POP3','account')
POP3Password = config.get('POP3','password')
totalMessagesFormat = config.get('messages','total_message')
newMessagesFormat = config.get('messages','new_message')
wakeupMessageFormat = config.get('messages','wakeup_message')

tts = pyTTS.Create()
#set the speech volume percentage (0-100%)
tts.Volume = 100
#explicitly set a voice

uidDict = {}
# We wait to be stopped and check for new email every maxTimeToWait seconds
maxTimeToWait = 1 # First check after 1 second
while True:
     maxTimeToWait = 60 # Rest of the checks after 60 second
         # Connect to the ISP
         a = poplib.POP3(POP3Server,110)
         answer = a.getwelcome()
         if answer[0:3] != '+OK':
             raise ValueError,'a.getwelcome returned: ' + answer
         answer = a.user(POP3Account)
         if answer[0:3] != '+OK':
             raise ValueError,'a.user returned: ' + answer
         if answer[4:] == 'Password required':
             answer = a.pass_(POP3Password)
             if answer[0:3] != '+OK':
                 raise ValueError,'a.pass_ returned: ' + answer
         answer = a.uidl()
         if answer[0][0:3] != '+OK':
             raise ValueError,'a.uidl returned: ' + repr(answer)
         # Connection closed. Start handling the unique message identifiers
         #logging.info('Connection succesfully opened, used and closed!')
         print 'answer', answer, time.asctime()
         uidList = [e.split()[1] for e in answer[1]]
         print 'uidList', uidList
         totalMessages = len(uidList)
         uidDictNew = {}
         for e in uidList: uidDictNew[e] = True
         uidList = [e for e in uidList if e not in uidDict]
         uidDict = uidDictNew
         if totalMessages:
             tts.Speak(totalMessagesFormat % totalMessages)
         newMessages = len(uidList)
         if newMessages:
             tts.Speak(newMessagesFormat % newMessages)
     except Exception,inst:
         errorMsg = 'Unexpected error: %s' % sys.exc_info()[0]
             tts.Speak('I repeat: ' + wakeupMessageFormat)
         except pywintypes.com_error,inst:
             errorMsg = 'Unexpected error: %s' % sys.exc_info()[0]

New Email Notifier.INI
server: myPOPserver
account: myAcoount
password: myPassword
total_message: Your eemail server has. a total of %d messages. for you 
to download
new_message: The number of new messages. since the last check. is %d
wakeup_message: Wake up, Youssi! This is your new eemail notifier, 
reporting the following error!


More information about the Python-list mailing list