本文整理汇总了Python中winsound.SND_FILENAME属性的典型用法代码示例。如果您正苦于以下问题:Python winsound.SND_FILENAME属性的具体用法?Python winsound.SND_FILENAME怎么用?Python winsound.SND_FILENAME使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类winsound
的用法示例。
在下文中一共展示了winsound.SND_FILENAME属性的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: textPlay
# 需要导入模块: import winsound [as 别名]
# 或者: from winsound import SND_FILENAME [as 别名]
def textPlay():
f = open("output.txt", "r")
text = f.read()
# Language in which you want to convert
language = 'en'
# Passing the text and language to the engine,
# here we have marked slow=False. Which tells
# the module that the converted audio should
# have a high speed
myobj = gTTS(text=text, lang=language, slow=False)
myobj.save("welcome.wav")
'''
print('Playing')
winsound.PlaySound("This is real this is me",winsound.SND_FILENAME)
pygame.init()
t= pygame.mixer.Sound("welcome.wav")
t.play()'''
os.system("start welcome.wav")
示例2: play
# 需要导入模块: import winsound [as 别名]
# 或者: from winsound import SND_FILENAME [as 别名]
def play(self, **kwargs):
sound_path = os.path.join(self.dir, '{}.wav'.format(kwargs['command']))
if sublime.platform() == "osx":
if os.path.isfile(sound_path):
call(["afplay", "-v", str(1), sound_path])
if sublime.platform() == "windows":
if os.path.isfile(sound_path):
winsound.PlaySound(sound_path, winsound.SND_FILENAME | winsound.SND_ASYNC | winsound.SND_NODEFAULT)
if sublime.platform() == "linux":
if os.path.isfile(sound_path):
call(["aplay", sound_path])
示例3: play_sound
# 需要导入模块: import winsound [as 别名]
# 或者: from winsound import SND_FILENAME [as 别名]
def play_sound(sound, async_=True):
if sound in sound_mappings: sound = sound_mappings[sound]
winsound.PlaySound(sound, winsound.SND_FILENAME | (winsound.SND_ASYNC if async_ else 0))
# --------------------------------------------------------------------------
# Sleep/wake grammar.
示例4: __init__
# 需要导入模块: import winsound [as 别名]
# 或者: from winsound import SND_FILENAME [as 别名]
def __init__(self, name='', file=None):
"""
Constructor arguments:
- *name* (*str*, default *empty string*) --
name of the Windows system sound to play. This argument is
effectively an alias for *file* on other platforms.
- *file* (*str*, default *None*) --
path of wave file to play when the action is executed.
If *name* and *file* are both *None*, then waveform playback
will be silenced on Windows when the action is executed. Nothing
will happen on other platforms.
"""
ActionBase.__init__(self)
self._flags = 0
if file is not None:
self._name = file
if os.name == 'nt':
self._flags = winsound.SND_FILENAME
else:
self._name = name
if os.name == 'nt':
self._flags = winsound.SND_ALIAS
# Expand ~ constructions and shell variables in the file path if
# necessary.
if file is not None or os.name != 'nt':
self._name = os.path.expanduser(os.path.expandvars(self._name))
self._str = str(self._name)
示例5: _win_wav_play
# 需要导入模块: import winsound [as 别名]
# 或者: from winsound import SND_FILENAME [as 别名]
def _win_wav_play(filename):
import winsound
winsound.PlaySound(filename, winsound.SND_FILENAME)
示例6: __init__
# 需要导入模块: import winsound [as 别名]
# 或者: from winsound import SND_FILENAME [as 别名]
def __init__(self, name=None, file=None):
ActionBase.__init__(self)
if name is not None:
self._name = name
self._flags = winsound.SND_ASYNC | winsound.SND_ALIAS
elif file is not None:
self._name = file
self._flags = winsound.SND_ASYNC | winsound.SND_FILENAME
self._str = str(self._name)
示例7: play
# 需要导入模块: import winsound [as 别名]
# 或者: from winsound import SND_FILENAME [as 别名]
def play(self, uri):
try:
winsound.PlaySound(None, 0)
winsound.PlaySound(
url2pathname(uri[5:]), winsound.SND_FILENAME | winsound.SND_ASYNC)
except RuntimeError:
log.error("ERROR: RuntimeError while playing %s." %
url2pathname(uri[5:]))
示例8: bellProcess
# 需要导入模块: import winsound [as 别名]
# 或者: from winsound import SND_FILENAME [as 别名]
def bellProcess(queue):
logQueue = queue
logQueue.put('Info:设备正在响铃...')
winsound.PlaySound('./alarm.wav', winsound.SND_FILENAME)
# TelegramBot推送进程