UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

How can I use speech synthesis as an alarm?

Forums > Swift

I made a speaking alarm clock using iOS Shortcuts. It reads out a hard coded string using the 'speak text' function, and I used the Shortcuts automation feature to have it run every morning at a specified time. In the automation settings, I was able to turn off 'ask before running', so that I don't have to do anything for it to work, even if the device is asleep. It reads out the string every morning all by itself.

I am having a hard time figuring out how to achieve the same functionality in Swift/SwiftUI using AVSpeechSynthesizer and background tasks like appRefresh. Every solution seems to somehow require the user to interact with the device - by tapping a notification, for example. Obviously an alarm clock that doesn't make any sound until you tap the screen is pretty useless. If anyone could shed some light on a possible solution here, or what Shortcuts is doing under the hood to make the automation happen, it would be extremely appreciated!

Thanks for any insight and for taking the time to read.

2      

TAKE YOUR SKILLS TO THE NEXT LEVEL If you like Hacking with Swift, you'll love Hacking with Swift+ – it's my premium service where you can learn advanced Swift and SwiftUI, functional programming, algorithms, and more. Plus it comes with stacks of benefits, including monthly live streams, downloadable projects, a 20% discount on all books, and free gifts!

Find out more

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.