Skip to content

Commit

Permalink
wed
Browse files Browse the repository at this point in the history
  • Loading branch information
quantum-quirks committed Oct 27, 2021
1 parent dd261a7 commit be150bb
Show file tree
Hide file tree
Showing 11 changed files with 116 additions and 219 deletions.
10 changes: 5 additions & 5 deletions docs/cli.rst
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
Command-line (:mod:`gtts-cli`)
Command-line (:mod:`t2s-cli`)
==============================

After installing the package, the ``gtts-cli`` tool becomes available::
After installing the package, the ``t2s-cli`` tool becomes available::

$ gtts-cli

.. click:: gtts.cli:tts_cli
:prog: gtts-cli
.. click:: t2s.cli:tts_cli
:prog: t2s-cli
:show-nested:

Examples
--------

List available languages::

$ gtts-cli --all
$ t2s-cli --all

Read 'hello' to ``hello.mp3``::

Expand Down
Binary file removed scripts/.gen_langs.py.swp
Binary file not shown.
150 changes: 64 additions & 86 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,100 +1,78 @@
[metadata]
name = t2s
version = attr: t2s.__version__
url = https://quo.rtfd.io
project_urls =
Donate = https://tinyurl.com/ygaj5fwj
Documentation = https://quo.rtfd.io
Changes = https://quo.readthedocs.io/en/latest/changes.html
Source Code = https://github.com/secretum-inc/quo
Issue Tracker = https://github.com/secretum-inc/quo/issues/
Twitter = https://twitter.com/secretum_inc
Chat = https://gitter.im/secretum-inc
license = MIT
license_files = LICENSE
description = t2s(Text-to-Speech), a Python library and CLI tool to interface with Google Translate text-to-speech API
author = Gerrishon Sirere
author_email = [email protected]
maintainer = Secretum Inc.
maintainer_email = [email protected]
description = Python based toolkit for writing Command-Line Interface applications
author_email = [email protected]
url = https://github.com/secretum-inc/t2s
license = MIT
keywords =
t2s
text to speech
Google Translate
T2S
classifiers =
Environment :: Console
Intended Audience :: Developers
License :: OSI Approved :: MIT License
Operating System :: MacOS
Operating System :: Unix
Operating System :: POSIX
Operating System :: POSIX :: Linux
Operating System :: Microsoft :: Windows
Programming Language :: Python :: 2.7
Programming Language :: Python :: 3.6
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Topic :: Software Development :: Libraries
Topic :: Multimedia :: Sound/Audio :: Speech
license_file = LICENSE
long_description = file: README.md
long_description_content_type = text/markdown
classifiers =
Development Status :: 5 - Production/Stable
Intended Audience :: Developers
License :: OSI Approved :: MIT License
Operating System :: OS Independent
Programming Language :: Python

[options]
python_requires = >= 3.6
include_package_data = True
packages = find:
package_dir = = src
include_package_data = true
python_requires = >= 3.6.1
# Dependencies are in setup.py for GitHub's dependency graph.
install_requires =
six
quo
requests

[options.packages.find]
where = src
[options.extras_require]
tests =
pytest == 4.6.11
pytest-cov
flake8
testfixtures
mock
six
docs =
sphinx
sphinx-autobuild
sphinx_rtd_theme
sphinx-click
towncrier

[tool:pytest]
testpaths = tests
filterwarnings =
error

[coverage:run]
branch = true
source =
quo
tests

[coverage:paths]
source =
quo
*/site-packages
[options.entry_points]
console_scripts =
t2s-cli = t2s.cli:t2s_cli

[flake8]
# B = bugbear
# E = pycodestyle errors
# F = flake8 pyflakes
# W = pycodestyle warnings
# B9 = bugbear opinions,
# ISC = implicit str concat
select = B, E, F, W, B9, ISC
ignore =
# slice notation whitespace, invalid
E203
# line length, handled by bugbear B950
E501
# bare except, handled by bugbear B001
E722
# bin op line break, invalid
W503
# up to 88 allowed by bugbear B950
max-line-length = 80
per-file-ignores =
# __init__ module exports names
src/quo/__init__.py: F401
max-line-length = 132
exclude = .git,__pycache__,.eggs/,doc/,docs/,build/,dist/,archive/
ignore = W605, W503, W504

[mypy]
files = src/quo
python_version = 3.6.1
disallow_subclassing_any = True
disallow_untyped_calls = True
disallow_untyped_defs = True
disallow_incomplete_defs = True
check_untyped_defs = True
no_implicit_optional = True
local_partial_types = True
no_implicit_reexport = True
strict_equality = True
warn_redundant_casts = True
warn_unused_configs = True
warn_unused_ignores = True
warn_return_any = True
warn_unreachable = True

