forked from MyDuerOS/DuerOS-Python-Client
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathenter_trigger_main.py
More file actions
59 lines (45 loc) · 1.26 KB
/
enter_trigger_main.py
File metadata and controls
59 lines (45 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# -*- coding: utf-8 -*-
'''
通过输入[Enter]触发唤醒状态
'''
import logging
from sdk.dueros_core import DuerOS
from app.framework.mic import Audio
from app.framework.player import Player
from app.utils.prompt_tone import PromptTone
logging.basicConfig(level=logging.INFO)
def directive_listener(directive_content):
'''
云端下发directive监听器
:param directive_content:云端下发directive内容
:return:
'''
content = u'云端下发directive:%s' % (directive_content)
logging.info(content)
def main():
# 创建录音设备(平台相关)
audio = Audio()
# 创建播放器(平台相关)
player = Player()
dueros = DuerOS(player)
dueros.set_directive_listener(directive_listener)
audio.link(dueros)
dueros.start()
audio.start()
prompt_tone_player = PromptTone(player)
while True:
try:
try:
print '\n'
input('单击[Enter]建,然后发起对话\n')
except SyntaxError:
pass
# 唤醒态提示音
prompt_tone_player.play()
dueros.listen()
except KeyboardInterrupt:
break
dueros.stop()
audio.stop()
if __name__ == '__main__':
main()