Skip to content

Commit

Permalink
Fixed unicode endoing issue.
Browse files Browse the repository at this point in the history
  • Loading branch information
XueWei committed Aug 21, 2017
1 parent 42ce1a7 commit 8c63295
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions bin/gtts-cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def languages():
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('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')
Expand All @@ -28,11 +28,12 @@ def languages():
args = parser.parse_args()

try:

if args.text:
if args.text == "-":
text = sys.stdin.read()
else:
text = args.text
text = args.text.decode('utf-8')
else:
with codecs.open(args.file, "r", "utf-8") as f:
text = f.read()
Expand All @@ -49,4 +50,3 @@ def languages():
print(str(e))
else:
print("ERROR: ", e, file=sys.stderr)

0 comments on commit 8c63295

Please sign in to comment.