How to Make Python Speak with a Male Voice Using pyttsx3 and Registry Tweaks
This article walks through troubleshooting the pyttsx3 Python text‑to‑speech library on Windows, explains why only female voices appear by default, shows how to add the missing male “Kangkang” voice via registry edits, and provides complete working code examples for both voice selection and speech synthesis.
Introduction
In a Python community, a user asked about a problem with the pyttsx3 library. The original code attempted to set a female voice.
Original Code
import pyttsx3 # import the library
def voiceChange():
eng = pyttsx3.init() # initialize an instance
voice = eng.getProperty('voices') # get the available voices
# eng.setProperty('voice', voice[0].id) # male voice (commented)
eng.setProperty('voice', voice[1].id) # female voice
eng.say("This is a demonstration of how to convert index of voice using pyttsx3 library in python.")
eng.runAndWait()
if __name__ == "__main__":
voiceChange()The code works but only female voices are available on Windows 10 by default.
Windows 10 Built‑in Voices
Windows 10 provides five voices. The male voice “Kangkang” is not loaded by default; only “Huihui” and “Zira” (female) appear.
Adding a Male Voice
By editing the Windows registry you can add the missing “Kangkang” voice. The tutorial is available at https://www.likecs.com/show-204841565.html.
After the registry change, the male voice appears in the list and can be selected.
Working Example
import pyttsx3 # 导入库
def textToVoice():
eng = pyttsx3.init()
voice = eng.getProperty('voices')
eng.setProperty('voice', voice[2].id)
eng.say("感谢大佬!太强了 太强了 太强了")
eng.runAndWait()
if __name__ == "__main__":
textToVoice()The script now speaks with the male “Kangkang” voice.
Conclusion
The article demonstrates how to troubleshoot pyttsx3 voice selection on Windows, modify the registry to load a missing male voice, and provides working code examples.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Python Crawling & Data Mining
Life's short, I code in Python. This channel shares Python web crawling, data mining, analysis, processing, visualization, automated testing, DevOps, big data, AI, cloud computing, machine learning tools, resources, news, technical articles, tutorial videos and learning materials. Join us!
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
