我将watson speech to text api与Python3一起用于一个项目,我必须编写一个新的命令来打开一个项目,但我很难弄清楚如何做到这一点。 这是我的命令代码
# Adding a command to launch an application
if x[0] ['alternatives'] [0] ['transcript'] == 'run ' and Command_State is 'Started':
print("Running...")
Command_State = 'Run'
self.listening = True
程序将看到命令并将命令状态设置为“Run”,然后我有一个if语句,我计划将代码放入运行应用程序中
# If statement to, watch for Command_State to switch to 'Run".
if Command_State == 'Run':
print("Running chrome")
# Code goes here
pass
目前,我在if语句中只有一个print语句和一个pass语句,但我想在这里放置运行应用程序的代码。我在考虑可能通过cmd运行它,但是我发现唯一一个谈论这个的代码已经过时了,并且不起作用。无论如何,谢谢你的帮助
我已经知道了怎么做这是我使用的代码。我决定只在一个if语句中完成这一切,因为这样做要简单得多,但是如果您希望使用set命令来更改命令的运行状态,那么可以侦听其他命令,例如“Netflix”来打开Netflix或“我恨我自己”来打开internetexplorer
只要它是可执行文件,您就可以用您想要的任何东西替换我的路径。我的意思是,我想你可以试试,但不能保证它会起作用
相关问题 更多 >
编程相关推荐