-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
play_medium_post.py
executable file
·54 lines (48 loc) · 1.49 KB
/
play_medium_post.py
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
#!/usr/bin/env python3
"""# -*- coding: utf-8 -*-"""
import argparse
import argcomplete
from medium_speech import MediumToSpeech
def main():
parser = argparse.ArgumentParser(description="")
parser.add_argument(
"--play",
"-p",
dest="play_it",
action="store_true",
help="Play generated MP3 files.",
)
parser.add_argument(
"--cleanup",
"-c",
dest="cleanup",
action="store_true",
help="Cleanup generated MP3 files.",
)
parser.add_argument(
"--speed",
"-s",
dest="n_speed",
default=0,
help="Play every n'th frame only ie Play speed.",
)
parser.add_argument(
"--loglevel",
dest="log_level",
default="INFO",
help="log level to use, default [INFO], options [INFO, DEBUG, ERROR]",
)
parser.add_argument("--url-post", "-u", dest="medium_url", help="Medium post URL.")
parser.add_argument("--file", dest="markdown_file", help="Specify a Markdown file.")
argcomplete.autocomplete(parser)
args = vars(parser.parse_args())
medium_to_speech = MediumToSpeech(
medium_url=args.get("medium_url"),
filename=args.get("markdown_file"),
log_level=args.get("log_level", "INFO"),
)
medium_to_speech.text_to_speech(cleanup=args.get("cleanup"))
if args.get("play_it"):
medium_to_speech.play_it(speed=args.get("n_speed"), cleanup=args.get("cleanup"))
if __name__ == "__main__":
main()