pyttsx3 icon indicating copy to clipboard operation
pyttsx3 copied to clipboard

Getting Error KeyError: 'unknown property pitch'

Open shubhankartrivedi opened this issue 4 years ago • 1 comments

I tried using pitch property and it gives me error

here is my Source Code:

import pyttsx3
engine = pyttsx3.init() # object creation

""" RATE"""
rate = engine.getProperty('rate')   # getting details of current speaking rate
print (rate)                        #printing current voice rate
engine.setProperty('rate', 125)     # setting up new voice rate


"""VOLUME"""
volume = engine.getProperty('volume')   #getting to know current volume level (min=0 and max=1)
print (volume)                          #printing current volume level
engine.setProperty('volume',1.0)    # setting up volume level  between 0 and 1

"""VOICE"""
voices = engine.getProperty('voices')       #getting details of current voice
#engine.setProperty('voice', voices[0].id)  #changing index, changes voices. o for male
engine.setProperty('voice', voices[1].id)   #changing index, changes voices. 1 for female

"""PITCH"""
pitch = engine.getProperty('pitch')   #Get current pitch value
print(pitch)                          #Print current pitch value
engine.setProperty('pitch', 75)       #Set the pitch (default 50) to 75 out of 100

engine.say("Hello World!")
engine.say('My current speaking rate is ' + str(rate))
engine.runAndWait()
engine.stop()


"""Saving Voice to a file"""
# On linux make sure that 'espeak' and 'ffmpeg' are installed
engine.save_to_file('Hello World', 'test.mp3')
engine.runAndWait()

Outupt:

200
1.0
Traceback (most recent call last):
  File "d:\Meet\AI\Python\test.py", line 21, in <module>
    pitch = engine.getProperty('pitch')   #Get current pitch value
  File "C:\Users\shubh\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\pyttsx3\engine.py", line 146, in getProperty
    return self.proxy.getProperty(name)
  File "C:\Users\shubh\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\pyttsx3\driver.py", line 173, in getProperty
    return self._driver.getProperty(name)
  File "C:\Users\shubh\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\pyttsx3\drivers\sapi5.py", line 96, in getProperty
    raise KeyError('unknown property %s' % name)
KeyError: 'unknown property pitch'

shubhankartrivedi avatar Mar 21 '22 15:03 shubhankartrivedi

did you solved it?

iamDyeus avatar Aug 01 '22 18:08 iamDyeus