Code Monkey home page Code Monkey logo

Comments (7)

PureTryOut avatar PureTryOut commented on June 12, 2024 1

The CLI doesn't segfault for me, but the tests certainly do. #3 fixes it so having that merged in a future release would be great!

from espeak-phonemizer.

synesthesiam avatar synesthesiam commented on June 12, 2024 1

Please upgrade to 1.3.1 and try again (thanks @msftcangoblowm)

from espeak-phonemizer.

athoune avatar athoune commented on June 12, 2024

With some print debugging, near line 100

        print("ptr", text_pointer)
        while text_pointer:
            clause_phonemes = ctypes.c_char_p(
                self.lib_espeak.espeak_TextToPhonemes(
                    ctypes.pointer(text_pointer), text_flags, phoneme_flags,
                )
            )
            print("ptr", text_pointer)
            print("clause", clause_phonemes)
            print("value", clause_phonemes.value)
            if clause_phonemes.value is not None:
                phoneme_lines.append(
                    clause_phonemes.value.decode()  # pylint: disable=no-member
                )

It prints:

$ echo "Hello" | python3 -m espeak_phonemizer -v en-us
ptr c_char_p(140501981572336)
ptr c_char_p(None)
clause c_char_p(2096739184)
Segmentation fault

The text is read (first the pointer exists, then it is None).
When value of clause_phonemes is get, it crashs.

from espeak-phonemizer.

nefastosaturo avatar nefastosaturo commented on June 12, 2024

Hi there, same problem here, three different systems.

  1. On google colab, ok

  2. On my system, Ubuntu 18.04 with python 3.7.6, Segmentation Fault

  3. On Docker, using the image for training Piper, python 3.8.1.2 Segmentation Fault

From 2) I created a conda env with Python 3.9, it worked.

So it seems that the problem is Python <3.9 (Colab is shipped with the 3.9.16) .

EDIT: 3)from the Docker image "nvcr.io/nvidia/pytorch:22.03-py3" taken from the Piper repository, creating a conda env with python 3.9.16 still gives segmentation fault

from espeak-phonemizer.

methosmythos avatar methosmythos commented on June 12, 2024

Hi,

it appears, that a restype for an external function call must be set, otherwise python assumes, that the return type of the function is always a C int type.

so if in def _maybe_init(self):, after library loading something like this is done:

self.lib_espeakTTP = self.lib_espeak.espeak_TextToPhonemes
self.lib_espeakTTP.restype = ctypes.c_char_p

and then instead of using self.lib_espeak.espeak_TextToPhonemes directly in the phonemize function, use the self.lib_espeakTTP.
I'm not a python coder, so maybe there's another (cleaner) way of doing this, but this way appears to be working, if someone needs it right away...

from espeak-phonemizer.

msftcangoblowm avatar msftcangoblowm commented on June 12, 2024

Following methosm excellent advice.
The entire working method (minimal changes).

    def _phonemize_no_stream(self, text: str, \
        phoneme_separator: Optional[str]) -> List[str]:
        phoneme_flags = Phonemizer.espeakPHONEMES_IPA
        if phoneme_separator:
            phoneme_flags = phoneme_flags | (ord(phoneme_separator) << 8)

        text_bytes = text.encode("utf-8")
        text_pointer = ctypes.c_char_p(text_bytes)
        text_flags = Phonemizer.espeakCHARS_AUTO
        phoneme_lines = []
        fcn_ttp = self.lib_espeak.espeak_TextToPhonemes
        fcn_ttp.restype = ctypes.c_char_p
        while text_pointer:
            clause_phonemes = fcn_ttp( \
            ctypes.pointer(text_pointer), text_flags, \
            phoneme_flags)
            if isinstance(clause_phonemes, bytes):
                clause_phonemes_str = clause_phonemes.decode()  # pylint: disable=no-member
                phoneme_lines.append(clause_phonemes_str)

        return phoneme_lines

nefastosaturo suggests python 3.9.16 could be a cause
I have it working on python 3.9.16
This issue, mostly likely, has nothing to do with the python interpreter version

Edit
June 26th, 2023: this comment cleaned up; sorry about the typo. In espeak, Michael fixed that typo in a later commit

from espeak-phonemizer.

msftcangoblowm avatar msftcangoblowm commented on June 12, 2024

#3

from espeak-phonemizer.

Related Issues (4)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.