Skip to content

Commit

Permalink
add pitch support for sapi5
Browse files Browse the repository at this point in the history
  • Loading branch information
Jiangshan00001 committed Apr 14, 2023
1 parent 3fe1bd4 commit d4729a1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ engine.runAndWait()

4. fix for sapi save_to_file when it run on machine without outputsream device.

5. fix save_to_file does not work on mac os ventura error.
5. fix save_to_file does not work on mac os ventura error. --3.0.6

6. add pitch support for sapi5(not tested yet). --3.0.7

NOTE:

Expand Down
11 changes: 9 additions & 2 deletions pyttsx4/drivers/sapi5.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ def __init__(self, proxy):
self._rateWpm = 200
self.setProperty('voice', self.getProperty('voice'))

#-10=>+10
self.pitch= 0

def destroy(self):
self._tts.EventInterests = 0

Expand Down Expand Up @@ -123,7 +126,8 @@ def getProperty(self, name):
elif name == 'volume':
return self._tts.Volume / 100.0
elif name == 'pitch':
print("Pitch adjustment not supported when using SAPI5")
return self.pitch
#print("Pitch adjustment not supported when using SAPI5")
else:
raise KeyError('unknown property %s' % name)

Expand Down Expand Up @@ -152,7 +156,10 @@ def setProperty(self, name, value):
except TypeError as e:
raise ValueError(str(e))
elif name == 'pitch':
print("Pitch adjustment not supported when using SAPI5")
#-10 ->10
self.pitch = value
self._tts.Speak('<pitch absmiddle="'+str(value)+'"/>')
print("Pitch adjustment is not tested when using SAPI5")
else:
raise KeyError('unknown property %s' % name)

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
setup(
name='pyttsx4',
packages=['pyttsx4', 'pyttsx4.drivers'],
version='3.0.6',
version='3.0.7',
description='Text to Speech (TTS) library for Python 3. Works without internet connection or delay. Supports multiple TTS engines, including Sapi5, nsss, and espeak.',
long_description=long_description,
summary='Offline Text to Speech library with multi-engine support',
Expand Down

0 comments on commit d4729a1

Please sign in to comment.