def __init__(self, directory):
        # Open STT Service
        with open(join(directory, "sttConfig.json")) as confile:
            stt_config = json.load(confile)['credentials']
        self.speechToText = SpeechToTextV1(username=stt_config['username'],
                                           password=stt_config['password'])

        # Open TTS Service
        with open(join(directory, "ttsConfig.json")) as confile:
            tts_config = json.load(confile)['credentials']
        self.textToSpeech = TextToSpeechV1(username=tts_config['username'],
                                           password=tts_config['password'])

        # Open the Dialog Service
        with open(join(directory, "dialogConfig.json")) as confile:
            dialog_config = json.load(confile)['credentials']
        self.dialogID = dialog_config['id']
        self.dialog = DialogV1(username=dialog_config['username'],
                               password=dialog_config['password'])
        self.response = self.dialog.conversation(self.dialogID)
        self.workingDirectory = directory
Esempio n. 2
0
# coding=utf-8
import json
from os.path import join, dirname
from watson_developer_cloud import DialogV1

dialog = DialogV1(username='******',
                  password='******')

print(json.dumps(dialog.get_dialogs(), indent=2))

# print(json.dumps(dialog.get_dialog('6250d170-41d6-468a-a697-5675578c8012'), indent=2))

# CREATE A DIALOG
# with open(join(dirname(__file__), '../resources/dialog.xml') as dialog_file:
#     print(json.dumps(dialog.create_dialog(
#         dialog_file=dialog_file, name='pizza_test_9'), indent=2))

# dialog_id = '98734721-8952-4a1c-bb72-ef9957d4be93'

# with open(join(dirname(__file__), '../resources/dialog.xml') as dialog_file:
#     print(json.dumps(dialog.update_dialog(dialog_file=dialog_file, dialog_id=dialog_id), indent=2))

# print(json.dumps(dialog.get_content(dialog_id), indent=2))
#
# initial_response = dialog.conversation(dialog_id)
#
# print(json.dumps(initial_response, indent=2))
#
# print(json.dumps(dialog.conversation(dialog_id=dialog_id,
#                                      dialog_input='What type of toppings do you have?',
#                                      conversation_id=initial_response['conversation_id'],