Threading Issue When Using Voice Recognition on TurtleBot3 (Kinetic)

asked 2017-10-18 13:21:04 -0600

jonasro gravatar image

updated 2017-10-21 09:50:28 -0600

I've gotten pocketsphinx (using a wrapper for Kinetic) and pyttsx working on my TurtleBot3. Pocketsphinx seems to be working correctly, but pyttsx stops talking after a single word / phrase. Upon quitting my pyttsx subscriber node I get this error:

^CException in thread /voice (most likely raised during interpreter shutdown):
Traceback (most recent call last):
  File "/usr/lib/python2.7/", line 801, in __bootstrap_inner
  File "/usr/lib/python2.7/", line 754, in run
  File "/opt/ros/kinetic/lib/python2.7/dist-packages/rospy/impl/", line 185, in robust_connect_subscriber
  File "/opt/ros/kinetic/lib/python2.7/dist-packages/rospy/impl/", line 823, in receive_loop
<type 'exceptions.TypeError'>: 'NoneType' object is not callable

The code that we're using subscribes to pocketsphinx topic, and it's pretty generic:

#!/usr/bin/env python

import rospy
import pyttsx
from std_msgs.msg import String

def voice_callback(msg):
    engine = pyttsx.init()
    if 'hello' in
        engine.say('Hello, I am Leonardo')

def main():
    sub = rospy.Subscriber('voice', String, voice_callback)

if __name__ == '__main__':

When the same exact code runs on my VirtualBox, pyttsx can run indefinitely without any problem. Does anyone know why I'm getting this error / how to fix it? Any suggestions and direction will be helpful!

edit retag flag offensive close merge delete