Skip to content

Commit

Permalink
Dockerize Amazon Transcribe tutorial
Browse files Browse the repository at this point in the history
Docker
  • Loading branch information
Mark Lewin authored Sep 23, 2019
2 parents 3a91b4f + 6fd131a commit c67a3fc
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 13 deletions.
13 changes: 13 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM node:12.8.1-alpine

EXPOSE 3000
WORKDIR /usr/src/

COPY ./package.json ./package-lock.json ./
RUN npm install

ENV PATH /usr/src/node_modules/.bin:$PATH

COPY . .

CMD ["npm", "start"]
29 changes: 19 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# Nexmo Voice API Call Transcription with Amazon Transcribe

This is example code for a [tutorial](https://developer.nexmo.com/use-cases/trancribe-amazon-api) that shows you how to transcribe a phone call automatically using the Amazon Transcribe API. You'll need two handsets with two different phone numbers to test this.

It uses the Nexmo Voice API to initiate and record the call. The call audio is created in your local `recordings` folder and uploaded to an S3 bucket.

Amazon Cloudwatch triggers a serverless Lambda function when the transcription job has completed. Transcripts are created in S3 and downloaded to your application's `transcripts` folder.

## Welcome to Nexmo

If you're new to Nexmo, you can [sign up for a Nexmo account](https://dashboard.nexmo.com/sign-up?utm_source=DEV_REL&utm_medium=github&utm_campaign=amazon-transcribe-call) and get some free credit to get you started.

## Setup

### Install the Nexmo CLI
Expand Down Expand Up @@ -105,6 +105,8 @@ serverless deploy

## Running the code

### Local Install

1. In the root directory of your application, execute:

```
Expand All @@ -117,21 +119,29 @@ node index.js

4. Watch the console as the transcription job is being processed. If everything works properly, you should receive a notification that your job is complete and you should find the call audio file in your `recordings` directory and the corresponding transcript (in JSON format) in `transcripts`. Note how the transcript is split into channels, one for each device you used. The application parses the completed transcription and displays the result for each channel in the console.

### Docker Compose

You can also run the code using Docker Compose using the following command.

```
docker-compose up
```

## Adding more callers

If you have more than two numbers, you can add more callers to the conversation. Simply create a `connect` action for each in the `/webhooks/answer` NCCO and increase the number of channels in the `record` action accordingly.

## Getting Help

We love to hear from you so if you have questions, comments or find a bug in the project, let us know! You can either:

* Open an issue on this repository
* Tweet at us! We're [@NexmoDev on Twitter](https://twitter.com/NexmoDev)
* Or [join the Nexmo Community Slack](https://developer.nexmo.com/community/slack)

## Further Reading

* Read the [tutorial](https://developer.nexmo.com/use-cases/trancribe-amazon-api) that accompanies this demo application to learn how it was put together.
* Read the [tutorial](https://developer.nexmo.com/use-cases/trancribe-amazon-api) that accompanies this demo application to learn how it was put together.
* Nexmo Voice API
* [Voice API call recording guide](/voice/voice-api/guides/recording)
* ["Record a call" code snippet](/voice/voice-api/code-snippets/record-a-call)
Expand All @@ -144,4 +154,3 @@ We love to hear from you so if you have questions, comments or find a bug in the
* [Amazon S3 documentation](https://docs.aws.amazon.com/s3/)
* [Amazon CloudWatch documentation](https://docs.aws.amazon.com/cloudwatch/)
* [Amazon Lambda](https://docs.aws.amazon.com/lambda/)

10 changes: 10 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: '3.7'
services:
aws-transcribe:
build: .
env_file: .env
ports:
- 3000:3000
volumes:
- ./:/usr/src
- ./node_modules:/usr/src/node_modules
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const nexmo = new Nexmo({
apiKey: "not_used", // Voice applications don't use API key or secret
apiSecret: "not_used",
applicationId: process.env.NEXMO_APPLICATION_ID,
privateKey: __dirname + "/" + process.env.NEXMO_PRIVATE_KEY_PATH
privateKey: __dirname + "/" + process.env.NEXMO_PRIVATE_KEY_FILE
})

AWS.config.update({
Expand Down Expand Up @@ -191,4 +191,4 @@ function downloadFile(key) {

}

app.listen(3000, () => console.log("Waiting for an inbound call..."))
app.listen(3000, () => console.log("Waiting for an inbound call..."))
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "Shows how to use the Amazon Transcribe API to transcribe a phone conversation recorded with the Nexmo Voice API.",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"start": "node index.js"
},
"author": "Mark Lewin",
"license": "ISC",
Expand Down

0 comments on commit c67a3fc

Please sign in to comment.