How to use the phonemizer.main.main function in phonemizer

To help you get started, we’ve selected a few phonemizer examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github bootphon / phonemizer / test / test_main.py View on Github external
def _test(input, expected_output, args=''):
    with tempfile.NamedTemporaryFile('w') as finput:
        # python2 needs additional utf8 encoding
        if sys.version_info[0] == 2:
            input = input.encode('utf8')
        finput.write(input)
        finput.seek(0)

        with tempfile.NamedTemporaryFile('w+') as foutput:
            opts = '{} -o {} {}'.format(finput.name, foutput.name, args)
            sys.argv = ['foo'] + shlex.split(opts)
            main.main()

            output = foutput.read()
            # python2 needs additional utf8 decoding
            if sys.version_info[0] == 2:
                output = output.decode('utf8')
            if expected_output == '':
                assert output == ''
            else:
                assert output == expected_output + '\n'
github bootphon / phonemizer / test / test_main.py View on Github external
def test_help():
    sys.argv = ['foo', '-h']
    with pytest.raises(SystemExit):
        main.main()
github bootphon / phonemizer / test / test_main.py View on Github external
def test_version():
    sys.argv = ['foo', '--version']
    main.main()