I am trying to create a personal reminder for myself using the Speak function in Mathematica hoping that the computer speaks the task only once at the designated time. However, I have found that the note is played five times before ending. Is there a way to ensure that the note is spoken once. Kindly find the code below:

Reminder[association_] := 
Module[{keys = association // Keys, vals = association // Values},
If[Flatten@# != {} , Speak[ToString@(vals[[Flatten@#]])], ""] &@Position[keys, (DateString[]//DateObject)] ]

Dynamic[{Reminder[Association[(StringSplit["2016-2-2-19-14-40", "-"] // 
    ToExpression // DateObject) -> "30 minutes remaining for incubation",
(StringSplit["2016-2-2-20-46-20", "-"] //ToExpression//DateObject) -> "20 minutes
remaining for incubation"]], Clock[{1, 1}, 1]}]
  • 1
    $\begingroup$ Have you considered something simpler, such as RunScheduledTask[Speak["Test"]; RemoveScheduledTask[$ScheduledTask], {0}, AbsoluteTime[] + 5 (* seconds *)] ? $\endgroup$ – kirma Feb 3 '16 at 5:55
  • $\begingroup$ Interesting, I will look into what you have written. I am interested in why the message is played more than once with the code that i have posted. any suggestions? $\endgroup$ – Ali Hashmi Feb 3 '16 at 17:51
  • $\begingroup$ I have a list of tasks and i really do not have an idea why it repeats even if i try to replace my current code with yours $\endgroup$ – Ali Hashmi Feb 10 '16 at 7:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.