1#!/usr/bin/env python 2 3import sys 4import argparse 5import whisper 6 7 8def main(): 9 """Set xFilesFactor for existing whisper file""" 10 parser = argparse.ArgumentParser( 11 description='Set xFilesFactor for existing whisper file') 12 parser.add_argument('path', type=str, help='path to whisper file') 13 parser.add_argument('xff', metavar='xFilesFactor', type=float, 14 help='new xFilesFactor, a float between 0 and 1') 15 16 args = parser.parse_args() 17 18 try: 19 old_xff = whisper.setXFilesFactor(args.path, args.xff) 20 except IOError: 21 sys.stderr.write("[ERROR] File '%s' does not exist!\n\n" % args.path) 22 parser.print_help() 23 sys.exit(1) 24 except whisper.WhisperException as exc: 25 raise SystemExit('[ERROR] %s' % str(exc)) 26 27 print('Updated xFilesFactor: %s (%s -> %s)' % 28 (args.path, old_xff, args.xff)) 29 30 31if __name__ == "__main__": 32 main() 33