bootphon / phonemizer

Simple text to phones converter for multiple languages
https://bootphon.github.io/phonemizer/
GNU General Public License v3.0
1.19k stars 166 forks source link

Failure with preserve_punctuation=True #40

Closed CorentinJ closed 4 years ago

CorentinJ commented 4 years ago
from phonemizer.phonemize import phonemize
phonemize("hi; ho,\"", backend="espeak", preserve_punctuation=True, punctuation_marks=".!;:,?")
Traceback (most recent call last):
  File "E:\Python37\lib\site-packages\IPython\core\interactiveshell.py", line 3291, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-26-f9fe7d23f4b3>", line 1, in <module>
    phonemize("hi; ho,\"", backend="espeak", preserve_punctuation=True, punctuation_marks=".!;:,?")
  File "E:\Python37\lib\site-packages\phonemizer\phonemize.py", line 172, in phonemize
    text, separator=separator, strip=strip, njobs=njobs)
  File "E:\Python37\lib\site-packages\phonemizer\backend\base.py", line 126, in phonemize
    text = self._punctuator.restore(text, punctuation_marks)
  File "E:\Python37\lib\site-packages\phonemizer\punctuation.py", line 146, in restore
    return cls._restore_aux(str2list(text), marks, 0)
  File "E:\Python37\lib\site-packages\phonemizer\punctuation.py", line 166, in _restore_aux
    [text[0] + m.mark + text[1]] + text[2:], marks[1:], n)
  File "E:\Python37\lib\site-packages\phonemizer\punctuation.py", line 166, in _restore_aux
    [text[0] + m.mark + text[1]] + text[2:], marks[1:], n)
IndexError: list index out of range

This is after https://github.com/bootphon/phonemizer/commit/83e8e620a223cbdecd415a7884b9a74d03ae76de.

mmmaat commented 4 years ago

thanks for reporting, normally this is fixed in b08713e.