theintencity / rtclite

Light weight implementations of real-time communication protocols and applications in Python
https://rtclite.com
Other
112 stars 39 forks source link

caller doesn't manage --no-audio correctly #8

Open fralbo opened 5 years ago

fralbo commented 5 years ago

Hello,

In case of audiodev.so import failure we cannot use caller.py module even if we specified --no-audio option. In fact it's due to a problem in the import statement which is:

try: import audiodev, audiospeex, audiotts, audioop
except ImportError: audiodev, audiospeex = audiotts = audioop = None

so if audiodev import fails, all imports including audiotts are set to None. But later in the code we have:

if options.recognize and sr is None:
    raise ImportError('please install speech_recognition module in your PYTHONPATH to use --recognize option')
if options.textspeech and audiotts is None:
    raise ImportError('please install py-audio in your PYTHONPATH to use --textspeech option')
if options.audio and audiodev is None:
    raise ImportError('please install py-audio in your PYTHONPATH to use audio, otherwise start with --no-audio option')

So if you use --textspeech option you will verify the second if test which is wrong because the problem came from audiodev.

Imports should be:

try: import audiospeex, audiotts, audioop
except ImportError: audiospeex = audiotts = audioop = None

try: import audiodev
except ImportError: audiodev = None