当前位置: 首页>>代码示例>>Python>>正文


Python Dispatch.Voice方法代码示例

本文整理汇总了Python中win32com.client.Dispatch.Voice方法的典型用法代码示例。如果您正苦于以下问题:Python Dispatch.Voice方法的具体用法?Python Dispatch.Voice怎么用?Python Dispatch.Voice使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在win32com.client.Dispatch的用法示例。


在下文中一共展示了Dispatch.Voice方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: run

# 需要导入模块: from win32com.client import Dispatch [as 别名]
# 或者: from win32com.client.Dispatch import Voice [as 别名]
    def run(self):
        try:
            pythoncom.CoInitializeEx(pythoncom.COINIT_MULTITHREADED)
            #tts = DispatchWithEvents("SAPI.SpVoice.1", SpeechEvents)
            tts = Dispatch('SAPI.SpVoice')
        except:
            self.plugin.PrintError(self.plugin.text.errorCreate)
            return
        vcs = tts.GetVoices()
        voices = [(voice.GetDescription(), voice) for voice in vcs]
        tmp = [item[0] for item in voices]
        ix = tmp.index(self.voiceName) if self.voiceName in tmp else 0
        tts.Voice = voices[ix][1]

        devs = tts.GetAudioOutputs()
        devices = [(dev.GetDescription(), dev) for dev in devs]
        tmp = [item[0] for item in devices]
        ix = tmp.index(self.device) if self.device in tmp else 0
        tts.AudioOutput = devices[ix][1]

        tts.Rate = self.rate
        tts.Volume = self.volume
        tts.Speak(self.text,0)
        suffix = self.plugin.text.suffix if self.suff == "" else "%s.%s" % (
            self.plugin.text.suffix,
            self.suff
        )
        self.plugin.TriggerEvent(suffix)
开发者ID:bruinlax,项目名称:EventGhost,代码行数:30,代码来源:__init__.py


注:本文中的win32com.client.Dispatch.Voice方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。