5

Is it posssible to implement an iOS app that is capable of recording audio (for the purpose of processing speech-to-text) when a user presses a button on a connected Bluetooth (BLE) device, when the handset screen is off or the app is backgrounded?

I've been digging for a long time now only to find old/unanswered/vaguely related posts.

I have a small Bluetooth controller that has a few buttons. One of the buttons is intended for triggering audio recording via the handset microphone (or via an attached Bluetooth headset microphone). At this point, we've implemented this and it works just fine when the screen is on and the app is foregrounded, however when the app is backgrounded or the screen is off, this functionality ceases to function.

Our implementation makes use of SFSpeechrecognizer via the Speech framework, and we've ensured to add all appropriate capabilities to the project/Info.plist (including Audio, Speech Recognition, Microphone Usage). Our app does continuous background processing that is unrelated to audio recording already and receives Bluetooth (BLE) button presses from the connected device without a problem, regardless of if the app is in the foreground or background.

It is my understanding that Apple/iOS restricts the use of audio recording initiated while the app is backgrounded. This makes sense from a privacy/security perspective, if the app were to initiate audio recording on its own, but does this limitation mean there are no methods of enabling our users to initiate audio recording on Bluetooth (BLE) device button press?

Absolutely any constructive guidance on this would be greatly appreciated!

Tom Larcher
  • 661
  • 9
  • 24
  • Have you spent an Apple support incident on this? – meaning-matters Aug 17 '22 at 04:39
  • 1
    @meaning-matters sure have! Still awaiting a response at this point. Hoping that if they return with something useful, I'll be able to relay it within this post for others to benefit from. – Tom Larcher Aug 17 '22 at 04:57
  • Duplicate of https://stackoverflow.com/questions/42020124/ios-background-audio-recording which doesn't seem to have a working answer. – Emil Aug 22 '22 at 08:05
  • @Emil you're correct, however as mentioned in the question, all answers that I've discovered (including the one you've found) are old (others are unanswered or loosely related). In the post you've linked, there is lots of helpful information, but it was posted around mid-2017, meaning that the information relates to iOS versions 10/11. From what I've read, there were significant changes to background audio made around iOS version 13 (onwards). – Tom Larcher Aug 23 '22 at 01:08

2 Answers2

3

Seems that Apple silently disables microphone in background mode due to privacy concerns. As a result, background session gets input channel with 0 Hz frequency and fails.

Workarounds are below but all of them have significant cons:

  • Start recording in active state and keep it on background. Handle required episode based on any kind of event like device buttons push. Cons are the battery impact and always presented orange microphone system bar on the top left side of the screen.
  • Record voice on gadget side and transfer it over Bluetooth back to iPhone to handle it. Cons is the significant complexity of implementation on BLE device and possible hardware limitations.
  • Use SiriKit paired with Shortcuts app. Pros: possible to talk with locked iPhone.Cons: current Siri implementation has a lot of UX flaws. User should tell one command at least in two phrases while Siri feedback isn't available as it re-routed to the iPhone instead of BLE speakers. Voice recognition still far from ideal so any step could fail because of it. Thus it's like talking with not very smart blackbox without much feedback and variable delays.
0

One alternative approach is, you can keep your audio recording session always ON and do audio processing when you get input from your BLE device.

Aruna Mudnoor
  • 4,795
  • 14
  • 16