I have tried for over 2 hours trying to figure this out, not 100% sure but i think it has to do with the fail in the sapi5.py module because i dont have the following voices installed:
MSSAM = 'HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Speech\\Voices\\Tokens\\MSSam'
MSMARY = 'HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Speech\\Voices\\Tokens\\MSMary'
MSMIKE = 'HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Speech\\Voices\\Tokens\\MSMike'
I have tried adding to the above list, changed the first entry to MSGeorge, tried downgrading to python 3.6 and 3.7, tried using pyttsx3 2.71,
also tried changing the registry to add in MSGeorge like what is called out in this issue "https://stackoverflow.com/questions/62756194/pyttsx3-module-is-not-showing-all-installed-voices"
I dont suppose anyone has seen this before, given that i searched the internet and youtube i couldnt find anything so im thinking its something simple,
Im running a windows 10 PC with python 3.8.6 on pycharm,
Code:
import pyttsx3
engine = pyttsx3.init() # object creation
voices = engine.getProperty('voices')
print(voices)
Error:
Traceback (most recent call last):
File "C:\Users\user\PycharmProjects\venv\lib\site-packages\pyttsx3\__init__.py", line 20, in init
eng = _activeEngines[driverName]
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.1776.0_x64__qbz5n2kfra8p0\lib\weakref.py", line 131, in __getitem__
o = self.data[key]()
KeyError: None
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:/Users/user/PycharmProjects/pythonProject/Jarvis/Jarvis.py", line 2, in <module>
engine = pyttsx3.init() # object creation
File "C:\Users\user\PycharmProjects\venv\lib\site-packages\pyttsx3\__init__.py", line 22, in init
eng = Engine(driverName, debug)
File "C:\Users\user\PycharmProjects\venv\lib\site-packages\pyttsx3\engine.py", line 30, in __init__
self.proxy = driver.DriverProxy(weakref.proxy(self), driverName, debug)
File "C:\Users\user\PycharmProjects\venv\lib\site-packages\pyttsx3\driver.py", line 52, in __init__
self._driver = self._module.buildDriver(weakref.proxy(self))
File "C:\Users\user\PycharmProjects\venv\lib\site-packages\pyttsx3\drivers\sapi5.py", line 32, in buildDriver
return SAPI5Driver(proxy)
File "C:\Users\user\PycharmProjects\venv\lib\site-packages\pyttsx3\drivers\sapi5.py", line 49, in __init__
self.setProperty('voice', self.getProperty('voice'))
File "C:\Users\user\PycharmProjects\venv\lib\site-packages\pyttsx3\drivers\sapi5.py", line 102, in setProperty
token = self._tokenFromId(value)
File "C:\Users\user\PycharmProjects\venv\lib\site-packages\pyttsx3\drivers\sapi5.py", line 86, in _tokenFromId
raise ValueError('unknown voice id %s', id_)
ValueError: ('unknown voice id %s', 'HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Speech_OneCore\\Voices\\Tokens\\MSTTS_V110_enGB_GeorgeM')