Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Windows] Program removes backslashes in path when calling subprocess #17

Closed
CenTdemeern1 opened this issue Dec 18, 2018 · 2 comments
Closed

Comments

@CenTdemeern1
Copy link

CenTdemeern1 commented Dec 18, 2018

Traceback (most recent call last):
  File "c:\users\User\appdata\local\programs\python\python36-32\lib\site-packages\phonemizer\festival.py", line 140, in _process
    shlex.split(cmd), stderr=fstderr)
  File "c:\users\User\appdata\local\programs\python\python36-32\lib\subprocess.py", line 336, in check_output
    **kwargs).stdout
  File "c:\users\User\appdata\local\programs\python\python36-32\lib\subprocess.py", line 418, in run
    output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['festival', '-b', 'C:UsersUserAppDataLocalTemptmph1yalspd']' returned non-zero exit status 4294967295.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\User\AppData\Local\Programs\Python\Python36-32\Scripts\phonemize-script.py", line 11, in <module>
    load_entry_point('phonemizer==0.3.1', 'console_scripts', 'phonemize')()
  File "c:\users\User\appdata\local\programs\python\python36-32\lib\site-packages\phonemizer\main.py", line 192, in main
    separator=sep, strip=args.strip, njobs=args.njobs, logger=logger)
  File "c:\users\User\appdata\local\programs\python\python36-32\lib\site-packages\phonemizer\phonemize.py", line 113, in phonemize
    separator=separator, strip=strip)
  File "c:\users\User\appdata\local\programs\python\python36-32\lib\site-packages\phonemizer\festival.py", line 77, in phonemize
    b = _process(a, script, logger)
  File "c:\users\User\appdata\local\programs\python\python36-32\lib\site-packages\phonemizer\festival.py", line 149, in _process
    .format(cmd, err.returncode, fstderr.read()))
RuntimeError: Command "festival -b C:\Users\User\AppData\Local\Temp\tmph1yalspd" returned exit status 4294967295, output is:
SIOD ERROR: could not open file C:UsersUserAppDataLocalTemptmph1yalspd

So I think I know what happend:
in the module phonemizer.espeak at line 85 it calls shlex.split(command). when testing, this happend:

>>> command='C:\\Users\\User\\AppData\\Local\\Temp\\test'
>>> shlex.split(command)
['C:UsersUserAppDataLocalTemptest']

This has something to do with Windows paths using backslashes.

This can be proven by replacing the double backslashes with forwardslashes.

Then the path returned keeps its path seperators (forwardslashes).

@mmmaat mmmaat changed the title Program removes backslashes in path when calling subprocess [Windows] Program removes backslashes in path when calling subprocess Dec 19, 2018
@mmmaat
Copy link
Collaborator

mmmaat commented Dec 19, 2018

Thank you for reporting. I never tested it on Windows but was thinking shlex is generic enough... This is related to the posix option of shlex.split I guess:

>>> command='festival -b C:\\Users\\User\\AppData\\Local\\Temp\\test'
>>> shlex.split(command, posix=False)
['festival', '-b', 'C:\\Users\\User\\AppData\\Local\\Temp\\test']
>>> shlex.split(command, posix=True)
['festival', '-b', 'C:UsersUserAppDataLocalTemptest']

I'll push a bugfix in few hours and let you know!

@mmmaat mmmaat closed this as completed in 0f1f0cd Dec 19, 2018
@mmmaat
Copy link
Collaborator

mmmaat commented Dec 19, 2018

I fixed it, should be OK now...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants