Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix save_to_file on Macos Ventura when using nsss #271

Merged
merged 5 commits into from
Aug 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions pyttsx3/drivers/nsss.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from Foundation import *
from AppKit import NSSpeechSynthesizer
from PyObjCTools import AppHelper
from ..voice import Voice
from pyttsx3.voice import Voice


def buildDriver(proxy):
Expand Down Expand Up @@ -60,8 +60,7 @@ def _toVoice(self, attr):
except KeyError:
lang = attr['VoiceLanguage']
return Voice(attr['VoiceIdentifier'], attr['VoiceName'],
[lang], attr['VoiceGender'],
attr['VoiceAge'])
[lang], attr['VoiceGender'])

@objc.python_method
def getProperty(self, name):
Expand Down Expand Up @@ -100,7 +99,10 @@ def setProperty(self, name, value):
@objc.python_method
def save_to_file(self, text, filename):
url = Foundation.NSURL.fileURLWithPath_(filename)
import time

self._tts.startSpeakingString_toURL_(text, url)
time.sleep(max(1, len(text) * 0.01))

def speechSynthesizer_didFinishSpeaking_(self, tts, success):
if not self._completed:
Expand Down