You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My male voice sounds like a weird version of the female voice. Here's my code:
import pyttsx3
import pyttsx3.voice
class VoiceEngine(object):
voiceDict = {"male": 0, "female": 1}
def __init__(self, voice: str="female", speed: int=144):
"""
Initialize a VoiceEngine object.
:param voice: 'male' or 'female'
"""
try:
self.voice = VoiceEngine.voiceDict[voice]
self.speed = speed
except:
self.voice = 1
self.speed = 144
print("Defaulting to female voice due to an error in the input.")
self.engine = pyttsx3.init("sapi5")
voices = self.engine.getProperty("voices")
self.engine.setProperty("voice", voices[self.voice].id)
self.engine.setProperty("rate", self.speed)
def speak(self, text: str):
self.engine.say(text)
self.engine.runAndWait()
def set_speed(self, speed: int):
self.speed = speed
self.engine.setProperty("rate", self.speed)
def set_voice(self, id):
self.voice = id
self.engine.setProperty("voice", self.voice)
if __name__ == '__main__':
voice_engine = VoiceEngine("male")
voice_engine.set_speed(200)
voices = pyttsx3.init()
male_voice = pyttsx3.voice.Voice(2, name="male", languages=["english"], gender="male")
voices = voices.getProperty("voices")
voice_engine.set_voice(2)
voice_engine.speak("""When a doctor doctors a doctor, does the doctor doing the doctoring doctor as the doctor being doctored wants to be doctored or does the doctor doing the doctoring doctor as he wants to doctor?""")
The text was updated successfully, but these errors were encountered:
For a start - male or female voices dont make a jot of difference in espeak. I think i need to look into getVoices for this
also though - your string
Something is really odd about it
voice_engine.speak("""When a doctor doctors a doctor, does the doctor doing the doctoring doctor as the doctor being doctored wants to be doctored or does the doctor doing the doctoring doctor as he wants to doctor?""")
Just wont work standalone
If we remove the comma and ? we get somewhere - but its something in this last part "doctor doing the doctoring doctor as he wants to doctor" that is causing it to crash and burn
update - my fixes in most recent PR seems to have cleared the speking bug. I think it was to do with using END not MSG Terminator - in espeak. something in that sentence was causing a early end.. closing for now.
My male voice sounds like a weird version of the female voice. Here's my code:
The text was updated successfully, but these errors were encountered: