Detect sound or audio from microphone and take action

I am designing an iOS app which works on sound response.

The sound can be of anything. Whenever the user says something or basically when the microphone receives any sound I want to control the phone’s flashlight or I want to take any action I want. That should not occur if there is no sound.

Can anyone suggest an idea? Thanks

I Think you App which you want to make is similar to iOS " Hey Siri " I won’t suggest you , You should too design an App for Android, Because in Android No any app Which relates to this App