2022-10-01 09:41:16 +00:00
from gtts import gTTS
2022-10-05 07:21:30 +00:00
from playsound import playsound
2022-10-01 09:41:16 +00:00
import os
2022-10-05 07:21:30 +00:00
mytext = input ( " Enter text: " )
2022-10-01 09:41:16 +00:00
2022-10-05 07:21:30 +00:00
print ( " MENU \n 1. English (Australia) \n 2. English (United Kingdom) \n 3. English (United States) \n 4. English (Canada) \n 5. English (India) \n 6. English (Ireland) \n 7. English (South Africa) \n 8. French (Canada) \n 9. French (France) \n 10. Mandarin (China Mainland) \n 11. Mandarin (Taiwan) \n 12. Portuguese (Brazil) \n 13. Portuguese (Portugal) \n 14. Spanish (Mexico) \n 15. Spanish (Spain) \n 16. Spanish (United States) " )
option = int ( input ( " Select option: " ) )
if option == 1 :
language = ' en '
tld1 = ' com.au '
if option == 2 :
language = ' en '
tld1 = ' co.uk '
if option == 3 :
language = ' en '
tld1 = ' com '
if option == 4 :
language = ' en '
tld1 = ' ca '
if option == 5 :
language = ' en '
tld1 = ' co.in '
if option == 6 :
language = ' en '
tld1 = ' ie '
if option == 7 :
language = ' en '
tld1 = ' co.za '
if option == 8 :
language = ' fr '
tld1 = ' ca '
if option == 9 :
language = ' fr '
tld1 = ' fr '
if option == 10 :
language = ' zh-CN '
tld1 = ' com '
if option == 11 :
language = ' zh-TW '
tld1 = ' com '
if option == 12 :
language = ' pt '
tld1 = ' com.br '
if option == 13 :
language = ' pt '
tld1 = ' pt '
if option == 14 :
language = ' es '
tld1 = ' com.mx '
if option == 15 :
language = ' es '
tld1 = ' es '
if option == 16 :
language = ' es '
tld1 = ' com '
2022-10-01 09:41:16 +00:00
2022-10-05 07:21:30 +00:00
tts = gTTS ( text = mytext , tld = tld1 , lang = language , slow = False )
audio_file = os . path . join ( os . path . dirname ( os . path . abspath ( __file__ ) ) , " tts.mp3 " )
tts . save ( audio_file )
playsound ( audio_file )