Hi all, I'm new to python. I am developing a text to speech application using python. So, I'm using a package named "pyTTS" version 3, compatible with python 2.5.
Using an existing example, I wrote the following orders:

import pyTTS
tts = pyTTS.Create()

Before this, I've installed the following packages: python-2.5
pyTTS-3.0.win32-py2.5
msttss22L
SAPI5SpeechInstaller

But I faced this error:

Trackback (most recent call last):
  File "<pyshell#1>", line 1, in <module>
    tts = pyTTS.Create()
  File "C:\Python2 5\Lib\site-packages\pyTTS\_init_.py", line 28, in Create
    raise ValueError('"%s" not supported' % api)
ValueError:  "SAPI" not supported

I think that the problem is in the SAPI package, but I don't know how to solve it. Could you help me?

Is more easy...

Use directly win32com module, don't use pytts.

if os.name=="nt":
    import win32com.client
    self.speaker = win32com.client.Dispatch("SAPI.SpVoice")
    self.speaker.Speak("Hello")
commented: thanks +15

Thanks txasatonga

works fine on Windows7 ...

# speak_SAPI1.py
# use with Windows OS
# needs the pywin32 extension package
# download the correct version from:
# http://www.lfd.uci.edu/~gohlke/pythonlibs/

import os

if os.name=="nt":
    import win32com.client
    speaker = win32com.client.Dispatch("SAPI.SpVoice")
    # speak "Hello World" on the computer sound system
    speaker.Speak("Hello World")
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.