With Microsoft Edge browser on Windows, you get text to speech functionality. However on Linux, the same browser has no such feature. In this article I will show you how you can convert long articles to audio file.
Step 1 : Install pipx
Related Documentaion : https://pypa.github.io/pipx/installation/
Its FOSS : https://itsfoss.com/install-pipx-ubuntu/
NixOS : (temporary) nix-shell -p pipx
Step 2 : Install edge-tts and trafilatura
pipx ensurepath
pipx install edge-tts
pipx install trafilatura
Step 3 : Usage
Notice : Kindly use bash or zsh, fish doesn’t support $() system.
Example:
edge-playback --voice en-GB-SoniaNeural --text "$(trafilatura -u "https://itsfoss.com/install-pipx-ubuntu/")"
For more options, read through the github page https://github.com/rany2/edge-tts
You can change voice, rate, pitch and volume !
Update !
sometimes this will not work if there are Double Quotations "
in the extracted content for that we will replace Double Quotations with nothing using sed :
edge-playback --text "$(trafilatura -u "https://article/link/here" | sed 's/"//g')"
we can also use a variable to store our links, for example $abc
:
abc=https://link/here
edge-playback --voice en-GB-SoniaNeural --text "$(trafilatura -u "$abc" | sed 's/"//g')"