Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1import argparse
4def setup_logging() -> None:
5 """Initialises logging for Ask Bob."""
6 import logging
7 import coloredlogs
8 import os
10 os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
12 logger = logging.getLogger()
13 if logger.hasHandlers():
14 logger.handlers.clear()
16 coloredlogs.install(
17 level=logging.INFO,
18 use_chroot=False,
19 fmt="%(asctime)s %(name)s[%(process)d] %(levelname)s %(message)s"
20 )
23def make_argument_parser() -> argparse.ArgumentParser:
24 """Initialises the CLI argument parser.
26 Returns:
27 argparse.ArgumentParser: the CLI argument parser
28 """
29 parser = argparse.ArgumentParser(
30 description="AskBob: a customisable voice assistant.")
32 parser.add_argument('-c', '--config', default="config.ini",
33 help="The configuration file.")
35 parser.add_argument('-w', '--savepath',
36 help="Save .wav files of utterences to a given directory.")
38 parser.add_argument('-f', '--file',
39 help="Read from a .wav file instead of the microphone.")
41 parser.add_argument('-d', '--device', type=int, default=None,
42 help="The device input index (int) as given by pyaudio.PyAudio.get_device_info_by_index(). Default: pyaudio.PyAudio.get_default_device().")
44 parser.add_argument('-r', '--rate', type=int, default=16000,
45 help=f"The input device sample rate (your device might require 44100Hz). Default: 16000.")
47 parser.add_argument('-s', '--serve', default=False, action='store_true',
48 help="Run Ask Bob as a server instead of interactively.")
50 parser.add_argument('-v', '--voice', default=False, action='store_true',
51 help="Enable speech transcription in server mode.")
53 parser.add_argument('--setup', const=".", nargs="?",
54 help="Setup Ask Bob from the configuration JSON file provided.")
56 return parser