2019-04-16 15:13:03 +00:00
from hugvey . client import Hugvey
import logging
import logging . handlers
import coloredlogs
import argparse
from urllib . parse import urlparse
from hugvey . tools import Toolbox
if __name__ == ' __main__ ' :
argParser = argparse . ArgumentParser ( description = ' Start up a Hugvey pillow. Mic stream becomes available on TCP Socket, and starts listening + emitting events ' )
argParser . add_argument (
' --config ' ,
' -c ' ,
required = True ,
type = str ,
help = ' The yaml config file to load '
)
argParser . add_argument (
' --files ' ,
action = ' store_true ' ,
help = " Add/remove new & unused file "
)
2019-11-08 10:30:49 +00:00
argParser . add_argument (
' --story ' ,
default = None ,
help = " Find/restore issues with the story file " ,
metavar = " LANG_CODE "
)
2019-11-29 19:34:31 +00:00
argParser . add_argument (
' --csv ' ,
default = None ,
help = " Generate a csv " ,
metavar = " LANG_CODE "
)
argParser . add_argument (
' --import_csv ' ,
default = None ,
help = " Import a csv file " ,
metavar = ( " LANG_CODE " , " CVS_FILE " ) ,
nargs = 2
)
2020-02-23 18:11:34 +00:00
argParser . add_argument (
' --parse-cutelog ' ,
default = None ,
help = " Parse the speech of a cutelog logfile " ,
metavar = " CUTELOG STORED FILE " ,
)
argParser . add_argument (
' --verbose ' ,
' -v ' ,
action = ' count ' , default = 0
)
2019-04-16 15:13:03 +00:00
args = argParser . parse_args ( )
2020-02-23 18:11:34 +00:00
loglevel = logging . NOTSET if args . verbose > 1 else logging . DEBUG if args . verbose > 0 else logging . INFO
2019-04-16 15:13:03 +00:00
coloredlogs . install (
2020-02-23 18:11:34 +00:00
level = loglevel
2019-04-16 15:13:03 +00:00
)
logger = logging . getLogger ( " toolbox " )
# logger.setLevel(1) # to send all records to cutelog
tools = Toolbox ( args . config )
if args . files :
logger . info ( " Filenames " )
tools . clean_audio_files ( )
2019-11-08 10:30:49 +00:00
if args . story :
2019-11-29 19:34:31 +00:00
tools . fix_story_file ( args . story )
if args . csv :
tools . generate_story_csv ( args . csv )
if args . import_csv :
2020-02-23 18:11:34 +00:00
tools . import_story_csv ( * args . import_csv )
if args . parse_cutelog :
tools . parse_cutelog ( args . parse_cutelog )