Python winsound.PlaySound() Examples
The following are 30
code examples of winsound.PlaySound().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
winsound
, or try the search function
.
Example #1
Source File: ksp_plugin.py From SublimeKSP with GNU General Public License v3.0 | 6 votes |
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])
Example #2
Source File: sbmit.py From hack4career with Apache License 2.0 | 6 votes |
def do_scan(crawling): while 1: try: crawling = tocrawl.pop() # print crawling except KeyError: sys.exit(1) url = urlparse.urlparse(crawling) try: response = urllib2.urlopen(crawling) except urllib2.HTTPError, e: continue except urllib2.URLError, e: log_file = "sqli.txt" FILE = open(log_file, "a") FILE.write(crawling) FILE.close() print "\n================================================================================" print "\t\tBlind MySQL Injection Detected" print crawling print "\n===============================================================================\n" winsound.PlaySound("SystemAsterisk", winsound.SND_ALIAS) time.sleep(10) continue
Example #3
Source File: rmEngine.py From chanlun with MIT License | 6 votes |
def writeRiskLog(self, content): """快速发出日志事件""" # 发出报警提示音 if platform.uname() == 'Windows': import winsound winsound.PlaySound("SystemHand", winsound.SND_ASYNC) # 发出日志事件 log = VtLogData() log.logContent = content log.gatewayName = self.name event = Event(type_=EVENT_LOG) event.dict_['data'] = log self.eventEngine.put(event) #----------------------------------------------------------------------
Example #4
Source File: rmEngine.py From vnpy_crypto with MIT License | 6 votes |
def writeRiskLog(self, content): """快速发出日志事件""" # 发出报警提示音 if platform.uname() == 'Windows': import winsound winsound.PlaySound("SystemHand", winsound.SND_ASYNC) # 发出日志事件 log = VtLogData() log.logContent = content log.gatewayName = self.name event = Event(type_=EVENT_LOG) event.dict_['data'] = log self.eventEngine.put(event) # ----------------------------------------------------------------------
Example #5
Source File: test_winsound.py From medicare-demo with Apache License 2.0 | 6 votes |
def test_stopasync(self): if _have_soundcard(): winsound.PlaySound( 'SystemQuestion', winsound.SND_ALIAS | winsound.SND_ASYNC | winsound.SND_LOOP ) time.sleep(0.5) try: winsound.PlaySound( 'SystemQuestion', winsound.SND_ALIAS | winsound.SND_NOSTOP ) except RuntimeError: pass else: # the first sound might already be finished pass winsound.PlaySound(None, winsound.SND_PURGE) else: self.assertRaises( RuntimeError, winsound.PlaySound, None, winsound.SND_PURGE )
Example #6
Source File: action_playsound.py From dragonfly with GNU Lesser General Public License v3.0 | 6 votes |
def _pyaudio_play(name): if not name: return if pyaudio is None: # Raise an error because pyaudio isn't installed. raise RuntimeError("pyaudio must be installed to use PlaySound " "on this platform") # Play the wave file. pa = _get_pa_instance() chunk = 1024 wf = wave.open(name, 'rb') stream = pa.open(format=pa.get_format_from_width(wf.getsampwidth()), channels=wf.getnchannels(), rate=wf.getframerate(), output=True) data = wf.readframes(chunk) while data: stream.write(data) data = wf.readframes(chunk) stream.stop_stream() stream.close() pa.terminate()
Example #7
Source File: core.py From face_recognition_py with GNU General Public License v3.0 | 5 votes |
def bellProcess(queue): logQueue = queue logQueue.put('Info:设备正在响铃...') winsound.PlaySound('./alarm.wav', winsound.SND_FILENAME) # TelegramBot推送进程
Example #8
Source File: beep.py From EasY_HaCk with Apache License 2.0 | 5 votes |
def _win_wav_play(filename): import winsound winsound.PlaySound(filename, winsound.SND_FILENAME)
Example #9
Source File: spgl.py From SPGL with GNU General Public License v3.0 | 5 votes |
def play_sound(self, sound_file, time = 0): # Windows if platform.system() == 'Windows': winsound.PlaySound(sound_file, winsound.SND_ASYNC) # Linux elif platform.system() == "Linux": os.system("aplay -q {}&".format(sound_file)) # Mac else: os.system("afplay {}&".format(sound_file)) if time > 0: turtle.ontimer(lambda: self.play_sound(sound_file, time), t=int(time * 1000))
Example #10
Source File: spgl.py From SPGL with GNU General Public License v3.0 | 5 votes |
def play_sound(self, sound_file, time = 0): # Windows if platform.system() == 'Windows': winsound.PlaySound(sound_file, winsound.SND_ASYNC) # Linux elif platform.system() == "Linux": os.system("aplay -q {}&".format(sound_file)) # Mac else: os.system("afplay {}&".format(sound_file)) if time > 0: turtle.ontimer(lambda: self.play_sound(sound_file, time), t=int(time * 1000))
Example #11
Source File: rmEngine.py From py3_demo_on_vnpy_ctp with MIT License | 5 votes |
def writeRiskLog(self, content): """快速发出日志事件""" # 发出报警提示音 if platform.uname() == 'Windows': import winsound winsound.PlaySound("SystemHand", winsound.SND_ASYNC) # 发出日志事件 event = Event(type_=EVENT_LOG) event.dict_['log'] = content self.eventEngine.put(event) #----------------------------------------------------------------------
Example #12
Source File: text2speech.py From Printed-Text-recognition-and-conversion with MIT License | 5 votes |
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")
Example #13
Source File: test_winsound.py From medicare-demo with Apache License 2.0 | 5 votes |
def test_errors(self): self.assertRaises(TypeError, winsound.PlaySound) self.assertRaises(TypeError, winsound.PlaySound, "bad", "bad") self.assertRaises( RuntimeError, winsound.PlaySound, "none", winsound.SND_ASYNC | winsound.SND_MEMORY )
Example #14
Source File: test_winsound.py From medicare-demo with Apache License 2.0 | 5 votes |
def test_alias_asterisk(self): if _have_soundcard(): winsound.PlaySound('SystemAsterisk', winsound.SND_ALIAS) else: self.assertRaises( RuntimeError, winsound.PlaySound, 'SystemAsterisk', winsound.SND_ALIAS )
Example #15
Source File: test_winsound.py From medicare-demo with Apache License 2.0 | 5 votes |
def test_alias_exclamation(self): if _have_soundcard(): winsound.PlaySound('SystemExclamation', winsound.SND_ALIAS) else: self.assertRaises( RuntimeError, winsound.PlaySound, 'SystemExclamation', winsound.SND_ALIAS )
Example #16
Source File: test_winsound.py From medicare-demo with Apache License 2.0 | 5 votes |
def test_alias_exit(self): if _have_soundcard(): winsound.PlaySound('SystemExit', winsound.SND_ALIAS) else: self.assertRaises( RuntimeError, winsound.PlaySound, 'SystemExit', winsound.SND_ALIAS )
Example #17
Source File: test_winsound.py From medicare-demo with Apache License 2.0 | 5 votes |
def test_alias_hand(self): if _have_soundcard(): winsound.PlaySound('SystemHand', winsound.SND_ALIAS) else: self.assertRaises( RuntimeError, winsound.PlaySound, 'SystemHand', winsound.SND_ALIAS )
Example #18
Source File: test_winsound.py From medicare-demo with Apache License 2.0 | 5 votes |
def test_alias_fallback(self): # This test can't be expected to work on all systems. The MS # PlaySound() docs say: # # If it cannot find the specified sound, PlaySound uses the # default system event sound entry instead. If the function # can find neither the system default entry nor the default # sound, it makes no sound and returns FALSE. # # It's known to return FALSE on some real systems. # winsound.PlaySound('!"$%&/(#+*', winsound.SND_ALIAS) return
Example #19
Source File: test_winsound.py From medicare-demo with Apache License 2.0 | 5 votes |
def test_alias_nofallback(self): if _have_soundcard(): # Note that this is not the same as asserting RuntimeError # will get raised: you cannot convert this to # self.assertRaises(...) form. The attempt may or may not # raise RuntimeError, but it shouldn't raise anything other # than RuntimeError, and that's all we're trying to test # here. The MS docs aren't clear about whether the SDK # PlaySound() with SND_ALIAS and SND_NODEFAULT will return # True or False when the alias is unknown. On Tim's WinXP # box today, it returns True (no exception is raised). What # we'd really like to test is that no sound is played, but # that requires first wiring an eardrum class into unittest # <wink>. try: winsound.PlaySound( '!"$%&/(#+*', winsound.SND_ALIAS | winsound.SND_NODEFAULT ) except RuntimeError: pass else: self.assertRaises( RuntimeError, winsound.PlaySound, '!"$%&/(#+*', winsound.SND_ALIAS | winsound.SND_NODEFAULT )
Example #20
Source File: beep.py From POC-EXP with GNU General Public License v3.0 | 5 votes |
def _win_wav_play(filename): import winsound winsound.PlaySound(filename, winsound.SND_FILENAME)
Example #21
Source File: strategy_model.py From equant with GNU General Public License v2.0 | 5 votes |
def setAlert(self, Info, bKeep, level): #出声音 if bKeep: if level in self._audioDict: audioName = self._audioDict[level] else: audioName = 'SystemQuestion' winsound.PlaySound(audioName, winsound.SND_ASYNC) #弹窗 createAlarmWin(Info, self._strategy.getStrategyId(), self._strategy.getStrategyName());
Example #22
Source File: spgl.py From Projects with GNU General Public License v3.0 | 5 votes |
def play_sound(self, sound_file, time = 0): # Windows if platform.system() == 'Windows': winsound.PlaySound(sound_file, winsound.SND_ASYNC) # Linux elif platform.system() == "Linux": os.system("aplay -q {}&".format(sound_file)) # Mac else: os.system("afplay {}&".format(sound_file)) if time > 0: turtle.ontimer(lambda: self.play_sound(sound_file, time), t=int(time * 1000))
Example #23
Source File: space_arena.py From Projects with GNU General Public License v3.0 | 5 votes |
def play_sound(sound_file, time = 0): # Windows if platform.system() == 'Windows': winsound.PlaySound(sound_file, winsound.SND_ASYNC) # Linux elif platform.system() == "Linux": os.system("aplay -q {}&".format(sound_file)) # Mac else: os.system("afplay {}&".format(sound_file)) if time > 0: turtle.ontimer(lambda: play_sound(sound_file, time), t=int(time * 1000))
Example #24
Source File: audiofeedback.py From edr with Apache License 2.0 | 5 votes |
def warn(self): winsound.PlaySound(self.snd_warn, winsound.SND_ASYNC)
Example #25
Source File: hotkey.py From EDMarketConnector with GNU General Public License v2.0 | 5 votes |
def worker(self, keycode, modifiers): # Hotkey must be registered by the thread that handles it if not RegisterHotKey(None, 1, modifiers|MOD_NOREPEAT, keycode): self.thread = None return fake = INPUT(INPUT_KEYBOARD, INPUT_union(ki = KEYBDINPUT(keycode, keycode, 0, 0, None))) msg = MSG() while GetMessage(ctypes.byref(msg), None, 0, 0) != 0: if msg.message == WM_HOTKEY: if config.getint('hotkey_always') or WindowTitle(GetForegroundWindow()).startswith('Elite - Dangerous'): self.root.event_generate('<<Invoke>>', when="tail") else: # Pass the key on UnregisterHotKey(None, 1) SendInput(1, fake, ctypes.sizeof(INPUT)) if not RegisterHotKey(None, 1, modifiers|MOD_NOREPEAT, keycode): break elif msg.message == WM_SND_GOOD: winsound.PlaySound(self.snd_good, winsound.SND_MEMORY) # synchronous elif msg.message == WM_SND_BAD: winsound.PlaySound(self.snd_bad, winsound.SND_MEMORY) # synchronous else: TranslateMessage(ctypes.byref(msg)) DispatchMessage(ctypes.byref(msg)) UnregisterHotKey(None, 1) self.thread = None
Example #26
Source File: dns_checker.py From hack4career with Apache License 2.0 | 5 votes |
def dns_lookup(address): subprocess.call("ipconfig /flushdns", stdout=False, stderr=False) query = socket.getaddrinfo(address, 80) query = ".".join([str(x) for x in query]) query = query.split("'")[3] print address, "-", query date = datetime.datetime.now().strftime("%d/%m/%Y %H:%M:%S") if os.path.isfile("history.txt"): FILE = open ("history.txt","r" ) entries = FILE.readlines() FILE.close() lastentry = entries[-1].split("|")[1] if debug: print query.strip, lastentry print address.strip().lower(), entries[-1].split("|")[0].strip().lower() if (address.strip().lower() == entries[-1].split("|")[0].strip().lower()): if query.strip() != lastentry.strip(): print "DNS Change Detected! (Old: %s - New: %s)\n" %(lastentry.strip(), query) winsound.PlaySound("SystemAsterisk", winsound.SND_ALIAS) line = address + "|" + query + "|" + date + "\n" FILE = open("history.txt", "a") FILE.writelines(line) FILE.close() else: line = address + "|" + query + "|" + date + "\n" FILE = open("history.txt", "w") FILE.writelines(line) FILE.close()
Example #27
Source File: uiBasicWidget.py From vnpy_crypto with MIT License | 5 votes |
def play_trade(self, event): """播放交易声音""" # 1.获取事件的Trade数据 trade = event.dict_['data'] winsound.PlaySound('warn.wav', winsound.SND_ASYNC) ########################################################################
Example #28
Source File: uiBasicWidget.py From vnpy_crypto with MIT License | 5 votes |
def play_trade(self, event): """播放交易声音""" # 1.获取事件的Trade数据 trade = event.dict_['data'] winsound.PlaySound('match.wav', winsound.SND_ASYNC) ########################################################################
Example #29
Source File: uiMultiRpcMonitor.py From vnpy_crypto with MIT License | 5 votes |
def updateWarning(self, event): """更新相关Warning """ log = event.dict_['data'] content = '\t'.join([log.logTime, log.logContent]) self.logMonitor.append(content) winsound.PlaySound('err.wav', winsound.SND_ASYNC) # ----------------------------------------------------------------------
Example #30
Source File: uiMultiRpcMonitor.py From vnpy_crypto with MIT License | 5 votes |
def updateError(self, event): """更新相关Error """ log = event.dict_['data'] content = '\t'.join([log.errorTime, log.errorID,log.errorMsg,log.additionalInfo]) self.logMonitor.append(content) winsound.PlaySound('err.wav', winsound.SND_ASYNC) # ----------------------------------------------------------------------