import winreg,winsound,pyttsx3,os,functools engine = pyttsx3.init() engine.setProperty('volume', 1)# 设置音量(0到1之间) rate = engine.getProperty('rate')# 设置语速 engine.setProperty('rate', rate-50) voices = engine.getProperty('voices') newVoice = voices[0] engine.setProperty('voice', newVoice.id) r_path = os.path.join(os.environ['USERPROFILE'])+"\AppData\Local\Temp" def ApplicationInstance(func): @functools.wraps(func) def fun(*args,**kwargs): import socket try: global s s = socket.socket() host = socket.gethostname() s.bind((host, 60124)) except: return print('程序已打开') return func(*args,**kwargs) return fun @ApplicationInstance def cpu_Monitor(): while True: try: registry_path = r'SOFTWARE\\FinalWire\AIDA64\\SensorValues' # 获取注册表该位置的所有键值 key = winreg.OpenKey(winreg.HKEY_CURRENT_USER, registry_path) value = winreg.QueryValueEx(key,'Value.TCC-1-1')[0] if int(value)> 80: filename = r_path+r'\Countdown.wav' winsound.PlaySound(filename, winsound.SND_FILENAME) # winsound.Beep(frequency=2500,duration=1000) engine.say('cpu当前温度%s度'%value) engine.runAndWait() except: pass if __name__ == '__main__': cpu_Monitor()
**注意:此方法只适用于intel cpu
标签:engine,__,winreg,AIDA64,python,rate,警报,winsound,path From: https://www.cnblogs.com/xcsg/p/18204725