Skip to content

Commit 495ef91

Browse files
committed
Bug fix for macOS failing to save audio file
1 parent 9335b33 commit 495ef91

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

pyttsx3/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from .engine import Engine
44

5-
version = '3.3'
5+
version = '3.4.0'
66
_activeEngines = weakref.WeakValueDictionary()
77

88

pyttsx3/drivers/nsss.py

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import time
2+
13
# noinspection PyUnresolvedReferences
24
from AppKit import NSSpeechSynthesizer
35
from Foundation import *
@@ -141,6 +143,8 @@ def setProperty(self, name, value):
141143
def save_to_file(self, text, filename):
142144
url = Foundation.NSURL.fileURLWithPath_(filename)
143145
self._tts.startSpeakingString_toURL_(text, url)
146+
# waits (for 1% of the length of text) the system to finish writing to the file system before continuing
147+
time.sleep(max(1.0, len(text) * 0.01))
144148

145149
def speechSynthesizer_didFinishSpeaking_(self, tts, success):
146150
if not self._completed:

0 commit comments

Comments
 (0)