Last active
March 5, 2023 23:54
Revisions
-
alecjacobson revised this gist
Mar 5, 2023 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,6 @@ # https://stackoverflow.com/a/51164950/148668 # # python3 -m pip install gtts playsound pyobjc from gtts import gTTS import sys from io import BytesIO -
alecjacobson revised this gist
Mar 2, 2023 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -26,5 +26,5 @@ else: filename = sys.argv[2] tts.save(filename) if args.output_file is None: playsound.playsound(filename) -
alecjacobson revised this gist
Mar 2, 2023 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -21,7 +21,7 @@ tts = gTTS(text=input_text, lang='en', slow=False) if args.output_file is None: filename = tempfile.NamedTemporaryFile().name else: filename = sys.argv[2] -
alecjacobson created this gist
Mar 1, 2023 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,30 @@ # https://stackoverflow.com/a/51164950/148668 from gtts import gTTS import sys from io import BytesIO import objc import playsound import tempfile import argparse import sys parser = argparse.ArgumentParser(description='`say` replacement using gtts') parser.add_argument('text', type=str, nargs='?', help="Text to be read (also accepted from stdin)" ) parser.add_argument('-o','--output-file', type=str, help='An optional output file argument') args = parser.parse_args() input_text = sys.stdin.read() if args.text == None else args.text tts = gTTS(text=input_text, lang='en', slow=False) if args.output_file == None: filename = tempfile.NamedTemporaryFile().name else: filename = sys.argv[2] tts.save(filename) if args.output_file == None: playsound.playsound(filename)