Hide keyboard shortcuts

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 

2 

3 

4def setup_logging() -> None: 

5 """Initialises logging for Ask Bob.""" 

6 import logging 

7 import coloredlogs 

8 import os 

9 

10 os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2' 

11 

12 logger = logging.getLogger() 

13 if logger.hasHandlers(): 

14 logger.handlers.clear() 

15 

16 coloredlogs.install( 

17 level=logging.INFO, 

18 use_chroot=False, 

19 fmt="%(asctime)s %(name)s[%(process)d] %(levelname)s %(message)s" 

20 ) 

21 

22 

23def make_argument_parser() -> argparse.ArgumentParser: 

24 """Initialises the CLI argument parser. 

25 

26 Returns: 

27 argparse.ArgumentParser: the CLI argument parser 

28 """ 

29 parser = argparse.ArgumentParser( 

30 description="AskBob: a customisable voice assistant.") 

31 

32 parser.add_argument('-c', '--config', default="config.ini", 

33 help="The configuration file.") 

34 

35 parser.add_argument('-w', '--savepath', 

36 help="Save .wav files of utterences to a given directory.") 

37 

38 parser.add_argument('-f', '--file', 

39 help="Read from a .wav file instead of the microphone.") 

40 

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().") 

43 

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.") 

46 

47 parser.add_argument('-s', '--serve', default=False, action='store_true', 

48 help="Run Ask Bob as a server instead of interactively.") 

49 

50 parser.add_argument('-v', '--voice', default=False, action='store_true', 

51 help="Enable speech transcription in server mode.") 

52 

53 parser.add_argument('--setup', const=".", nargs="?", 

54 help="Setup Ask Bob from the configuration JSON file provided.") 

55 

56 return parser