Skip to content

Commit

Permalink
Bug fix for macOS failing to save audio file
Browse files Browse the repository at this point in the history
  • Loading branch information
dormant-user committed Sep 13, 2023
1 parent 9335b33 commit 495ef91
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pyttsx3/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from .engine import Engine

version = '3.3'
version = '3.4.0'
_activeEngines = weakref.WeakValueDictionary()


Expand Down
4 changes: 4 additions & 0 deletions pyttsx3/drivers/nsss.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import time

# noinspection PyUnresolvedReferences
from AppKit import NSSpeechSynthesizer
from Foundation import *
Expand Down Expand Up @@ -141,6 +143,8 @@ def setProperty(self, name, value):
def save_to_file(self, text, filename):
url = Foundation.NSURL.fileURLWithPath_(filename)
self._tts.startSpeakingString_toURL_(text, url)
# waits (for 1% of the length of text) the system to finish writing to the file system before continuing
time.sleep(max(1.0, len(text) * 0.01))

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

0 comments on commit 495ef91

Please sign in to comment.