WHAT I'M DOING:
I'm trying to run a simple tts program:
import pyttsx3
*** engine = pyttsx3.init()
engine.setProperty("rate", 178)
engine.say("I am the text spoken after changing the speech rate.")
engine.runAndWait()
but I'm getting the following error at the *** line:
Exception has occurred: ModuleNotFoundError No module named 'win32api'
WHAT I'VE TRIED:
import pyttsx3
*** import win32api
engine = pyttsx3.init()
engine.setProperty("rate", 178)
engine.say("I am the text spoken after changing the speech rate.")
engine.runAndWait()
Even weirder is Visual Studio Code sees win32api (the word is green on my IDE), but it still says it doesn't exist?:
I'm really confused so absolutely any help would be greatly appreciated. Thank you.
This is because the vscode search module using the workspace as the root directory to search, rather than the current file.
You need to add the relative path or absolute path of the file to be imported at the beginning of the file.
import sys
sys.path.append("your path of module")