Change the volume of Pepper according to the surrounding environment (sound)

Trigger

  1. It is troublesome to adjust the volume according to the number of people at exhibitions.
  2. Is volume control popular in Robot Library by Robot Start?
  3. I was waiting for someone to make it, but ...
  4. Let's make it because it is a great deal with "Pepper decides the winner by measuring the size of the applause of the audience" given by Professor Kawada. I thought.

API used

ALAudioDevice

Method used

getFrontMicEnergy()

Preparation

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.

How to decide the volume

--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

How it works

I want you to do it without permission, so after starting it, let the Timer move semi-permanently like this. スクリーンショット 2015-12-27 16.29.02.png

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)

Start-up

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. スクリーンショット 2015-12-27 16.45.31.png

bonus

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.

sample

Robot Start's Robot Library https://robo-lib.com/repositories/summary/42

Recommended Posts

Change the volume of Pepper according to the surrounding environment (sound)
Switch the setting value of setting.py according to the development environment
Script to change the description of fasta
Change the decimal point of logging from, to.
SmartVolumer, an Android app that adjusts the music playback volume according to the surrounding volume
Automatically select BGM according to the content of the conversation
[Python] Change the Cache-Control of the object uploaded to Cloud Storage
Dot according to the image
An introduction to object orientation-let's change the internal state of an object
Change the theme of Jupyter
Change the style of matplotlib
How to handle multiple versions of CUDA in the same environment
How to change the log level of Azure SDK for Python
How to change the color of just the button pressed in Tkinter
Change the Y-axis scale of Matplotlib to exponential notation (10 Nth power notation)
[Go] Create a CLI command to change the extension of the image
I summarized how to change the boot parameters of GRUB and GRUB2
I tried to expand the size of the logical volume with LVM
How to set up the development environment of ev3dev [Windows version]
Change the Flyweight pattern to Pythonic (?) (3)
Change the Flyweight pattern to Pythonic (?) (2)
Change the background of Ubuntu (GNOME)
Change the Python version of Homebrew
Change the Flyweight pattern to Pythonic (?) (1)
Change the suffix of django-filter / DateFromToRangeFilter
Supplement to the explanation of vscode
[Python] Change the alphabet to numbers
Use Cloud Dataflow to dynamically change the destination according to the value of the data and save it in GCS
[Golang Error handling] The best way to separate processing according to the type of error
When you want to change the HTTP headers of Flask's test client
I checked the contents of docker volume
Change Python 64bit environment to 32bit environment with Anaconda
The story of trying to reconnect the client
10 methods to improve the accuracy of BERT
The story of adding MeCab to ubuntu 16.04
About the virtual environment of python version 3.7
Build the execution environment of Jupyter Lab
Try to prepare each environment of kivy
Change the order of PostgreSQL on Heroku
The story of pep8 changing to pycodestyle
Change the destination batfish server of pybatfish
How to make VS Code aware of the venv environment and its benefits
Test of the difference between the mean values of count data according to the Poisson distribution
I want to use Python in the environment of pyenv + pipenv on Windows 10
Change the Key of Object on S3 from normal date format to Hive format
Change the data frame of pandas purchase data (id x product) to a dictionary
How to change the appearance of unselected Foreign Key fields in Django's ModelForm
Ansible self-made module creation-Part 3: Life that wants to judge the necessity of change-
How to install the deep learning framework Tensorflow 1.0 in the Anaconda environment of Windows