Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Concept of Assist on Apple Watch #2400

Closed
wants to merge 29 commits into from

Conversation

bgoncal
Copy link
Member

@bgoncal bgoncal commented Aug 20, 2023

Summary

Goal:

  • Use Assist on an intuitive way in Apple Watch

Achieved on this PR:

  • Conversation with Assist is working

Challenge:

  • Since SFSpeechRecognizer is not available on the watchOS I have use (for demonstration purposes) the keyboard dictation, which is not good since you need extra taps. One alternative could be record the audio in the Apple Watch and process over the iPhone, but performance would need to be tested.
    -> I am now recording the audio on watchOS and processing it on iOS

Also pending:

  • Having to open the app to trigger Assist is not ideal, so the best we could do in watchOS (considering Apple limitations) is to provide a complication that directly opens Assist. (Done ✔️ check third demo video)
  • Depending on how important the minimum watchOS version requirement is currently, we could drop support to a few versions so we can refactor the code and maybe even use swiftUI to simplify navigation and interaction.

~Why not demo it on a real Apple Watch?

  • Currently my devices are running iOS and watchOS beta's and I couldn't make them quickly work with home assistant project yet.
    -> I have added a new demo video showing it working on a real device + fully by voice (currently you still need to "end" the session manually)

Screenshots

assist-low.mov
IMG_0524-low.mov
123-low-2.mov

@codecov
Copy link

codecov bot commented Aug 20, 2023

Codecov Report

Merging #2400 (fb5bd42) into master (1df0738) will increase coverage by 0.12%.
The diff coverage is 23.88%.

❗ Current head fb5bd42 differs from pull request most recent head cc4a95e. Consider uploading reports for the commit cc4a95e to get more accurate results

@@            Coverage Diff             @@
##           master    #2400      +/-   ##
==========================================
+ Coverage   28.05%   28.17%   +0.12%     
==========================================
  Files         273      277       +4     
  Lines       30232    30337     +105     
==========================================
+ Hits         8481     8548      +67     
- Misses      21751    21789      +38     
Files Coverage Δ
Sources/Shared/API/WatchHelpers.swift 21.68% <ø> (+14.45%) ⬆️
...Media and CoreAudio Helpers/HACoreBlahObject.swift 0.00% <ø> (ø)
.../API/Webhook/Sensors/InputOutputDeviceSensor.swift 67.16% <75.00%> (ø)
Sources/Shared/Environment/Environment.swift 68.38% <72.72%> (+0.18%) ⬆️
Sources/Shared/Intents/AssistIntentHandler.swift 0.00% <0.00%> (ø)
Sources/App/WebView/WebViewController.swift 0.00% <0.00%> (ø)
Sources/Shared/Watch/WatchAssistService.swift 86.11% <86.11%> (ø)
Sources/App/AppDelegate.swift 8.62% <0.00%> (+0.48%) ⬆️
Sources/Shared/Watch/WatchPushActionService.swift 0.00% <0.00%> (ø)
Sources/Shared/Watch/WatchActionService.swift 0.00% <0.00%> (ø)
... and 2 more

... and 10 files with indirect coverage changes

@bgoncal
Copy link
Member Author

bgoncal commented Aug 20, 2023

Also, another todo item that just popped on my mind is to try to use Apple Watch Ultra action button to open Assist directly

@bgoncal
Copy link
Member Author

bgoncal commented Aug 25, 2023

I had great progress on this concept, now you are able to use just voice even though watchOS can't transcribe locally, it sends the audio file to iPhone and then it is processed there. The performance is great, I will add a video below.

IMG_0524-low.mov

@bgoncal
Copy link
Member Author

bgoncal commented Aug 27, 2023

I did one more iteration, now it is possible to launch assist via complication and also it automatically stops recording on silence.

123-low-2.mov

@bgoncal
Copy link
Member Author

bgoncal commented Aug 28, 2023

I have moved all watch actions that were handled in App Delegate to a specific service for it's type, sharing the same protocol.

@jrspowers
Copy link

Hallo, kan ik deze app ergens testen voor Apple Watch? Dit is erg handig!

@bgoncal
Copy link
Member Author

bgoncal commented Sep 19, 2023

Hallo, kan ik deze app ergens testen voor Apple Watch? Dit is erg handig!

Hey, if you know how to compile an iOS app you can try right away using this branch, otherwise I still need to find time to wrap it up and check with Nabu Casa if the feature matches their expectations (since Android already has it, I would need to align the UI and behavior)

@bgoncal bgoncal marked this pull request as draft November 2, 2023 08:31
@bgoncal bgoncal self-assigned this Nov 2, 2023
@bgoncal bgoncal force-pushed the assist-apple-watch branch from 3e7f414 to bdfeed7 Compare November 7, 2023 09:09
@bgoncal
Copy link
Member Author

bgoncal commented Nov 13, 2023

Update on it's speed launching from complication. Next step: launch from action button (Apple Watch Ultra) and allow selecting pipeline wanted to use.
https://github.com/home-assistant/iOS/assets/5808343/08194e6f-4a3f-4bdb-b0c1-c00f0ddf1916

@bgoncal
Copy link
Member Author

bgoncal commented Nov 14, 2023

I'm closing this draft PR, I will open another one based on this but using HA Assist pipeline directly through HA Websocket API

@bgoncal bgoncal closed this Nov 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants