Ask coding questions

← Back to all posts
Text to spech python, Help
EricBromstead (21)

I Tried this code here:

import win32com.client as wincl
speak = wincl.Dispatch("SAPI.SpVoice")
speak.Speak("Hello World")

but I get the error: package installation failure

Traceback (most recent call last):
File "python", line 1, in <module>
ModuleNotFoundError: No module named 'win32com'

This error seems to be happening in even the other text to speech repls such as

Any help is appreciated!


I Also Tried the Watson TTS thing too but that doesn't work either going to check out @basicer

LightninMcQuade (41)

Did you try this?
You are using pip version 9.0.1, however version 18.0 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

EricBromstead (21)

Anyway, thank you all for all the help! :D @amasad if you or your team ever add sound I would like to know. Hope you all have a good day!

amasad (3454)

@EricBromstead cool, will update this thread.

pyelias (2648) runs Linux, not Windows, so Windows modules like win32com don't work. Also, does not currently support playing sound, so if you want to run this code, you'll have to do it on your own computer.

EricBromstead (21)

@pyelias Ok well I tried the Linux one anyway: (Just in case)

import pyttsx
engine = pyttsx.init()
engine.say('Good morning.')

And now I get this:

Traceback (most recent call last):
File "python", line 1, in <module>
ModuleNotFoundError: No module named 'engine'

Is there a way to fix this or is there really NO WAY to get to make sounds... if so that sucks :(

amasad (3454)

@pyelias we're thinking about sounds though. @basicer had some ideas here.

EricBromstead (21)

@amasad WAIT A SECOND YOUR THE CEO. Wow! Yes I really encorage the whole sound feature, if you can't do i now that would be great in the future! I also want to thank you for making this site, Im teaching some friends how to code python on here! Thx a lot! :D

amasad (3454)

@EricBromstead thank you for using!!
We're just trying to figure out how to do it cross-platform.

CoolqB (166)

Sorry to say, but this won't work.
First off, uses Linux servers, which means that the win32com library, and SAPI.SpVoice service both don't exist.
The other issue, is as fair as I know, doesn't forward audio through to your browser, which means even if you could get it to speak, you probably wouldn't hear it ;-;

The third issue, is that it probably trying to get win32com through a direct name installation, which won't work. win32com is more recently part of the pypiwin32 package.
I'm not sure this can be done with Python in it's current state...
However this might be possible with JS, I'm not sure! It depends if JS is run through the browser, or externally.

theangryepicbanana (1697)

I think that you misspelled the package name. When I tried it, Pip told me that it could find a package named "win32com", so you may want to check that.