Ask coding questions

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

I Tried this code here:

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

but I get the error:

Repl.it: 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 https://repl.it/@Kingsley005/Python-Text-to-Speech

Any help is appreciated!

EDIT:

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

Commentshotnewtop
pyelias (750)

repl.it runs Linux, not Windows, so Windows modules like win32com don't work. Also, repl.it 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 (7)

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

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

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 repl.it to make sounds... if so that sucks :(

amasad (1416)

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

EricBromstead (7)

@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 (1416)

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

LightninMcQuade (240)

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.

CoolqB (103)

Sorry to say, but this won't work.
First off, Repl.it 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, Repl.it 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 Repl.it 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 (847)

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.

EricBromstead (7)

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 (1416)

@EricBromstead cool, will update this thread.