

# AWS CLI를 사용한 Amazon Polly 예시
<a name="cli_polly_code_examples"></a>

다음 코드 예시는 Amazon Polly와 함께 AWS Command Line Interface를 사용하여 일반적인 시나리오를 구현하는 방법을 보여줍니다.

*작업*은 대규모 프로그램에서 발췌한 코드이며 컨텍스트에 맞춰 실행해야 합니다. 작업은 개별 서비스 함수를 직접적으로 호출하는 방법을 보여주며 관련 시나리오의 컨텍스트에 맞는 작업을 볼 수 있습니다.

각 예시에는 전체 소스 코드에 대한 링크가 포함되어 있으며, 여기에서 컨텍스트에 맞춰 코드를 설정하고 실행하는 방법에 대한 지침을 찾을 수 있습니다.

**Topics**
+ [작업](#actions)

## 작업
<a name="actions"></a>

### `delete-lexicon`
<a name="polly_DeleteLexicon_cli_topic"></a>

다음 코드 예시에서는 `delete-lexicon`의 사용 방법을 보여줍니다.

**AWS CLI**  
**어휘 삭제**  
다음 `delete-lexicon` 예시에서는 지정된 어휘를 삭제합니다.  

```
aws polly delete-lexicon \
    --name w3c
```
이 명령은 출력을 생성하지 않습니다.  
자세한 내용은 *Amazon Polly 개발자 안내서*의 [DeleteLexicon 작업 사용](https://docs.aws.amazon.com/polly/latest/dg/gs-delete-lexicon.html)을 참조하세요.  
+  API 세부 정보는 *AWS CLI 명령 참조*의 [DeleteLexicon](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/polly/delete-lexicon.html)을 참조하세요.

### `get-lexicon`
<a name="polly_GetLexicon_cli_topic"></a>

다음 코드 예시에서는 `get-lexicon`의 사용 방법을 보여줍니다.

**AWS CLI**  
**어휘의 콘텐츠 가져오기**  
다음 `get-lexicon` 예시에서는 지정된 발음 어휘의 콘텐츠를 검색합니다.  

```
aws polly get-lexicon \
    --name w3c
```
출력:  

```
{
    "Lexicon": {
        "Content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<lexicon version=\"1.0\" \n      xmlns=    \"http://www.w3.org/2005/01/pronunciation-lexicon\"\n      xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" \n          xsi:schemaLocation=\"http://www.w3.org/2005/01/pronunciation-lexicon \n        http://www.w3.org/TR/2007/CR-pronunciation-    lexicon-20071212/pls.xsd\"\n      alphabet=\"ipa\" \n      xml:lang=\"en-US\">\n  <lexeme>\n    <grapheme>W3C</grapheme>\n        <alias>World Wide Web Consortium</alias>\n  </lexeme>\n</lexicon>\n",
        "Name": "w3c"
    },
    "LexiconAttributes": {
        "Alphabet": "ipa",
        "LanguageCode": "en-US",
        "LastModified": 1603908910.99,
        "LexiconArn": "arn:aws:polly:us-west-2:880185128111:lexicon/w3c",
        "LexemesCount": 1,
        "Size": 492
    }
}
```
자세한 내용은 *Amazon Polly 개발자 안내서*의 [GetLexicon 작업 사용](https://docs.aws.amazon.com/polly/latest/dg/gs-get-lexicon.html)을 참조하세요.  
+  API 세부 정보는 *AWS CLI 명령 참조*의 [GetLexicon](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/polly/get-lexicon.html)을 참조하세요.

### `get-speech-synthesis-task`
<a name="polly_GetSpeechSynthesisTask_cli_topic"></a>

다음 코드 예시에서는 `get-speech-synthesis-task`의 사용 방법을 보여줍니다.

**AWS CLI**  
**음성 합성 작업 정보 가져오기**  
다음 `get-speech-synthesis-task` 예시에서는 지정된 음성 합성 태스크에 대한 정보를 검색합니다.  

```
aws polly get-speech-synthesis-task \
    --task-id 70b61c0f-57ce-4715-a247-cae8729dcce9
```
출력:  

```
{
    "SynthesisTask": {
        "TaskId": "70b61c0f-57ce-4715-a247-cae8729dcce9",
        "TaskStatus": "completed",
        "OutputUri": "https://s3.us-west-2.amazonaws.com/amzn-s3-demo-bucket/70b61c0f-57ce-4715-a247-cae8729dcce9.mp3",
        "CreationTime": 1603911042.689,
        "RequestCharacters": 1311,
        "OutputFormat": "mp3",
        "TextType": "text",
        "VoiceId": "Joanna"
    }
}
```
자세한 내용은 *Amazon Polly 개발자 안내서*의 [긴 오디오 파일 생성](https://docs.aws.amazon.com/polly/latest/dg/longer-cli.html)을 참조하세요.  
+  API 세부 정보는 *AWS CLI 명령 참조*의 [GetSpeechSynthesisTask](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/polly/get-speech-synthesis-task.html)를 참조하세요.

### `list-lexicons`
<a name="polly_ListLexicons_cli_topic"></a>

다음 코드 예시에서는 `list-lexicons`의 사용 방법을 보여줍니다.

**AWS CLI**  
**어휘 나열**  
다음 `list-lexicons` 예시에서는 발음 어휘를 나열합니다.  

```
aws polly list-lexicons
```
출력:  

```
{
    "Lexicons": [
        {
            "Name": "w3c",
            "Attributes": {
                "Alphabet": "ipa",
                "LanguageCode": "en-US",
                "LastModified": 1603908910.99,
                "LexiconArn": "arn:aws:polly:us-east-2:123456789012:lexicon/w3c",
                "LexemesCount": 1,
                "Size": 492
            }
        }
    ]
}
```
자세한 내용은 *Amazon Polly 개발자 안내서*의 [ListLexicons 작업 사용](https://docs.aws.amazon.com/polly/latest/dg/gs-list-lexicons.html)을 참조하세요.  
+  API 세부 정보는 *AWS CLI 명령 참조*의 [ListLexicons](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/polly/list-lexicons.html)를 참조하세요.

### `list-speech-synthesis-tasks`
<a name="polly_ListSpeechSynthesisTasks_cli_topic"></a>

다음 코드 예시에서는 `list-speech-synthesis-tasks`의 사용 방법을 보여줍니다.

**AWS CLI**  
**음성 합성 작업 나열**  
다음 `list-speech-synthesis-tasks` 예시에서는 음성 합성 작업을 나열합니다.  

```
aws polly list-speech-synthesis-tasks
```
출력:  

```
{
    "SynthesisTasks": [
        {
            "TaskId": "70b61c0f-57ce-4715-a247-cae8729dcce9",
            "TaskStatus": "completed",
            "OutputUri": "https://s3.us-west-2.amazonaws.com/amzn-s3-demo-bucket/70b61c0f-57ce-4715-a247-cae8729dcce9.mp3",
            "CreationTime": 1603911042.689,
            "RequestCharacters": 1311,
            "OutputFormat": "mp3",
            "TextType": "text",
            "VoiceId": "Joanna"
        }
    ]
}
```
자세한 내용은 *Amazon Polly 개발자 안내서*의 [긴 오디오 파일 생성](https://docs.aws.amazon.com/polly/latest/dg/longer-cli.html)을 참조하세요.  
+  API 세부 정보는 *AWS CLI 명령 참조*의 [ListSpeechSynthesisTasks](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/polly/list-speech-synthesis-tasks.html)를 참조하세요.

### `put-lexicon`
<a name="polly_PutLexicon_cli_topic"></a>

다음 코드 예시에서는 `put-lexicon`의 사용 방법을 보여줍니다.

**AWS CLI**  
**어휘 저장**  
다음 `put-lexicon` 예시에서는 지정된 발음 어휘를 저장합니다. `example.pls` 파일은 W3C PLS 호환 어휘를 지정합니다.  

```
aws polly put-lexicon \
    --name w3c \
    --content file://example.pls
```
`example.pls`의 콘텐츠  

```
{
    <?xml version="1.0" encoding="UTF-8"?>
    <lexicon version="1.0"
        xmlns="http://www.w3.org/2005/01/pronunciation-lexicon"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://www.w3.org/2005/01/pronunciation-lexicon
            http://www.w3.org/TR/2007/CR-pronunciation-lexicon-20071212/pls.xsd"
        alphabet="ipa"
        xml:lang="en-US">
        <lexeme>
            <grapheme>W3C</grapheme>
            <alias>World Wide Web Consortium</alias>
        </lexeme>
    </lexicon>
}
```
이 명령은 출력을 생성하지 않습니다.  
자세한 내용은 *Amazon Polly 개발자 안내서*의 [PutLexicon 작업 사용](https://docs.aws.amazon.com/polly/latest/dg/gs-put-lexicon.html)을 참조하세요.  
+  API 세부 정보는 *AWS CLI 명령 참조*의 [PutLexicon](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/polly/put-lexicon.html)을 참조하세요.

### `start-speech-synthesis-task`
<a name="polly_StartSpeechSynthesisTask_cli_topic"></a>

다음 코드 예시에서는 `start-speech-synthesis-task`의 사용 방법을 보여줍니다.

**AWS CLI**  
**텍스트 합성**  
다음 `start-speech-synthesis-task` 예시에서는 `text_file.txt`의 텍스트를 합성하고 결과 MP3 파일을 지정된 버킷에 저장합니다.  

```
aws polly start-speech-synthesis-task \
    --output-format mp3 \
    --output-s3-bucket-name amzn-s3-demo-bucket \
    --text  file://text_file.txt \
    --voice-id Joanna
```
출력:  

```
{
    "SynthesisTask": {
        "TaskId": "70b61c0f-57ce-4715-a247-cae8729dcce9",
        "TaskStatus": "scheduled",
        "OutputUri": "https://s3.us-east-2.amazonaws.com/amzn-s3-demo-bucket/70b61c0f-57ce-4715-a247-cae8729dcce9.mp3",
        "CreationTime": 1603911042.689,
        "RequestCharacters": 1311,
        "OutputFormat": "mp3",
        "TextType": "text",
        "VoiceId": "Joanna"
    }
}
```
자세한 내용은 *Amazon Polly 개발자 안내서*의 [긴 오디오 파일 생성](https://docs.aws.amazon.com/polly/latest/dg/longer-cli.html)을 참조하세요.  
+  API 세부 정보는 *AWS CLI 명령 참조*의 [StartSpeechSynthesisTask](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/polly/start-speech-synthesis-task.html)를 참조하세요.