Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
This can be used to output a mp3 file to play, which outputs the catfacts as a .mp3 file then deletes it.
#/bin/bash
# This application requries AWS-CLI enabled and configured including your Location, and sox to allow the play command. (This could be substitued with another application if you wish to keep this as minimal as possible)
# We have selected "Justin" for the voice, but you can use any of the selection by AWS Polly, which are as follows; "Ivy","Joanna","Joey","Justin","Kendra","Kimberly","Matthew","Salli","Russell","Nicole","Amy","Brian","Emma","Geraint".
voiceid=Justin
# This variable is used to obtain the catfacts in a .json format, which then we pipe into jq, and finally into tr to clean the output up.
tts=$(curl -X GET --header 'Accept: application/json' 'https://catfact.ninja/fact' | jq '.fact' | tr -d '"')
aws polly synthesize-speech \
--text-type ssml \
--text '<speak>'"$tts"'</speak>' \
--output-format mp3 \
--voice-id $voiceid \
speech.mp3
play speech.mp3
rm speech.mp3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.