From d4729a1dc1b7c61958c60601d6917f6fce34c26d Mon Sep 17 00:00:00 2001 From: Jiangshan00001 <710806594@qq.com> Date: Fri, 14 Apr 2023 13:26:29 +0800 Subject: [PATCH] add pitch support for sapi5 --- README.md | 3 ++- pyttsx4/drivers/sapi5.py | 11 +++++++++-- setup.py | 2 +- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index e2ed62c..85ee726 100644 --- a/README.md +++ b/README.md @@ -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: diff --git a/pyttsx4/drivers/sapi5.py b/pyttsx4/drivers/sapi5.py index ce458a5..8a9216c 100644 --- a/pyttsx4/drivers/sapi5.py +++ b/pyttsx4/drivers/sapi5.py @@ -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 @@ -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) @@ -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('') + print("Pitch adjustment is not tested when using SAPI5") else: raise KeyError('unknown property %s' % name) diff --git a/setup.py b/setup.py index 7f6c013..b552cf8 100644 --- a/setup.py +++ b/setup.py @@ -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',