Python Text to Speech in Macintosh

后端 未结 3 2222
攒了一身酷
攒了一身酷 2020-12-28 21:45

Are there any libraries in Python that does or allows Text To Speech Conversion using Mac Lion\'s built in text to speech engine? I did google but most are windows based. I

3条回答
  •  长发绾君心
    2020-12-28 22:25

    Wouldn't it be much simpler to do this?

    from os import system
    system('say Hello world!')
    

    You can enter man say to see other things you can do with the say command.

    However, if you want some more advanced features, importing AppKit would also be a possibility, although some Cocoa/Objective C knowledge is needed.

    from AppKit import NSSpeechSynthesizer
    speechSynthesizer = NSSpeechSynthesizer.alloc().initWithVoice_("com.apple.speech.synthesis.voice.Bruce")
    speechSynthesizer.startSpeakingString_('Hi! Nice to meet you!')
    

    If you would like to see more things you can do with NSSpeechSynthesizer take a look at Apple's documentation: https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/ApplicationKit/Classes/NSSpeechSynthesizer_Class/Reference/Reference.html

提交回复
热议问题