1

I know the iPhone responds to "hey Siri". Is there similar features that I can use in my app to listen for certain sounds? If so what is the name of the iOS framework to use?

  • Are you talking about when your app is currently the actively running app or are you looking for something that your app can do even if it isn't running or in the background? – rmaddy Mar 01 '18 at 22:05
  • It will be running actively and in background. But dont need to listen when not used by user. – Chris_1983_Norway Mar 01 '18 at 22:06

3 Answers3

3

No, there is no API for that. Hey Siri is part of the OS and has hardware-level support. Your app can only use the microphones while it’s running; there is support for keeping the app alive while it’s recording audio, but the battery impact would be severe—the device can’t go to sleep—so it would be extremely unlikely to pass app review. That said, if you’d like API support to be added in future, please file an enhancement request with the use case you have in mind.

Noah Witherspoon
  • 57,021
  • 16
  • 130
  • 131
2

Yes sure, you can implement a recorder that records from the microphone and then you check anything you may need from recorded files.

Btw, what do you mean by certain sounds?

I think it sounds a bit tricky so please elaborate on your question. What's the business reason? How will you perform "listen for certain sounds"? How do you check it for being "certain". I think it's quite a hard thing to do using iOS but maybe I got your question wrong.

UPDATE: According to your comment: yeah it's possible but not like "hey ios check if it's a gunshot" :)))

But I think you can do it by checking the volume of the sound. If it is loud then it's a gunshot. I think it will work since user will use it on purpose. Check this link.

Also, I saw a similar app for gun shooters. So I'm sure it's doable:)

So shortly: find the way to: 1. use microphone. 2. Listen to sounds. 3. Check the sound for volume/length 4. Try detecting by testing

PS: Be careful with shooting while coding :)

Tung Fam
  • 7,899
  • 4
  • 56
  • 63
1

If your "certain" sounds are referring to spoken words. Apple has the Speech Recognition framework for determining particular words.

If you are trying to measure perhaps a particular frequency however, Like many guitar tuner apps use or other music recording type app, I would recommend checking in depth AVFoundation 's guide to audio engineering.

NSGangster
  • 2,397
  • 12
  • 22