주변 환경 (소리)에 따라 마음대로 Pepper의 볼륨을 변경
                                            
                                                
                                                
                                                
                                                
                                                
                                                 4799 단어  Choregraphe파이썬Pepper
                    
계기
로봇 시작 님의 로봇 라이브러리
사용한 API
 ALAudioDevice
※ 지난번 와 함께 w
 사용한 Method
 getFrontMicEnergy()
※ 지난번 와 함께 w
 준비
무엇을 보고 볼륨을 조정하는가?
사람의 양 
주위의 볼륨 
Pepper와 사람 사이의 거리 
사람의 움직임 
이상의 2개로 만들어 보겠습니다.
 볼륨을 결정하는 방법
getFrontMicEnergy()
※ 지난번 와 함께 w
준비
무엇을 보고 볼륨을 조정하는가?
사람의 양 
주위의 볼륨 
Pepper와 사람 사이의 거리 
사람의 움직임 
이상의 2개로 만들어 보겠습니다.
 볼륨을 결정하는 방법
메커니즘
마음대로 하고 싶으면 기동 후, Timer로 이런 느낌으로 반영구적으로 움직여 달라고 합니다.
 
출력한 Volume(%)은 Set Speaker Vol. 박스의 변수에 넣고 있습니다.
그 후, 설정해 둔 간격으로 Volume를 매번, 설정.
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)
 시작
기동은 재생 버튼의 옆의 이 깃발에 체크를 해 두는지, 플러그 인 넣으면 Pepper 기동했을 때 마음대로 앱은 움직입니다.
 
 덤
Config를로드 할 때 원래 볼륨을 기억하고 앱을 종료 할 때 돌아갑니다.
머리를 터치한 후 5초 이내에 백범퍼를 4번 누르면 볼륨을 되돌려 앱 종료입니다.
 샘플
로봇 시작의 로봇 라이브러리
 htps : // 로보-b. 코 m / 레포시 토리 s / 슈마 ry / 42
                
                    
        
    
    
    
    
    
                
                
                
                
                    
                        
                            
                            
                            Reference
                            
                            이 문제에 관하여(주변 환경 (소리)에 따라 마음대로 Pepper의 볼륨을 변경), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다
                                
                                https://qiita.com/mat_aaa/items/ae7290fe4997f6894091
                            
                            
                            
                                텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
                            
                            
                                
                                
                                 우수한 개발자 콘텐츠 발견에 전념
                                (Collection and Share based on the CC Protocol.)
                                
                                
                                우수한 개발자 콘텐츠 발견에 전념
                                (Collection and Share based on the CC Protocol.)
                            
                            
                        
                    
                
                
                
            
    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)
기동은 재생 버튼의 옆의 이 깃발에 체크를 해 두는지, 플러그 인 넣으면 Pepper 기동했을 때 마음대로 앱은 움직입니다.

덤
Config를로드 할 때 원래 볼륨을 기억하고 앱을 종료 할 때 돌아갑니다.
머리를 터치한 후 5초 이내에 백범퍼를 4번 누르면 볼륨을 되돌려 앱 종료입니다.
 샘플
로봇 시작의 로봇 라이브러리
 htps : // 로보-b. 코 m / 레포시 토리 s / 슈마 ry / 42
                
                    
        
    
    
    
    
    
                
                
                
                
                    
                        
                            
                            
                            Reference
                            
                            이 문제에 관하여(주변 환경 (소리)에 따라 마음대로 Pepper의 볼륨을 변경), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다
                                
                                https://qiita.com/mat_aaa/items/ae7290fe4997f6894091
                            
                            
                            
                                텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
                            
                            
                                
                                
                                 우수한 개발자 콘텐츠 발견에 전념
                                (Collection and Share based on the CC Protocol.)
                                
                                
                                우수한 개발자 콘텐츠 발견에 전념
                                (Collection and Share based on the CC Protocol.)
                            
                            
                        
                    
                
                
                
            
로봇 시작의 로봇 라이브러리
htps : // 로보-b. 코 m / 레포시 토리 s / 슈마 ry / 42
Reference
이 문제에 관하여(주변 환경 (소리)에 따라 마음대로 Pepper의 볼륨을 변경), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/mat_aaa/items/ae7290fe4997f6894091텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
                                
                                
                                
                                
                                
                                우수한 개발자 콘텐츠 발견에 전념
                                (Collection and Share based on the CC Protocol.)