Open a TextEdit document with a few words in it. Notice that when you right click on a word, you can click "Look up (Word)" to get its definition or "Speech Start Speaking" to hear it read out aloud.
How can I build a local application to monitor globally whenever a user has requested a dictionary definition or the speech synthesizer?