Last active
June 17, 2021 11:51
-
-
Save costa86/1d3ae06510c4f97d44056e323f4d424d to your computer and use it in GitHub Desktop.
Plays audio given sys arguments
This file contains hidden or 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
from gtts import gTTS | |
import os | |
from playsound import playsound | |
import sys | |
text = "Flow has been completed" | |
lang = "en" | |
tld = "ca" | |
audio_filename = r"C:\Users\lcosta\PowerAutomate\sample.mp3" | |
def speak(text,lang="en",tld="ca"): | |
tts = gTTS(text,lang=lang,tld=tld) | |
tts.save(audio_filename) | |
playsound(audio_filename) | |
os.remove(audio_filename) | |
try: | |
text = sys.argv[1] | |
lang = "pt" if sys.argv[2] == "pt" else "en" | |
tld = "pt" if lang == "pt" else "ca" | |
except: | |
pass | |
speak(text,lang,tld) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment