Skip to content

Add AudioRecordingIntent sample implementation with Live Activity#4087

Closed
Copilot wants to merge 5 commits intomainfrom
copilot/create-audio-recording-intent
Closed

Add AudioRecordingIntent sample implementation with Live Activity#4087
Copilot wants to merge 5 commits intomainfrom
copilot/create-audio-recording-intent

Conversation

Copy link
Contributor

Copilot AI commented Dec 11, 2025

Summary

Implements a sample AudioRecordingIntent (iOS 17.0+) demonstrating audio recording with comprehensive input logging, Live Activity support, and audio settings matching the existing Home Assistant AudioRecorder.

Implementation (Sources/Extensions/AppIntents/AudioRecording/AudioRecordingAppIntent.swift):

  • Conforms to AudioRecordingIntent protocol
  • Displays Live Activity during recording (required by AudioRecordingIntent documentation) showing elapsed time and progress on Lock Screen/Dynamic Island
  • Records audio (Linear PCM, 16kHz mono, 16-bit) to temporary storage using settings consistent with existing Home Assistant Assist AudioRecorder
  • Configurable duration (1-60s, default 10s) and metadata logging toggle
  • Logs all operations via Current.Log: start/stop, permissions, duration, sample rate, channels, file size, Live Activity status
  • Handles microphone permissions via AVAudioApplication.requestRecordPermission()
  • Returns structured response with recording metadata

Example log output:

AudioRecordingAppIntent: Starting audio recording
AudioRecordingAppIntent: Duration: 10 seconds
AudioRecordingAppIntent: Microphone access granted
AudioRecordingAppIntent: Live Activity started
AudioRecordingAppIntent: Recording to file: /tmp/audio_recording_1234567890.wav
AudioRecordingAppIntent: Recording stopped
AudioRecordingAppIntent: Live Activity ended
AudioRecordingAppIntent: Recording Metadata:
  - Duration: 10.0 seconds
  - Sample Rate: 16000.0 Hz
  - Channels: 1
  - File Size: 320044 bytes (312.5 KB)
AudioRecordingAppIntent: Recording completed successfully

Documentation:

  • README.md - Technical architecture including Live Activity details
  • INTEGRATION.md - Xcode project integration steps (includes ActivityKit requirements)
  • EXAMPLES.md - Usage patterns (Siri, Shortcuts, programmatic)
  • SUMMARY.md - Implementation overview

Screenshots

N/A - Sample intent for developers, no UI changes (Live Activity is system-provided)

Link to pull request in Documentation repository

Documentation: home-assistant/companion.home-assistant#

Any other notes

Files require manual addition to Xcode project targets. See INTEGRATION.md for steps. Requires microphone permissions in Info.plist and ActivityKit framework. Audio settings (16kHz mono) match the existing Home Assistant Assist AudioRecorder for consistency.

Original prompt

Propose a sample intent which records audio and logs the input, use AudioRecordingIntent (https://developer.apple.com/documentation/AppIntents/AudioRecordingIntent)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 3 commits December 11, 2025 14:51
Co-authored-by: bgoncal <5808343+bgoncal@users.noreply.github.com>
Co-authored-by: bgoncal <5808343+bgoncal@users.noreply.github.com>
Co-authored-by: bgoncal <5808343+bgoncal@users.noreply.github.com>
Copilot AI changed the title [WIP] Add audio recording intent using AudioRecordingIntent Add AudioRecordingIntent sample implementation Dec 11, 2025
Copilot AI requested a review from bgoncal December 11, 2025 14:59
@bgoncal
Copy link
Member

bgoncal commented Dec 11, 2025

@copilot according to the docs we must display a live activity when recording. Also reuse the AudioRecorder that already exists

…dioRecorder

Co-authored-by: bgoncal <5808343+bgoncal@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Dec 11, 2025

@copilot according to the docs we must display a live activity when recording. Also reuse the AudioRecorder that already exists

Updated in bc7f3aa. The implementation now:

  1. Displays Live Activity during recording - Shows recording progress with elapsed time on Lock Screen/Dynamic Island (required by AudioRecordingIntent docs)
  2. Uses audio settings matching existing AudioRecorder - Changed to 16kHz mono PCM (same as Home Assistant Assist AudioRecorder) instead of 44.1kHz stereo

The AudioRecordingIntent uses AVAudioRecorder to save to file (similar to WatchAudioRecorder pattern), while the main App/Assist AudioRecorder uses AVCaptureSession for streaming. Both approaches are appropriate for their use cases.

Copilot AI changed the title Add AudioRecordingIntent sample implementation Add AudioRecordingIntent sample implementation with Live Activity Dec 11, 2025
@bgoncal bgoncal closed this Dec 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants