Skip to content

ThisIsDjonathan/daily-stoic-alexa-skill

Repository files navigation

Welcome to daily-stoic-alexa-skill 👋🏛️📜

This project aims to provide daily Stoic quotes for Alexa users and show how I built my first Alexa Skill 😄💻

You can download this skill on the Skill Store in your Alexa app.

  • Download the portuguese version here!

How I built this

The premise for this Alexa Skill was to have a single Stoic Quote for each day of the year.
So the first thing I did was create a .json file with 366 entries.

📦 daily-stoic-alexa-skill
┣ 📂 assets
┃ ┗ 📜 portuguese.json
┃ ┗ 📜 english.json

The Speech to Text 🗣️👂

On the first try, I used a text feed but the current text-to-speech used by Alexa is very bad, so I used the ElevenLabs library + API to convert the text-to-speech.

This is done by the code in the text-to-speech.py file. More details on how to run this are in the Contributing 🤝 section.


The result was 366 .mp3 files. 📦 daily-stoic-alexa-skill
┣ 📂 assets
┃ ┗ 📂 audios
┃ ┗ 📂 portuguese
┃     ┗ 🎧 1.mp3
┃     ┗ 🎧 2.mp3
┃ ┗ 📂 english
┃     ┗ 🎧 366.mp3

Note: After generating all audios I noticed some were too quiet. To not generate all again I increased the volume for the portuguese audio files. This is done in the make-it-louder.py.

The Alexa Skill 🤖

The Alexa Skill is a Flash Briefing skill created in the Alexa Developer Console that will consume our JSON feed API hosted on AWS.
These are the docs I used for reference:

Amazon Lambda and S3 🪣λ

To feed the Alexa Skill I created a Lambda function hosted on AWS. This is a simple python script that will fetch the mp3 file for the current date. The mp3 files are hosted in an S3 bucket and the Lambda Function has an API Gateway so the Alexa Skill can consume it.

The script details can be found in the TheDailyStoic-LambdaFunction.py file 🐍

Contributing 🤝

You can contribute by adding support for more languages! 🌎

Translating the quotes

To do so, first, you need to translate the english.json to your language and then create a new YOUR_LANGUAGE.json file and put it in the assets/ directory.


📦 daily-stoic-alexa-skill
┣ 📂 assets
┃ ┗ 📜 YOUR_LANGUAGE.json

Getting an ElevenLabs API Key

You can do the text-to-speech using another tool, but if you want to use the same I used just go to the ElevenLabs website and create a free account. You will get an API Key by clicking on your name in the bottom right corner, then click on Profile and copy your API Key.

Running the code

Then let's run the code in your environment! First, install the Python dependencies python-dotenv and elevenlabs:

pip install -r requirements.txt

Then update the .env file by adding your API Key. 📦 daily-stoic-alexa-skill ┣ 📜 .env

API_KEY='your API key goes here'

Run python text-to-speech.py to convert the text to speech.

Push a PR

Finally, push a PR to this repo. I will merge it, add the new audio files to the S3 bucket, and make the Alexa Skill available in your country. Please specify the language you are adding, the country where you are from, and your name to the PR description!

Author

👤 Djonathan Krause

Show your support

Please ⭐️ this repository if this project helped you!

Buy Me A Coffee

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages