How to make Python speak

前端 未结 13 1213
时光说笑
时光说笑 2020-11-30 20:34

How could I make Python say some text?

I could use Festival with subprocess but I won\'t be able to control it (or maybe in interactive mode, but it won\'t be clean)

13条回答
  •  天涯浪人
    2020-11-30 20:50

    PYTTSX3!

    WHAT:

    Pyttsx3 is a python module which is a modern clone of pyttsx, modified to work perfectly well in the latest versions of Python 3!

    • Python Package Index for downloads: https://pypi.python.org
    • GitHub for source , bugs, and Q&A: https://github.com/nateshmbhat/pyttsx3
    • Read the Full documentation at: https://pyttsx3.readthedocs.org

    WHY:

    It is 100% MULTI-PLATFORM and WORKS OFFLINE and IS ACTIVE/STILL BEING DEVELOPED and WORKS WITH ANY PYTHON VERSION

    HOW:

    It can be easily installed with pip install pyttsx3 and usage is the same as pyttsx:

    import pyttsx3;
    engine = pyttsx3.init();
    engine.say("I will speak this text");
    engine.runAndWait();
    

    This is the best multi platform option!

提交回复
热议问题