Miscellaneous

echosim 에서 Amazon Echo 음성인식 맛보기 2

[혜안] 2017. 11. 27. 22:57
728x90

echosim 에서 Amazon Echo 음성인식 맛보기 2

드디어 어제 주말까지 잔잔하게 괴롭히던 일정이 마무리 되었다. 이미 한달이 넘은 내용이지만 그래도 이어서 포스팅해본다.

2017/10/29 - [Miscellaneous] - echosim.io 에서 Amazon Echo 음성인식 맛보기 1 

이전 포스팅에서 테스트용 Lambda function을 만들었고, 이제 AWS개발자 포털에서 Alexa 스킬을 생성하여 연결해주기만 하면 된다.


1. 개발자 포털에 접속하여 신규가입

developer.amazon.com


2. Alexa Skills Kit -> Start a Skill



3. Skill 생성

3.1 기본정보 입력

Name은 임의로 넣어도 상관없지만, Invocation Name은 나중에 내가 음성으로 불어내야 하는 Skill 명이다.
따라서 음성인식이 잘 되고, 유니크한 이름이 좋다.


3.2 Interaction Model

저장을 하고 다음 화면으로 넘어가면 음성 명령과 Lambda function을 매핑하는 화면이다.
아래 정보를 입력하자. (Skill Builder 베타서비스 중이라 하여 사용해봤지만 영 불편하다.)

Intent Schema

{
  "intents": [
    {
      "slots": [
        {
          "name": "Region",
          "type": "LIST_OF_REGIONS"
        }
      ],
      "intent": "SetRegionIntent"
    },
    {
      "intent": "GetRegionIntent"
    },
    {
      "intent": "InstanceCountIntent"
    },
    {
      "intent": "TerminateUntaggedInstancesIntent"
    },
    {
      "slots": [
        {
          "name": "Instance",
          "type": "LIST_OF_INSTANCES"
        }
      ],
      "intent": "StopInstanceIntent"
    },
    {
      "slots": [
        {
          "name": "Instance",
          "type": "LIST_OF_INSTANCES"
        }
      ],
      "intent": "LaunchInstanceIntent"
    },
    {
      "intent": "AMAZON.HelpIntent"
    }
  ]
}

호출할 Lambda function들이다.
아래는 입력 화면..




그리고 호출할 명령어 내에 정해진 목록이 있다면 아래와 같이 슬롯을 만들어 파라미터처럼 넘길 수 있다.
LIST_OF_REGIONS과 LIST_OF_INSTANCES를 만들어보자.


Custom Slot Types - Regions
LIST_OF_REGIONS
Virginia
Oregon 
Seoul 
Tokyo 
Singapore

화면상으로는 아래와 같다.


Custom Slot Types - Instances
LIST_OF_INSTANCES
window
linux


역시 화면상으로는 아래와 같다.




이제 Lambda function과 명령어를 매핑시킨다.
Sample Utterances
SetRegionIntent set my region to {Region}
SetRegionIntent set the region to {Region}
GetRegionIntent what region is set
GetRegionIntent what's my region
GetRegionIntent what's the selected region
GetRegionIntent what region is selected
InstanceCountIntent how many instances are running
InstanceCountIntent what's the instance count
InstanceCountIntent what's the current instance count
TerminateUntaggedInstancesIntent clean up untagged instances
TerminateUntaggedInstancesIntent delete untagged instances
TerminateUntaggedInstancesIntent clean up instances
StopInstanceIntent stop {Instance} instance
LaunchInstanceIntent launch {Instance} instance


완료되면 아래와 같이 보인다.


3.3 Configuration

다음으로 넘어가면 Lambda function과 연결을 설정하는 화면이 나온다.
작성한 Lambda function의 ARN 을 넣어주면 된다.모르겠으면 다시 AWS 콘솔로 돌아가서 확인.


그리고 아래와 같이 설정해주자.


3.4 Test

기본 설정은 완료되었다.
Test 화면으로 넘어가면 Service Simulator에서 텍스트로 미리 시험해 볼 수 있다.
위 3.2절에서 넣은 Sample Utterances 를 하나씩 넣어보자.
눈치챘겠지만 {} 안의 값은 미리 정의한 Slot Type 중에 하나를 선택하면 된다.
예를 들면, set my region to {Region} 은 set my region to seoul 을 넣으면 된다.
그러면 아래와 같이 응답이 올 것이다.




이어서 다른 질문 [how many instances are running]




이번엔 인스턴스 중지 명령 [stop linux instance]




AWS 콘솔에 들어가보면 실제로 인스턴스가 중지되고 있다.


여기까지만 하면 echosim에서 내 스킬을 부를 수 있다.
echosim 연결은 다음 포스팅에…




728x90