Created
April 23, 2018 06:53
-
-
Save evildaemond/d96d63be126a2d97572705c847eca0bf to your computer and use it in GitHub Desktop.
This can be used to output a mp3 file to play, which outputs the catfacts as a .mp3 file then deletes it.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#/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