File size: 1,381 Bytes
dc6dc7d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
"""Run a verified Inflect Mini package without writing into its model folders."""
import sys
sys.dont_write_bytecode = True

import argparse
from pathlib import Path
import subprocess

from verify_release import verify


def main():
    parser = argparse.ArgumentParser(description=__doc__)
    parser.add_argument('mode', choices=('speech', 'events'),
                        help='Ordinary speech or the optional six-voice event component')
    args, forwarded = parser.parse_known_args()
    root = Path(__file__).resolve().parent
    verify(root)
    if args.mode == 'speech':
        if any(arg == '--model' or arg.startswith('--model=') for arg in forwarded):
            parser.error('This download contains Mini; no --model flag is needed.')
        command = [str(root / 'core/synthesize.py'), '--model', 'mini', *forwarded]
    else:
        protected = ('--core-root', '--core-manifest-sha256', '--component', '--component-sha256')
        if any(arg == flag or arg.startswith(flag + '=') for arg in forwarded for flag in protected):
            parser.error('Component paths are selected from this verified download.')
        command = [str(root / 'extras/events/command.py'), '--events', *forwarded]
    raise SystemExit(subprocess.run([sys.executable, '-B', *command], check=False).returncode)


if __name__ == '__main__':
    main()