RapidWareTech / pyttsx

Cross-platform text-to-speech wrapper
Other
370 stars 134 forks source link

I want to use apscheduler to do a regular cycle of voice, but encountered a problem #63

Closed qilongqiu closed 6 years ago

qilongqiu commented 6 years ago
import pyttsx,sys,os
from apscheduler.schedulers.blocking import BlockingScheduler
reload(sys)
sys.setdefaultencoding('utf8')

engine = pyttsx.init()
rate = engine.getProperty('rate')
engine.setProperty('rate', rate - 50)
volume = engine.getProperty('volume')
engine.setProperty('volume', volume + 0.25)
def getTicker_wrap():

    engine.say('abcdefghijklmnopqrstuvwxyz')
    #engine.runAndWait()
    print 'x'
def run():
    engine.runAndWait()
if __name__ == '__main__':
    scheduler = BlockingScheduler()
    scheduler.add_job(getTicker_wrap, 'interval', seconds=10)
    scheduler.add_job(run, 'interval', seconds=11)
    print('Press Ctrl+{0} to exit'.format('Break' if os.name == 'nt' else 'C'))
    try:
        scheduler.start()
    except (KeyboardInterrupt, SystemExit):
        pass

Will only play once what should I do

G33kNik commented 6 years ago

Same here, facing same issue for python2.7!, For python 3.5 pyttsx3 is working all right