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 issue with NamedTemporaryFile #21

Closed
snowzhangy opened this issue Jun 1, 2019 · 8 comments
Closed

Windows issue with NamedTemporaryFile #21

snowzhangy opened this issue Jun 1, 2019 · 8 comments

Comments

@snowzhangy
Copy link

snowzhangy commented Jun 1, 2019

when i run phonemize on windows 10 , python 3.6 i still have issue. it looks the temp file doesn't created at all. (the backslash issue fixed i can see)

>>> ph=phonemize('Hello World',strip=False,njobs=1,backend='espeak')
Failed to read file 'C:\Users\cinetec\AppData\Local\Temp\tmp5sigu2vf'
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\cinetec\AppData\Local\Programs\Python\Python36\lib\site-packages\phonemizer-1.0.1-py3.6.egg\phonemizer\phonemize.py", line 94, in phonemize
    text, separator=separator, strip=strip, njobs=njobs)
  File "C:\Users\cinetec\AppData\Local\Programs\Python\Python36\lib\site-packages\phonemizer-1.0.1-py3.6.egg\phonemizer\backend.py", line 130, in phonemize
    out = self._phonemize_aux(self._list2str(text), separator, strip)
  File "C:\Users\cinetec\AppData\Local\Programs\Python\Python36\lib\site-packages\phonemizer-1.0.1-py3.6.egg\phonemizer\backend.py", line 235, in _phonemize_aux
    shlex.split(command, posix=False)).decode('utf8')
  File "C:\Users\cinetec\AppData\Local\Programs\Python\Python36\lib\subprocess.py", line 356, in check_output
    **kwargs).stdout
  File "C:\Users\cinetec\AppData\Local\Programs\Python\Python36\lib\subprocess.py", line 438, in run
    output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['espeak', '-ven-us', '--ipa=3', '-q', '-f', 'C:\\Users\\cinetec\\AppData\\Local\\Temp\\tmp5sigu2vf']' returned non-zero exit status 1.
@mmmaat
Copy link
Collaborator

mmmaat commented Jun 3, 2019

I do not have a windows machine to test it... But few stuff you can do:

  • what is the result of phonemize --version? Or the version() function in the main.py.
  • what is the result of espeak -ven-us --ipa=3 -q -f test.txt from command line? (put 'Hello World' in test.txt

@CorentinJ
Copy link

CorentinJ commented Jul 3, 2019

I'm having the same issue. The command will fail if there are spaces in any of the paths to begin with, but even without I meet the same error as @snowzhangy:

subprocess.CalledProcessError: Command 
'['D:\\Users\\Corentin\\Documents\\Utilities\\CLI\\espeak.exe', '-ven-us', '--ipa=3',
 '-q', '-f', 'C:\\Users\\Valiox\\AppData\\Local\\Temp\\tmp76tt0mot']' 
returned non-zero exit status 1.

(breaks added for readability)

Running that identical command in CLI but on another text file works without issues.

@CorentinJ
Copy link

I guess something is wrong with NamedTemporaryFile on windows, because using a regular file works fine.

@mmmaat
Copy link
Collaborator

mmmaat commented Jul 4, 2019

Indeed from Python doc they say: Whether the name can be used to open the file a second time, while the named temporary file is still open, varies across platforms (it can be so used on Unix; it cannot on Windows NT or later).

I'm working on a fix.

@mmmaat
Copy link
Collaborator

mmmaat commented Jul 4, 2019

I pushed a commit in the branch issue21.

As I said I do not have Windows so I cannot check myself. Could you please test if the bug is fixed on that branch and let me know?

Thanks.

@mmmaat
Copy link
Collaborator

mmmaat commented Jul 4, 2019

The idea is to use tmpfile.close() instead of tmpfile.seek(0)

@CorentinJ
Copy link

Yep, that fixes it 👍

@mmmaat mmmaat changed the title Windows issue Windows issue with NamedTemporaryFile Jul 4, 2019
@mmmaat
Copy link
Collaborator

mmmaat commented Jul 4, 2019

Thanks, merged into master

@mmmaat mmmaat closed this as completed Jul 4, 2019
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

3 participants