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
http://www.cs.unc.edu/~parente/tech/tr02.shtml
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
http://www.cs.unc.edu/Research/assis...hInstaller.msi
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
=============== ===========
#!/usr/bin/python
'''
License: MIT License. See License.txt. If that file is not attached,
the license is
http://www.opensource.org/licenses/mit-license.php,
where
<year= 2006 and <copyright holders= Jussi Salmela, Turku, Finland
'''
# This program checks for new email at ISP and notifies if new email is
found
import win32serviceuti l
import win32service
import win32event
import pyTTS, sys, os, poplib, logging, time
import ConfigParser,py wintypes
print '\nThis is the New Mail Notifier window\n'
notifierDirecto ry = r'C:\Python\OMA T___PROJEKTIT\N ew Email Notifier Service'
logging.basicCo nfig(level=logg ing.DEBUG,
format='%(ascti me)s %(levelname)-8s %(message)s',
filename=notifi erDirectory+r'\ error.log')
logging.info('= =============== =============== =============== ===========')
logging.info('N ew Email Notifier Service started')
config = ConfigParser.Co nfigParser()
config.readfp(o pen(notifierDir ectory+r'\New Email Notifier.INI'))
POP3Server = config.get('POP 3','server')
POP3Account = config.get('POP 3','account')
POP3Password = config.get('POP 3','password')
totalMessagesFo rmat = config.get('mes sages','total_m essage')
newMessagesForm at = config.get('mes sages','new_mes sage')
wakeupMessageFo rmat = config.get('mes sages','wakeup_ message')
tts = pyTTS.Create()
#set the speech volume percentage (0-100%)
tts.Volume = 100
#explicitly set a voice
tts.SetVoiceByN ame(u'MSMary')
uidDict = {}
# We wait to be stopped and check for new email every maxTimeToWait seconds
maxTimeToWait = 1 # First check after 1 second
while True:
time.sleep(maxT imeToWait)
maxTimeToWait = 60 # Rest of the checks after 60 second
try:
# Connect to the ISP
a = poplib.POP3(POP 3Server,110)
answer = a.getwelcome()
if answer[0:3] != '+OK':
raise ValueError,'a.g etwelcome returned: ' + answer
answer = a.user(POP3Acco unt)
if answer[0:3] != '+OK':
raise ValueError,'a.u ser returned: ' + answer
if answer[4:] == 'Password required':
answer = a.pass_(POP3Pas sword)
if answer[0:3] != '+OK':
raise ValueError,'a.p ass_ returned: ' + answer
answer = a.uidl()
if answer[0][0:3] != '+OK':
raise ValueError,'a.u idl returned: ' + repr(answer)
a.quit()
# 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(total MessagesFormat % totalMessages)
newMessages = len(uidList)
if newMessages:
tts.Speak(newMe ssagesFormat % newMessages)
except Exception,inst:
errorMsg = 'Unexpected error: %s' % sys.exc_info()[0]
logging.error(e rrorMsg)
logging.error(i nst)
try:
tts.Speak(wakeu pMessageFormat)
tts.Speak('I repeat: ' + wakeupMessageFo rmat)
tts.Speak(error Msg)
tts.Speak(inst)
except pywintypes.com_ error,inst:
errorMsg = 'Unexpected error: %s' % sys.exc_info()[0]
logging.error(e rrorMsg)
logging.error(i nst)
=============== ===========
New Email Notifier.INI
=============== ===========
[POP3]
server: myPOPserver
account: myAcoount
password: myPassword
[messages]
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!
HTH,
Jussi