[mypy-colorama.*]
ignore_missing_imports = True
[coverage:run]
cover_pylib = false
omit =
*/site-packages/*
t2s/tests/*
t2s/tokenizer/tests/*

[mypy-importlib_metadata.*]
ignore_missing_imports = True
[coverage:report]
exclude_lines =
pragma: no cover
def __repr__
log.debug
log.warning
Binary file removed src/t2s/.__init__.py.swp
Binary file not shown.
Binary file removed src/t2s/.tts.py.swp
Binary file not shown.
2 changes: 1 addition & 1 deletion src/t2s/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@

__all__ = ['T2S', 'gTTSError']

__version__ = "2021.1"
__version__ = "2021.2"
72 changes: 18 additions & 54 deletions src/t2s/cli.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# -*- coding: utf-8 -*-
from gtts import gTTS, gTTSError, __version__
from t2s import T2S, gTTSError, __version__
from t2s.lang import tts_langs
from quo import app, command, arg, File
from quo import app, command, arg, autoversion
from quo.type import File
from quo.errors import BadParameter, UsageError, Outlier
import logging
import logging.config
Expand Down Expand Up @@ -112,57 +113,20 @@ def set_debug(clime, param, debug):
@command(context_settings=CONTEXT_SETTINGS)
@arg('text', metavar='<text>', required=False, callback=validate_text)
@app('-f', '--file', metavar='<file>', type= File(encoding=sys_encoding()), help="Read from <file> instead of <text>.")
@app(
'-o',
'--output',
metavar='<file>',
type= File(mode='wb'),
help="Write to <file> instead of stdout.")
@app(
'-s',
'--slow',
default=False,
is_flag=True,
help="Read more slowly.")
@app(
'-l',
'--lang',
metavar='<lang>',
default='en',
show_default=True,
callback=validate_lang,
help="IETF language tag. Language to speak in. List documented tags with --all.")
@app(
'-t',
'--tld',
metavar='<tld>',
default='com',
show_default=True,
is_eager=True, # Prioritize <tld> to ensure it gets set before <lang>
help="Top-level domain for the Google host, i.e https://translate.google.<tld>")
@app(
'--nocheck',
default=False,
is_flag=True,
is_eager=True, # Prioritize <nocheck> to ensure it gets set before <lang>
help="Disable strict IETF language tag checking. Allow undocumented tags.")
@app(
'--all',
default=False,
is_flag=True,
is_eager=True,
expose_value=False,
callback=print_languages,
help="Print all documented available IETF language tags and exit.")
@click.option(
'--debug',
default=False,
is_flag=True,
is_eager=True, # Prioritize <debug> to see debug logs of callbacks
expose_value=False,
callback=set_debug,
help="Show debug information.")
@autoversion(version=__version__)
@app('-o', '--output', metavar='<file>', type= File(mode='wb'), help="Write to <file> instead of stdout.")
@app('-s', '--slow', default=False, flag=True, help="Read more slowly.")
@app('-l', '--lang', metavar='<lang>', default='en', show_default=True, callback=validate_lang, help="IETF language tag. Language to speak in. List documented tags with --all.")

# Prioritize <tld> to ensure it gets set before <lang>
@app('-t', '--tld', metavar='<tld>', default='com', show_default=True, eager=True, help="Top-level domain for the Google host, i.e https://translate.google.<tld>")

# Prioritize <nocheck> to ensure it gets set before <lang>
@app('--nocheck', default=False, flag=True, eager=True, help="Disable strict IETF language tag checking. Allow undocumented tags.")
@app('--all', default=False, flag=True, eager=True, expose_value=False, callback=print_languages, help="Print all documented available IETF language tags and exit.")

# Pruoritize <debug> to see debug logs of callbacks
@app('--debug', default=False, flag=True, eager=True, expose_value=False, callback=set_debug, help="Show debug information.")
#@autoversion(version=__version__)
def tts_cli(text, file, output, slow, tld, lang, nocheck):
""" Read <text> to mp3 format using Google Translate's Text-to-Speech API
(set <text> or --file <file> to - for standard input)
Expand All @@ -189,7 +153,7 @@ def tts_cli(text, file, output, slow, tld, lang, nocheck):

# TTS
try:
tts = gTTS(
tts = T2S(
text=text,
lang=lang,
slow=slow,
Expand Down
11 changes: 8 additions & 3 deletions src/t2s/lang.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
# -*- coding: utf-8 -*-
from t2s.langs import _main_langs
from t2s.languages import _main_langs
from warnings import warn
import logging
from quo import command, app

__all__ = ['tts_langs']

# Logger
log = logging.getLogger(__name__)
log.addHandler(logging.NullHandler())


@command()
@app("--tts_langs")
def tts_langs():
"""Languages Google Text-to-Speech supports.
Expand All @@ -33,7 +35,8 @@ def tts_langs():
log.debug("langs: {}".format(langs))
return langs


@command()
@app("--_extra_langs")
def _extra_langs():
"""Define extra languages.
Expand All @@ -51,6 +54,8 @@ def _extra_langs():
'zh': 'Chinese (Mandarin)'
}

@command()
@app("--_fallback_deprecated_lang")

def _fallback_deprecated_lang(lang):
"""Languages Google Text-to-Speech used to support.
Expand Down
66 changes: 0 additions & 66 deletions src/t2s/langs.py

This file was deleted.

Loading

0 comments on commit be150bb

Please sign in to comment.