-
-
Save davidabram/d590668728e8d2733b57d1b4bf1ad6dd to your computer and use it in GitHub Desktop.
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 | |
# | |
# Description: Text to speech using pico2wave | |
# | |
# sudo apt install libttspico-utils | |
# | |
# sudo apt install sox | |
# | |
# | |
# sudo mkdir -p /etc/apt/keyrings | |
# curl -fsSL https://repo.charm.sh/apt/gpg.key | sudo gpg --dearmor -o /etc/apt/keyrings/charm.gpg | |
# echo "deb [signed-by=/etc/apt/keyrings/charm.gpg] https://repo.charm.sh/apt/ * *" | sudo tee /etc/apt/sources.list.d/charm.list | |
# sudo apt update && sudo apt install glow | |
if [ -z "$1" ]; then | |
echo "Usage: $0 <text_or_file_path>" | |
exit 1 | |
fi | |
clear | |
# Determine if the argument is a file | |
if [ -f "$1" ]; then | |
content=$(cat "$1" | sed '/<!--/,/-->/d') | |
glow "$1" | |
else | |
content=$(echo "$1" | sed '/<!--/,/-->/d') | |
echo "$content" | |
fi | |
pico2wave -w=/tmp/test.wav "$content" | |
duration_seconds=$(soxi -D /tmp/test.wav) | |
duration_minutes=$(echo "$duration_seconds / 60" | bc -l) | |
printf "\n\nReading time of the WAV file is: %.2f minutes\n" "$duration_minutes" | |
aplay -q /tmp/test.wav | |
rm /tmp/test.wav |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment