-
Notifications
You must be signed in to change notification settings - Fork 26
/
xuebao.py
executable file
·59 lines (49 loc) · 1.97 KB
/
xuebao.py
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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
please visit https://github.com/niutool/xuebao
for more detail
"""
import sys
import logging
import argparse
from client import settings
from client import application
if __name__ == "__main__":
parser = argparse.ArgumentParser(description='Xuebao: the story robot')
parser.add_argument('--local', action='store_true', help='Use text input instead of a real microphone')
parser.add_argument('--debug', action='store_true', help='Print debug messages')
list_info = parser.add_mutually_exclusive_group(required=False)
list_info.add_argument('--list-plugins', action='store_true', help='List plugins and exit')
list_info.add_argument('--list-audio-devices', action='store_true', help='List audio devices and exit')
list_info.add_argument('--list-phrases', action='store_true', help='List phrases and exit')
args = parser.parse_args()
if args.debug:
log_level = logging.DEBUG
else:
log_level = logging.INFO
logging.basicConfig(level=log_level,
format='%(asctime)s %(name)-12s %(levelname)-8s %(message)s',
datefmt='%m-%d %H:%M',
filename=settings.LOG_FILE,
filemode='w')
console = logging.StreamHandler()
console.setLevel(log_level)
formatter = logging.Formatter('%(name)-12s: %(levelname)-8s %(message)s')
console.setFormatter(formatter)
logging.getLogger('').addHandler(console)
logging.info('=' * 64)
logging.info('-%s-' % 'XUEBAO - The Story Robot'.center(62))
logging.info('-%s-' % '(c) 2015 niutool.com'.center(62))
logging.info('=' * 64)
app = application.Xuebao(use_local_mic=args.local)
if args.list_plugins:
app.list_plugins()
sys.exit(1)
elif args.list_audio_devices:
app.list_audio_devices()
sys.exit(0)
elif args.list_phrases:
app.list_phrases()
sys.exit(2)
app.run()