Пример #1
0
import time
from xbmcjson import XBMC
import sys
if sys.platform.find('linux') >=0:
	from speechdispatcher import SPEECHDISPATCHER as TTS
else:
	from nvda import NVDA as TTS

s = TTS()
xbmc=XBMC("http://localhost:8080/jsonrpc")

controlLabel=""
windowLabel=""
windowID=0
while True:
	resp =xbmc.GUI.GetProperties({"properties":["currentcontrol","currentwindow"]})
	# print resp
	win=resp['result']['currentwindow']
	ctrl=resp['result']['currentcontrol']
	if controlLabel !=ctrl['label']:
		if windowID !=win['id']:
			windowID =win['id']
			windowLabel=win['label']
		controlLabel=ctrl['label']
		if s.canSpeak():
			print("%s\t%s"%(windowLabel,controlLabel))
			s.speak("%s\t%s"%(windowLabel,controlLabel))
		windowLabel=""
	time.sleep(1)
Пример #2
0
	from nvda import NVDA as TTS
import re

stripHTMLRegExp=re.compile(r'(<!--.*?-->|<[^>]*>)')

def stripHTML(text):
	return re.sub(stripHTMLRegExp, '', text)

args = urlparse.parse_qs(sys.argv[2][1:])

oldID =json.loads(xbmc.executeJSONRPC(r'{"jsonrpc":"2.0","id":0,"method":"Gui.GetProperties","params":{"properties":["currentwindow"]}}'))['result']['currentwindow']['id']
action = args.get('action', None)

if action:
	action = action[0]
	xbmc.executebuiltin("Action(%s)"%action)
	time.sleep(0.2)

resp =json.loads(xbmc.executeJSONRPC(r'{"jsonrpc":"2.0","id":0,"method":"Gui.GetProperties","params":{"properties":["currentwindow","currentcontrol"]}}'))
s = TTS()
if s.canSpeak():
	text=""
	if action==None or resp['result']['currentwindow']['id'] !=oldID:
		text="%s: "%resp['result']['currentwindow']['label']
	text="%s%s"%(text,resp['result']['currentcontrol']['label'])
	text=stripHTML(text)
	s.speak(text)
s.terminate()
sys.exit(0)