---
tags: AWS Alexa Lab
---
# AWS Alexa Lab Tutorial
Created by Lawrence Chen
Pre-warm video
---
**Built up your first Alexa service video!**
<iframe width="560" height="315" src="https://www.youtube.com/embed/0CM8BH11Il4" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
相關的代碼都可以在我的Github上面找到
https://github.com/lawrencechen0921/alexademolab
**跟著以下步驟去執行**:
首先先到**Amazon Polly**去將你所需要的服務轉換成語音的方式傳送~
**What is Amazon Polly?**
Amazon Polly 是將文字轉換成逼真說話方式的服務,能夠讓您建立會說話的應用程式和打造全新的啟用語音產品類別。Polly 的文字轉換語音 (TTS) 服務運用先進深度學習技術,合成自然的真人發音。它提供多種語言的數十種逼真語音,您可以建立多國使用並啟用語音功能的應用程式。
除了標準 TTS 語音之外,Amazon Polly 還提供神經文字轉換語音 (NTTS) 語音,透過全新的機器學習方法進一步改善語音品質。Polly 的神經文字轉換語音技術還支援兩種說話風格:可讓您更好地將演講者的演講風格與應用程式匹配:針對新旁白使用案例訂製的新聞播報員閱讀風格和適用於雙向通訊 (例如電話語音應用程式) 的交談說話風格。
最後,Amazon Polly Brand Voice 可針對您的組織建立自訂語音。這是一種自訂參與,您將與 Amazon Polly 團隊共同建立您組織專用的 NTTS 語音。在這裡進一步了解。
---
**Intro Video**
<iframe width="560" height="315" src="https://www.youtube.com/embed/jXPN12ReUJg" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
---
**Step 1**
---
Paste your File or anything you want to translate speech into voice
```
Like in the video, we paste "What is EC2?"
Amazon Elastic Compute Cloud (Amazon EC2) is a web service that provides secure, resizable compute capacity in the cloud. It is designed to make web-scale cloud computing easier for developers. Amazon EC2’s simple web service interface allows you to obtain and configure capacity with minimal friction. It provides you with complete control of your computing resources and lets you run on Amazon’s proven computing environment.
Amazon EC2 offers the broadest and deepest compute platform with choice of processor, storage, networking, operating system, and purchase model. We offer the fastest processors in the cloud and we are the only cloud with 400 Gbps ethernet networking. We have the most powerful GPU instances for machine learning training and graphics workloads, as well as the lowest cost-per-inference instances in the cloud. More SAP, HPC, Machine Learning, and Windows workloads run on AWS than any other cloud. Click here to learn What's New with Amazon EC2.
```
---
Step 2
---
Create S3 bucket
Then click **Permissions** and modify your bucket policy
JSON format
```
{
"Version" : "2012-10-17",
"Statement": [
{
"Sid": "PublicReadGetObject",
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::yourbucketname/*"
}
]
}
```
然後將你的Polly 點擊下方的**Synthesize to S3**(請確保到你剛create好的S3)
---
Step3
---
Go to Alexa Developer Console to create your account!
https://developer.amazon.com/en-US/alexa
接著要想用什麼服務去打Alexa的服務,那就是Lambda囉!
**請選擇範例程式!**

整個服務是走**serverless**的架構,並且是用**cloudformation**去開啟整個服務,需要一些時間才可以完成!
**並且在開啟的過程中到S3確認一下你剛剛的Polly mp3檔案有沒有存在裡面!**
並且打開lambda去修改**第211行**的代碼,改成你需要輸出的格式!
---
Step4
---
進入到**Alexa Developer console**之後請點選**create skills**
選擇**custom**的服務,並且選擇你所要的語言開發

選擇好之後就可以直接建模了!

並且點選**create skills**,跳轉到下一個介面後,再選擇**Fact skill**就大工告成,可以去訓練**Alexa**的語意分析啦!
(沒想到過了五個月就多了好多服務呢!)

**成功的話你會來到這個介面!**

進入到這個介面後,你先去改寫**trigger**整個服務的**lambda endpoint**並且,給予正確的**ARN**位置!

先跳回去**AWS Console**將你剛剛開啟的**lambda**資源貼到這個**ARN console**裡面!
(⚠️ **AWS console**與**Alexa**是有服務上結合的,所以你的地區還是必須配置一樣!)

貼上去之後把你的endpoint save起來!

接著,為了讓Alexa聽懂我們在問什麼,我們就先去旁邊的欄位Interaction Model先去訓練對於使用者語意的了解!

Create 一個新的Intent,之後輸入你要讓Alexa了解的語句輸入是什麼!
(多訓練一點會好一些)

好了之後,把model save起來,並且開始Build model確保他已經可以運作!

先注意一些小細節,你在create理解時,有個invocation(調用的介面必須命名清楚!)
(且必須是兩個字詞的組合!)

好了之後,回到介面去Test你的intent,若是有回傳正確的結果,代表你成功了!
到Test的介面做測試!

若有回傳你想要的結果表示成功!

接著我們要把剛剛Polly存在S3的語音資料測試出來,
並且把你的Src格式寫好如下圖這樣!才有辦法成功叫出服務!

你在問一次Alexa剛剛的東西,就會跑出EC2的語音介紹了!
若有任何問題請洽
個人相關連結(歡迎加好友)
---

Youtube: https://www.youtube.com/c/LCAWS/videos
Github: lawrencechen0921
Facebook: Lawrence Chen
Instagram: klunreal4show