def launch_request_handler(clova_request): # You can answer in different languages within one response welcome_japanese = cek.Message(message="ようこそ!", language="ja") welcome_korean = cek.Message(message="환영!", language="ko") response = clova.response(["Welcome~~!", welcome_japanese, welcome_korean, "How can i help you?"]) return response
def _advise_training(slot): if "胸筋" in slot: message_japanese = cek.Message(message="ベンチプレスをやりましょう", language="ja") elif "上腕二頭筋" in slot: message_japanese = cek.Message(message="アームカールをやりましょう", language="ja") elif "上腕三頭筋" in slot: message_japanese = cek.Message(message="トライセプスキックバックをやりましょう", language="ja") elif "腹筋" in slot: message_japanese = cek.Message(message="クランチをやりましょう", language="ja") return message_japanese
def launch_request_handler(clova_request): # You can answer in different languages within one response welcome_japanese = cek.Message(message="おはよう。もう体重は測った?", language="ja") response = clova.response([welcome_japanese]) return response
def test_response_message_set_verbose_list(self): message_set = cek.MessageSet( brief="title", verbose=["First Message", cek.Message("Second Message", "en")]) response = clova.response(message_set) output_speech = response['response']['outputSpeech'] self.assertEqual(output_speech['type'], 'SpeechSet') self.assertEqual(output_speech['brief']['lang'], 'en') self.assertEqual(output_speech['brief']['type'], 'PlainText') self.assertEqual(output_speech['brief']['value'], 'title') self.assertEqual(output_speech['verbose']['type'], 'SpeechList') self.assertEqual(output_speech['verbose']['values'][0]['lang'], 'en') self.assertEqual(output_speech['verbose']['values'][0]['type'], 'PlainText') self.assertEqual(output_speech['verbose']['values'][0]['value'], 'First Message') self.assertEqual(output_speech['verbose']['values'][1]['lang'], 'en') self.assertEqual(output_speech['verbose']['values'][1]['type'], 'PlainText') self.assertEqual(output_speech['verbose']['values'][1]['value'], 'Second Message')
def test_response_message_language(self): message = cek.Message(message="こんにちは!", language='ja') response = clova.response(message) output_speech = response['response']['outputSpeech'] self.assertEqual(output_speech['type'], 'SimpleSpeech') self.assertEqual(output_speech['values']['lang'], 'ja') self.assertEqual(output_speech['values']['type'], 'PlainText') self.assertEqual(output_speech['values']['value'], 'こんにちは!')
def test_error_nested_message_set(self): message_set = cek.MessageSet( brief="title", verbose=["One Message", cek.Message("Other Message", "en")]) nested_message_set = cek.MessageSet(brief="title", verbose=message_set) with self.assertRaises(TypeError): clova.response(nested_message_set)
def test_wrong_language(self): # Tets builders for lang in ["es", "jp"]: with self.assertRaises(ValueError): clova.response(cek.Message("Hola", lang)) with self.assertRaises(ValueError): Clova(application_id="", default_language=lang, debug_mode=True)
def play_sound_intent_handler(clova_request): app.logger.info("Intent started") message = cek.Message(message="赤ちゃんが落ち着く音を再生します。", language="ja") sound_url = cek.URL( "https://s3-ap-northeast-1.amazonaws.com/takecian-clova/plastic_sound.mp3" ) response = clova.response( [message, sound_url, sound_url, sound_url, sound_url]) return response
def advise_handler(clova_request): print('request was submitted.') message_japanese = cek.Message(message='何をおっしゃっているのかよくわかりません', language="ja") # weightに紐づいてるスロットが存在する -> 体重を入力された user_id = clova_request.user_id slot = clova_request.slot_value("weight") if slot is not None: print(slot) msg = '{}キロですね。了解です。今日の運動のレコメンドを lineに送 った よ!'.format(slot) message_japanese = cek.Message(message=msg, language="ja") job = Process(target=log_wight, args=( slot, user_id, )) job.start() response = clova.response([message_japanese]) return response
def test_response_message(self): message = cek.Message("Hello! How are you?") response = clova.response(message) output_speech = response['response']['outputSpeech'] self.assertEqual(output_speech['type'], 'SimpleSpeech') self.assertEqual(output_speech['values']['lang'], 'en') self.assertEqual(output_speech['values']['type'], 'PlainText') self.assertEqual(output_speech['values']['value'], 'Hello! How are you?')
def handler(clova_request): # バグがあるかもしれない # textの形式次第で print("clova intent = %s" % intent) msg = create_reply([text], source="clova") # msg = plant_animator.communicate(text, None) if msg is None: msg = "誰ともお話ししていません" message_japanese = cek.Message(message=msg, language="ja") response = clova.response([message_japanese]) return response
def number_handler(clova_request): app.logger.info("Intent started") start_num = clova_request.slot_value("startNum") end_num = clova_request.slot_value('endNum') app.logger.info("startNum: {}, endNum: {}".format(str(start_num), str(end_num))) res = decide_num(end_num, start_num) message_japanese = cek.Message(message="結果は{}でした。".format(res), language="ja") response = clova.response([message_japanese]) return response
def test_response_list(self): url = cek.URL('http://my.soundfile.mp3') message1 = cek.Message("Hello! How are you?") message2 = "Bye bye!" response = clova.response([message1, url, message2]) output_speech = response['response']['outputSpeech'] self.assertEqual(output_speech['type'], 'SpeechList') self.assertEqual(output_speech['values'][0]['lang'], 'en') self.assertEqual(output_speech['values'][0]['type'], 'PlainText') self.assertEqual(output_speech['values'][0]['value'], 'Hello! How are you?') self.assertEqual(output_speech['values'][1]['lang'], '') self.assertEqual(output_speech['values'][1]['type'], 'URL') self.assertEqual(output_speech['values'][1]['value'], 'http://my.soundfile.mp3') self.assertEqual(output_speech['values'][2]['lang'], 'en') self.assertEqual(output_speech['values'][2]['type'], 'PlainText') self.assertEqual(output_speech['values'][2]['value'], 'Bye bye!')
def play_sound_intent_handler(clova_request): app.logger.info("Intent started") message = cek.Message(message=get_support_message(), language="ja") response = clova.response([message]) return response
def launch_request_handler(clova_request): open_message = "こんにちは、いつでもあなたの味方です" welcome_japanese = cek.Message(message=open_message, language="ja") response = clova.response([welcome_japanese]) return response
def no_intent(clova_request): cek_message = cek.Message(message="はい、わかりました!", language="ja") return clova.response(cek_message)
def launch_request_handler(clova_request): open_message = "こんにちは,サイコロに設定したい数字を指定してください" welcome_japanese = cek.Message(message=open_message, language="ja") response = clova.response([welcome_japanese]) return response
def launch_request_handler(clova_request): welcome_japanese = cek.Message(message="あなたは誰?どこに行くんですか?", language="ja") response = clova.response([welcome_japanese]) return response
def advise_handler(clova_request): msg = 'なんキロ だっ た?' message_japanese = cek.Message(message=msg, language="ja") response = clova.response([message_japanese]) return response
def launch_request_handler(clova_request): welcome_japanese = cek.Message(message="起動しました", language="ja") response = clova.response([welcome_japanese]) return response
def wife_status_handler(clova_request): print("Get Task list") message_japanese = cek.Message(message="Coming soon...", language="ja") response = clova.response([message_japanese]) return response
def launch_request_handler(clova_request): open_message = "こんにちは、赤ちゃんのお世話はお任せください" welcome_japanese = cek.Message(message=open_message, language="ja") response = clova.response([welcome_japanese]) return response