

지원 종료 공지: 2025년 9월 15 AWS 일에는 Amazon Lex V1에 대한 지원을 중단할 예정입니다. 2025년 9월 15일 이후에는 Amazon Lex V1 콘솔 또는 Amazon Lex V1 리소스에 더 이상 액세스할 수 없습니다. Amazon Lex V2를 사용하는 경우 대신 [Amazon Lex V2 가이드를](https://docs.aws.amazon.com/lexv2/latest/dg/what-is.html) 참조하세요.

기계 번역으로 제공되는 번역입니다. 제공된 번역과 원본 영어의 내용이 상충하는 경우에는 영어 버전이 우선합니다.

# 음성 입력을 사용하여 봇 테스트(AWS CLI)
<a name="gs-create-test-speech"></a>

오디오 파일을 사용하여 봇을 테스트하려면 [PostContent](API_runtime_PostContent.md) 작업을 사용합니다. Amazon Polly 텍스트 음성 변환 작업을 사용하여 오디오 파일을 생성합니다.

이 연습에서 명령을 실행하려면 Amazon Lex 및 Amazon Polly 명령이 실행될 리전을 알아야 합니다. Amazon Lex의 지역 목록은 [런타임 서비스 할당량](gl-limits.md#gl-limits-runtime)을 참조하십시오. Amazon Polly 리전 목록은 *Amazon Web Services 일반 참조*에서 [AWS 리전 및 엔드포인트](https://docs.aws.amazon.com/general/latest/gr/rande.html#pol_region)를 참조하세요.

**참고**  
다음 AWS CLI 예제는 Unix, Linux 및 macOS용으로 포맷되어 있습니다. Windows의 경우 `"\$LATEST"`를 `$LATEST`로 바꾸고, 각 줄의 끝에 있는 백슬래시(\$1) 연속 문자를 캐럿(^)으로 변경합니다.

**음성 입력을 사용하여 봇을 테스트하려면(AWS CLI)**

1. 에서 Amazon Polly를 사용하여 오디오 파일을 AWS CLI생성합니다. 다음은 Unix, Linux, macOS용 형식으로 지정된 예제입니다. Windows의 경우 각 줄의 끝에 있는 백슬래시(\$1) Unix 연속 문자를 캐럿(^)으로 바꿉니다.

   ```
   aws polly synthesize-speech \
       --region region \
       --output-format pcm \
       --text "i would like to order flowers" \
       --voice-id "Salli" \
       IntentSpeech.mpg
   ```

1. Amazon Lex 에서 오디오 파일을 보내려면 다음 명령을 실행합니다. Amazon Lex는 오디오 응답을 지정된 출력 파일에 저장합니다.

   ```
   aws lex-runtime post-content \
       --region region \
       --bot-name OrderFlowersBot \
       --bot-alias "\$LATEST" \
       --user-id UserOne \
       --content-type "audio/l16; rate=16000; channels=1" \
       --input-stream IntentSpeech.mpg \
       IntentOutputSpeech.mpg
   ```

   Amazon Lex는 첫 번째 슬롯에 대한 요청으로 응답합니다. 오디오 응답을 지정된 출력 파일에 저장합니다.

   ```
   {
       "contentType": "audio/mpeg", 
       "slotToElicit": "FlowerType", 
       "dialogState": "ElicitSlot", 
       "intentName": "OrderFlowers", 
       "inputTranscript": "i would like to order some flowers", 
       "slots": {
           "PickupDate": null, 
           "PickupTime": null, 
           "FlowerType": null
       }, 
       "message": "What type of flowers would you like to order?"
   }
   ```

1. 장미를 주문하려면 다음 오디오 파일을 생성하여 Amazon Lex에 보냅니다.

   ```
   aws polly synthesize-speech \
       --region region \
       --output-format pcm \
       --text "roses" \
       --voice-id "Salli" \ 
       FlowerTypeSpeech.mpg
   ```

   ```
   aws lex-runtime post-content \
       --region region \
       --bot-name OrderFlowersBot \
       --bot-alias "\$LATEST" \
       --user-id UserOne \
       --content-type "audio/l16; rate=16000; channels=1" \
       --input-stream FlowerTypeSpeech.mpg \
       FlowerTypeOutputSpeech.mpg
   ```

1. 배달 날짜를 설정하려면 다음 오디오 파일을 만들어 Amazon Lex로 보냅니다.

   ```
   aws polly synthesize-speech \
       --region region \
       --output-format pcm \
       --text "tuesday" \
       --voice-id "Salli" \ 
       DateSpeech.mpg
   ```

   ```
   aws lex-runtime post-content \
       --region region \
       --bot-name OrderFlowersBot \
       --bot-alias "\$LATEST" \
       --user-id UserOne \
       --content-type "audio/l16; rate=16000; channels=1" \
       --input-stream DateSpeech.mpg \
       DateOutputSpeech.mpg
   ```

1. 배달 날짜를 설정하려면 다음 오디오 파일을 만들어 Amazon Lex 로 보냅니다.

   ```
   aws polly synthesize-speech \
       --region region \
       --output-format pcm \
       --text "10:00 a.m." \
       --voice-id "Salli" \
       TimeSpeech.mpg
   ```

   ```
   aws lex-runtime post-content \
       --region region \
       --bot-name OrderFlowersBot \
       --bot-alias "\$LATEST" \
       --user-id UserOne \
       --content-type "audio/l16; rate=16000; channels=1" \
       --input-stream TimeSpeech.mpg \
       TimeOutputSpeech.mpg
   ```

1. 배달 여부를 확인하려면 다음 오디오 파일을 만들어 Amazon Lex로 보냅니다.

   ```
   aws polly synthesize-speech \
       --region region \
       --output-format pcm \
       --text "yes" \
       --voice-id "Salli" \
       ConfirmSpeech.mpg
   ```

   ```
   aws lex-runtime post-content \
       --region region \
       --bot-name OrderFlowersBot \
       --bot-alias "\$LATEST" \
       --user-id UserOne \
       --content-type "audio/l16; rate=16000; channels=1" \
       --input-stream ConfirmSpeech.mpg \
       ConfirmOutputSpeech.mpg
   ```

   배달 확인 후에는 Amazon Lex가 의도 이행을 확인하는 응답을 보냅니다.

   ```
   {
       "contentType": "text/plain;charset=utf-8", 
       "dialogState": "ReadyForFulfillment", 
       "intentName": "OrderFlowers", 
       "inputTranscript": "yes", 
       "slots": {
           "PickupDate": "2017-05-16", 
           "PickupTime": "10:00", 
           "FlowerType": "roses"
       }
   }
   ```

## 다음 단계
<a name="gs-cli-next-exercise-2"></a>

[연습 2: 새 표현 추가(AWS CLI)](gs-cli-update-utterance.md)