[Python-modules-commits] [gtts] 02/05: Add patch for binaries

Ethan Ward ethanward-guest at moszumanska.debian.org
Fri Aug 4 21:21:00 UTC 2017


This is an automated email from the git hooks/post-receive script.

ethanward-guest pushed a commit to branch master
in repository gtts.

commit 93d9dfceb24c384a3a268f23908cd9e15fb500bd
Author: Ethan Ward <ethan.ward at mycroft.ai>
Date:   Fri Aug 4 14:07:28 2017 -0500

    Add patch for binaries
---
 .../0001-Change-binary-to-be-pure-python.patch     | 129 +++++++++++++++++++++
 debian/patches/series                              |   1 +
 2 files changed, 130 insertions(+)

diff --git a/debian/patches/0001-Change-binary-to-be-pure-python.patch b/debian/patches/0001-Change-binary-to-be-pure-python.patch
new file mode 100644
index 0000000..c222f1f
--- /dev/null
+++ b/debian/patches/0001-Change-binary-to-be-pure-python.patch
@@ -0,0 +1,129 @@
+From: Ethan Ward <ethan.ward at mycroft.ai>
+Date: Fri, 4 Aug 2017 14:05:48 -0500
+Subject: Change binary to be pure python
+
+---
+ bin/gtts-cli    | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++----
+ bin/gtts-cli.py | 52 ----------------------------------------------------
+ 2 files changed, 52 insertions(+), 56 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/debian/patches/series b/debian/patches/series
new file mode 100644
index 0000000..39e328e
--- /dev/null
+++ b/debian/patches/series
@@ -0,0 +1 @@
+0001-Change-binary-to-be-pure-python.patch

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/gtts.git



More information about the Python-modules-commits mailing list