bootphon / phonemizer

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

when set preserve_punctuation=True , it produce exceeded error. #123

Closed sunnnnnnnny closed 2 years ago

sunnnnnnnny commented 2 years ago

Describe the bug

import phonemizer as ph
from phonemizer.separator import Separator
 phonemized = ph.phonemize(lines, language_switch='remove-flags', separator=Separator(phone='-', word=' '),preserve_punctuation=True)
File "/data/home/*/.conda/envs/*/lib/python3.8/site-packages/phonemizer/punctuation.py", line 187, in _restore_aux
    return cls._restore_current(current, text, marks, num)
  File "/data/home/*/.conda/envs/*/lib/python3.8/site-packages/phonemizer/punctuation.py", line 151, in _restore_current
    @classmethod
  File "/data/home/*/.conda/envs/*/lib/python3.8/bdb.py", line 90, in trace_dispatch
    return self.dispatch_call(frame, arg)
  File "/data/home/*.conda/envs/*/lib/python3.8/bdb.py", line 128, in dispatch_call
    if not (self.stop_here(frame) or self.break_anywhere(frame)):
  File "/data/home/*/.conda/envs/*/lib/python3.8/site-packages/IPython/core/debugger.py", line 808, in break_anywhere
    sup = super().break_anywhere(frame)
  File "/data/home/*/.conda/envs/*/lib/python3.8/bdb.py", line 252, in break_anywhere
    return self.canonic(frame.f_code.co_filename) in self.breaks
  File "/data/home/*/.conda/envs/*/lib/python3.8/bdb.py", line 45, in canonic
    if filename == "<" + filename[1:-1] + ">":
RecursionError: maximum recursion depth exceeded in comparison

Phonemizer version 3.1.1

System linux

Expected behavior len(lines) >= 2000 when i don't set preserve_punctuation=True, it works; when i set preserve_punctuation=True,if produce exceeded error;

jncasey commented 2 years ago

Hi @sunnnnnnnny. The latest master has fixed the punctuation recursion error. I'm not sure when the next release is coming, but for now the current master should solve your problem.