What to look for to adjust the volume.
-[x] Amount of people -[x] Volume around -[] Distance between Pepper and people -[] People's movements
I will make it with the above two.
--Noisy surroundings-> Maximum volume --Customers are not in front of Pepper-> Original volume ――One customer-> 60% because I think it's noisy if it's too big ――2 to 3 customers-> 80% because I want everyone to ask ――4 or more customers-> 100% because it seems to be difficult to hear
I want you to do it without permission, so after starting it, let the Timer move semi-permanently like this.
The output Volume (%) is put in the variable of the Set Speaker Vol. Box. After that, set the Volume each time at the set interval.
Config.py
def onLoad(self):
self.timer = None
self.nFacesDetected = -1
self.audiodevice = ALProxy("ALAudioDevice")
self.defaultVol = self.audiodevice.getOutputVolume()
self.vol = self.defaultVol
def onUnload(self):
self.cancelTimer()
def cancelTimer(self):
if self.timer:
self.timer.stop()
self.timer = None
def onTimer(self):
self.timerOutput()
def startTimer(self):
import qi
self.timer = qi.PeriodicTask()
self.timer.setCallback(self.onTimer)
self.timer.setUsPeriod(int(self.getParameter("Period (s)") * 1000 * 1000))
self.timer.start(True)
def onInput_onStart(self):
self.cancelTimer()
self.startTimer()
def onInput_onStop(self):
self.audiodevice.setOutputVolume(self.defaultVol)
if self.timer and self.timer.isRunning():
self.onStopped()
self.onUnload()
def onInput_inputFaceTracked(self, p):
if(len(p) > 0):
if(self.nFacesDetected != len(p[1]) -1): # an additional array has been placed at the end for time
self.nFacesDetected = len(p[1]) -1 # filtered info and has to be substracted when counting faces
self._JudgeOutput( self.nFacesDetected )
else:
if(self.nFacesDetected != 0):
self.nFacesDetected = 0
self._JudgeOutput( self.nFacesDetected )
def _JudgeOutput(self, envMaterial):
self.logger.info("FrontMicEnergy:%d" % self.audiodevice.getFrontMicEnergy())
self.logger.info("envMaterial:%d" % envMaterial)
if (self.audiodevice.getFrontMicEnergy() >= 1800):
self.EnvironmentVolume(100)
elif envMaterial == 0:
self.EnvironmentVolume(self.defaultVol)
elif envMaterial == 1:
self.EnvironmentVolume(60)
elif envMaterial >= 2 and envMaterial < 4:
self.EnvironmentVolume(80)
elif envMaterial >= 4:
self.EnvironmentVolume(100)
To start it, check this flag next to the play button, or if you insert a plug-in, the application will start running automatically when Pepper is started.
The original volume is memorized when Config is loaded and returned when the application is closed. If you press the back bumper 4 times within 5 seconds after touching your head, the volume will be restored and the application will end.
Robot Start's Robot Library https://robo-lib.com/repositories/summary/42
Recommended Posts