本文整理汇总了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)