Alexa MVP

This project contains a series of microservices, which when all are running - the main service (alexa.go) can be used. This main service takes in an audio file (.wav) of any question and return an audio file with the corrosponding answer.

Alpha Microservice

This microservice takes a JSON object that has a “text” property whose value is a question string, and returns a JSON object that has an “text” property whose value is an answer string.

Speech-to-Text Microservice

This microservice takes a JSON object that has a “speech” property whose value is a WAV sound encoded as a string using the Base64 scheme, and returns a JSON object that has a “text” property whose value is a text string.

Text-to-Speech Microservice

This microservice takes a JSON object that has a “text” property whose value is a text string, and returns a JSON object that has a “speech” property whose value is a WAV sound encoded as a string using the Base64 scheme.

Alexa Microservice

This microservice takes a JSON object that has a “speech” property whose value is a WAV sound encoded as a string using the Base64 scheme. This speech should be a question. The microservice returns a JSON object that has a “speech” property whose value is again a WAV sound encoded as a string using the Base64 scheme.

API Keys

Alpha API key

The Alpha microservice (alpha.go), uses the Short Answers API of the Wolfram Alpha computational knowledge engine. Signup is free, you will recieve an app id which you must place into the following file.

  /alpha.go
const{
    ...

    APPID = "Put your AppId here"
}

Speech-to-Text and Text-to-Speech API keys

The speech-to-text (stt.go) and text-to-speech (tts.go) microservices use the APIs from Microsoft Azure Cognitive Services. Free API keys for these services can be generated by following the free sign up here.

Where to put your key

The same key can be used for both services, but adjustments must be made to the following files:

  /tts.go
  /stt.go

Replace the quoted section with your API key in both files.

const{
    ...

    xxxKEY = "Put your api key here"
}

Running the Microservices

To run locally, each microservice needs to be run using localhost (3000, 3001, 3002, 3003). To activate the microservces, open up four seperate terminal windows and go to the file directory for each microservice and input the following command:

  go run microservice.go

For the alexa.go microservice to work, the other microservices (alpha.go, stt.go, tts.go) must be running.

To send requests to each microservice, edit the corrosponding shell scrips with your request. Note: all and then run the following commands:

Alpha Service:

  ./alphatest.sh

Speech-to-Text Service:

  ./stttest.sh

Text-to-Speech Service:

  ./ttstest.sh

Alexa Service:

  ./alexatest.sh

Lessons Learned

The purpose of this project was to get to grips with the basics of GoLang, while understanding and implimenting some basic microservices. This project has demonstrated the simplicity and power of Go, especially within http.

License

MIT