天天看点

cannot import name 'SpeechLib'

cannot import name 'SpeechLib'

解决方法:

import comtypes.client  # Importing comtypes.client will make the gen subpackage

try:

    from comtypes.gen import SpeechLib  # comtypes

except ImportError:

    # Generate the SpeechLib lib and any associated files

    engine = comtypes.client.CreateObject("SAPI.SpVoice")

    stream = comtypes.client.CreateObject("SAPI.SpFileStream")

    from comtypes.gen import SpeechLib