我想录制 Pepper 麦克风的声音并将其流式传输到服务器。我遵循了naoqi 文档上的代码并将其改编为Choregraphe python box。
当我启动程序时,出现以下错误:
[ERROR] ALAudioDeviceClient :threadReader:0 Error on processRemote, stopping thread: AudioModule::processRemote Type mismatch
这是我的代码:
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()
processRemote 函数的结构与示例相同,为什么会出现类型不匹配错误?
提前致谢 !