-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.py
62 lines (52 loc) · 2.21 KB
/
main.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
60
61
62
"""
Starts the dialogue system. Command-line parameters can specified through system properties via
the --flag. All parameters are optional.
Some of the possible properties are:
--domain path/to/domain/file: dialogue domain file
--dialogue path/to/recorded/dialogue: dialogue file to import
--simulator path/to/simulator/file: domain file for the simulator
"""
import argparse
import logging
import os
from dialogue_system import DialogueSystem
from modules.simulation.simulator import Simulator
from plugins.GoogleSTT import GoogleSTT
from plugins.GoogleTTS import GoogleTTS
from readers.xml_domain_reader import XMLDomainReader
parser = argparse.ArgumentParser()
parser.add_argument('--domain', type=str, help='domain file path')
# parser.add_argument('--dialogue', type=str, help='dialogue file path')
parser.add_argument('--simulator', type=str, help='simulator file path')
args = parser.parse_args()
# Set logger
logger = logging.getLogger('PyOpenDial')
logger.setLevel(logging.DEBUG)
logger.addHandler(logging.StreamHandler())
if args.domain is not None:
system = DialogueSystem(args.domain)
else:
system = DialogueSystem()
if args.domain:
try:
domain = XMLDomainReader.extract_domain(args.domain)
system.log.info("Domain from %s successfully extracted" % args.domain)
except Exception as e:
system.display_comment("Cannot load domain: %s" % e)
domain = XMLDomainReader.extract_empty_domain(args.domain)
system.change_domain(domain)
if args.simulator:
simulator = Simulator(system, XMLDomainReader.extract_domain(args.simulator))
system.log.info("Simulator with domain %s successfully extracted" % args.simulator)
system.attach_module(simulator)
settings = system.get_settings()
system.change_settings(settings)
if os.path.exists(settings.GOOGLE_APPLICATION_CREDENTIALS):
os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = settings.GOOGLE_APPLICATION_CREDENTIALS
system.attach_module(GoogleSTT(system))
system.attach_module(GoogleTTS(system))
print('Google SST/TTS modules are attached.')
else:
print("In order to use Google SST/TTS modules, please specify your 'GOOGLE_APPLICATION_CREDENTIALS' in settings.yml")
system.start_system()
print("Dialogue system started!")