Reputation: 11
I want to record the sound of the Pepper microphone and stream it to a server. I followed the code on the naoqi documentation and adapted it for a Choregraphe python box.
When I launch the program, I've got the following error :
[ERROR] ALAudioDeviceClient :threadReader:0 Error on processRemote, stopping thread: AudioModule::processRemote Type mismatch
Here's my code :
import qi
class AudioModule(object):
def __init__(self):
super(AudioModule, self).__init__()
self.moduleName = "AudioModule"
try :
self.ALAudioDevice = ALProxy("ALAudioDevice")
except Exception, e:
self.logger.error("Error when creating proxy on ALAudioDevice:")
self.logger.error(e)
def begin_stream(self):
self.ALAudioDevice.setClientPreferences(self.moduleName, 16000, 3, 0)
self.ALAudioDevice.subscribe(self.moduleName)
def end_stream(self):
self.ALAudioDevice.unsubscribe(self.moduleName)
def processRemote( self, nbOfChannels, samplesByChannel, altimestamp, buffer ):
nbOfChannels = nbOfChannels
#mylogger = qi.Logger("data")
#mylogger.info("It works ! " + nbOfChannels)
class MyClass(GeneratedClass):
def __init__(self):
GeneratedClass.__init__(self, False)
self.audio = AudioModule()
def onLoad(self):
self.serviceId = self.session().registerService("AudioModule", self.audio)
pass
def onUnload(self):
if self.serviceId != -1:
self.session().unregisterService(self.serviceId)
self.serviceId = -1
pass
def onInput_onStart(self):
self.audio.begin_stream()
def onInput_onStop(self):
self.audio.end_stream()
The structure of the processRemote function is the same as the example so why do I get a Type mismatch error ?
Thanks in advance !
Upvotes: 1
Views: 344
Reputation: 4507
Quite often "type mismatch" or "conversion" errors can come from the way you get your naoqi module. Here you get it the "old" (naoqi v.1) way :
self.ALAudioDevice = ALProxy("ALAudioDevice")
Which can generate conversion errors. Can you try to get it the new way, via the session :
self.ALAudioDevice = self.session().service("ALAudioDevice")
Upvotes: 1
Reputation: 2971
One problem is that your ALAudioDevice object doesn't have a "logger" member - you could just pass that one to your constructor (and also use it instead of the "mylogger" you use later on).
But the problem is probably coming from your
"It works ! " + nbOfChannels
... because you're trying to add a string and an integer, which Python doesn't like; do something like
"It works ! %i" % nbOfChannels
Upvotes: 0