This code is perfect and should work provided you have installed gtts
into your pip environment and mpg321
is on your path. I tested this code on Mac OS (where I did brew install mpg321
and on Ubuntu 18.04 (sudo apt install mpg321
). In both cases, I heard a voice saying "welcome to geeks for geeks".
If you want more help with this, you will have to provide more details about the context in which this code is being run. Here are some commands you should post the output of, to give more info people like me who want to help you. :)
python --version
pip freeze
uname -a
Also, have you tried playing a different mp3 file with mpg321? It might be that mpg321 is not working properly.