0

TLDR: What I want to acquire is the source code for pyttsx3.Engine.proxy._driver.say, in order to modify its source code to save the converted audio file instead of speaking it, but unfortunately, this was it. Is there any way to acquire these kinds of internal source codes in VS code or in any other IDEs if applicable?

I've been struggling trying to make an audiobook in Python that can be played and paused based on the user's preference. The gTTS module allows text to audio conversion but requires internet connection, so it gives users more burden. The pyttsx3.say() method from the pyttsx3 module allows text to be directly spoken by a device, but it does not give users the option of pause and play. the pyttsx3.save_to_file() method does save text to audio, but it's very buggy when saving a large text file. Hence, I tried to look at the internal source code for the pyttsx3.say() but the farthest I could see was:

engine.py
def say(self, text, name=None):
        """
        Adds an utterance to speak to the event queue.

        @param text: Text to sepak
        @type text: unicode
        @param name: Name to associate with this utterance. Included in
            notifications about this utterance.
        @type name: str
        """
        self.proxy.say(text, name)
driver.py
def say(self, text, name):
        '''
        Called by the engine to push a say command onto the queue.

        @param text: Text to speak
        @type text: unicode
        @param name: Name to associate with the utterance
        @type name: str
        '''
        self._push(self._driver.say, (text,), name)

What I want to acquire is the source code for pyttsx3.Engine.proxy._driver.say, in order to modify its source code to save the converted audio file instead of speaking it, but unfortunately, this was it. Is there any way to acquire these kinds of internal source codes in VS code or in any other IDEs if applicable?

lucidcloud
  • 73
  • 6
  • 1
    Source code generally has nothing to with a IDE. Whether it's available depends on the author / owner of the project. If it's pure Python code, installing the project usually involves download a copy of its source code. – martineau Jan 15 '21 at 07:30
  • @martineau Is there any way to check if the method is pure python code and acquire the source code if it is? – lucidcloud Jan 15 '21 at 07:37
  • Not that I know of. You may be able to find the its files in your Python/Libs folder or a subfolder and look in them. If you have some sort of text search utility, that would speed up the process. Nowadays many third-party modules keep their source code and track changes to it in online version-control systems like github and you can often browse through the lastest source code via a web-browser. The `pyttsx3` module's homepage is https://github.com/nateshmbhat/pyttsx3 P.S. The homepage was listed [here](https://pypi.org/project/pyttsx3/). – martineau Jan 15 '21 at 08:32

0 Answers0