1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144
|
From: Ethan Ward <ethan.ward@mycroft.ai>
Date: Fri, 4 Aug 2017 14:05:48 -0500
Subject: Change binary to be pure python
Remove .py file from scripts
---
bin/gtts-cli | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++----
bin/gtts-cli.py | 52 ----------------------------------------------------
setup.py | 2 +-
3 files changed, 53 insertions(+), 57 deletions(-)
delete mode 100755 bin/gtts-cli.py
diff --git a/bin/gtts-cli b/bin/gtts-cli
index dc25393..f3657d0 100755
--- a/bin/gtts-cli
+++ b/bin/gtts-cli
@@ -1,4 +1,52 @@
-#!/bin/bash
-DIR="$( cd "$( dirname "$0" )" && pwd )"
-PYTHON=$(which python)
-exec $PYTHON $DIR/gtts-cli.py "$@"
+#! /usr/bin/python
+
+from __future__ import print_function
+from gtts import gTTS
+from gtts import __version__
+import sys
+import argparse
+import os
+import codecs
+
+def languages():
+ """Sorted pretty printed string of supported languages"""
+ return ", ".join(sorted("{}: '{}'".format(gTTS.LANGUAGES[k], k) for k in gTTS.LANGUAGES))
+
+# Args
+desc = "Creates an mp3 file from spoken text via the Google Text-to-Speech API ({v})".format(v=__version__)
+parser = argparse.ArgumentParser(description=desc, formatter_class=argparse.RawTextHelpFormatter)
+
+text_group = parser.add_mutually_exclusive_group(required=True)
+text_group.add_argument('text', nargs='?', help="text to speak")
+text_group.add_argument('-f', '--file', help="file to speak")
+
+parser.add_argument("-o", '--destination', help="destination mp3 file", action='store')
+parser.add_argument('-l', '--lang', default='en', help="ISO 639-1/IETF language tag to speak in:\n" + languages())
+parser.add_argument('--slow', action="store_true", help="slower read speed")
+parser.add_argument('--debug', action="store_true")
+
+args = parser.parse_args()
+
+try:
+ if args.text:
+ if args.text == "-":
+ text = sys.stdin.read()
+ else:
+ text = args.text
+ else:
+ with codecs.open(args.file, "r", "utf-8") as f:
+ text = f.read()
+
+ # TTSTF (Text to Speech to File)
+ tts = gTTS(text=text, lang=args.lang, slow=args.slow, debug=args.debug)
+
+ if args.destination:
+ tts.save(args.destination)
+ else:
+ tts.write_to_fp(os.fdopen(sys.stdout.fileno(), "wb"))
+except Exception as e:
+ if args.destination:
+ print(str(e))
+ else:
+ print("ERROR: ", e, file=sys.stderr)
+
diff --git a/bin/gtts-cli.py b/bin/gtts-cli.py
deleted file mode 100755
index f3657d0..0000000
--- a/bin/gtts-cli.py
+++ /dev/null
@@ -1,52 +0,0 @@
-#! /usr/bin/python
-
-from __future__ import print_function
-from gtts import gTTS
-from gtts import __version__
-import sys
-import argparse
-import os
-import codecs
-
-def languages():
- """Sorted pretty printed string of supported languages"""
- return ", ".join(sorted("{}: '{}'".format(gTTS.LANGUAGES[k], k) for k in gTTS.LANGUAGES))
-
-# Args
-desc = "Creates an mp3 file from spoken text via the Google Text-to-Speech API ({v})".format(v=__version__)
-parser = argparse.ArgumentParser(description=desc, formatter_class=argparse.RawTextHelpFormatter)
-
-text_group = parser.add_mutually_exclusive_group(required=True)
-text_group.add_argument('text', nargs='?', help="text to speak")
-text_group.add_argument('-f', '--file', help="file to speak")
-
-parser.add_argument("-o", '--destination', help="destination mp3 file", action='store')
-parser.add_argument('-l', '--lang', default='en', help="ISO 639-1/IETF language tag to speak in:\n" + languages())
-parser.add_argument('--slow', action="store_true", help="slower read speed")
-parser.add_argument('--debug', action="store_true")
-
-args = parser.parse_args()
-
-try:
- if args.text:
- if args.text == "-":
- text = sys.stdin.read()
- else:
- text = args.text
- else:
- with codecs.open(args.file, "r", "utf-8") as f:
- text = f.read()
-
- # TTSTF (Text to Speech to File)
- tts = gTTS(text=text, lang=args.lang, slow=args.slow, debug=args.debug)
-
- if args.destination:
- tts.save(args.destination)
- else:
- tts.write_to_fp(os.fdopen(sys.stdout.fileno(), "wb"))
-except Exception as e:
- if args.destination:
- print(str(e))
- else:
- print("ERROR: ", e, file=sys.stderr)
-
diff --git a/setup.py b/setup.py
index 533fdbb..e85fac7 100644
--- a/setup.py
+++ b/setup.py
@@ -12,7 +12,7 @@ setup(
author_email='pndurette@gmail.com',
url='https://github.com/pndurette/gTTS',
packages=['gtts'],
- scripts=['bin/gtts-cli', 'bin/gtts-cli.py'],
+ scripts=['bin/gtts-cli'],
license='MIT',
description='Create an mp3 file from spoken text via the Google TTS (Text-to-Speech) API',
long_description=open('README.md').read(),
|