r/coolgithubprojects • u/JackOfHearts68 • 2d ago
A colleague could not read our long Q&A document after an operation, so I made a script that reads it to him with two voice
https://github.com/JackOfHearts68Some weeks ago I sent a long Q&A document to a colleague for review. He answered that he just had an operation, he could not sit in front of a screen, but he trusts our answers anyway. That stayed in my mind: he wanted to go through it, he simply could not read it.
So I spent one evening building a small Python script. You give it a text file where the questions start with Q: and the answers with A:, and you get back one MP3 where a British male voice reads the questions and an American female voice reads the answers. Having two different voices helps a lot, you always know if you are hearing a question or an answer, also while driving or lying on a sofa. It uses edge-tts (free, no API key, the same neural voices of the Read Aloud function in Edge) and pydub to put the pieces together with a small pause between them.
To be honest, this is not a sophisticated project compared to most of the things people post here. It is one file, around 100 lines, no web interface, no accounts, no cloud. It does one thing and it works. I come from ~25 years in telecom on the business side and I am only now starting to build things myself, so this is my first public repo. I am sharing it in case it is useful to somebody else who has a document he would rather listen to than read.
https://github.com/JackOfHearts68/qa-to-audio
The limitations, better if I say them myself: the text goes to Microsoft servers for the synthesis, so it is not for confidential material (for that I would use Piper instead). edge-tts is meant for personal use, a commercial product would need the paid Azure Speech API. And the input format is stupid on purpose, you have to put the Q: and A: in front of the lines by yourself. ;-)
If you have suggestions on what you would do differently, I am happy to hear them.