Skip to content

Instantly share code, notes, and snippets.

@costa86
Last active June 17, 2021 11:51
Show Gist options
  • Save costa86/1d3ae06510c4f97d44056e323f4d424d to your computer and use it in GitHub Desktop.
Save costa86/1d3ae06510c4f97d44056e323f4d424d to your computer and use it in GitHub Desktop.
Plays audio given sys arguments
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