pndurette / gTTS

Python library and CLI tool to interface with Google Translate's text-to-speech API
http://gtts.readthedocs.org/
MIT License
2.26k stars 361 forks source link

gtts_cli breaks when text starts with '-' #419

Closed arainflake closed 9 months ago

arainflake commented 1 year ago

Prerequisites

Current Behaviour (steps to reproduce)

> gtts-cli "-face" -o ham.wav

Usage: gtts-cli [OPTIONS] <text>
Try 'gtts-cli -h' for help.

Error: Invalid value for '-f' / '--file': 'ace': No such file or directory

image image

Expected Behaviour

It should be expected to interpret the text as a solid block of text and not brake it into multiple arguments.

gtts-cli "-face" -o test.wav

would expect the above to output an audio file saying "minus face" or "dash face"

Context

trying to use the g_tts library through the command line helper (gtts-cli), and noticed that the command line parser breaks when the inline text starts with a '-' such as "-hello" or "-face" it seems to interpret it as "-f" and "ace" as seperate arguments. if using "-hello" it sees "-h" as a proper argument, and then says "e" is not a valid option.

Environment

gtts version: 2.3.2 os is manjaro with the i3 window manager, fish and bash shell tested

pndurette commented 11 months ago

Sorry for the huge delay on this! This is indeed quite a bug, it takes -face as -f ace.

pndurette commented 9 months ago

First of all, thanks for all the details. So, it's been taking a while because I've been dabating this. I've also been searching this, and I don't think I can easily fix this.

There's been quite a lot of debate about fixing or not that issue when it happened with Python's argparse more than 10 years ago now, it resulted in a 'wont fix'

My suggestions of workarounds:

arainflake commented 8 months ago

much appreciated for the advice. Ill go with those options.