The short answer is that you can’t. At the time of writing there isn’t a way to reliably detect whether someone visiting your site is using a screen reader (or screen magnifier). You might have heard that Flash will do the trick, but that might not be quite the solution you’re expecting.
People often ask whether it’s possible to automatically detect screen readers or other access technologies. The thought is that it would make it possible to deliver content in a way most appropriate for the given audience. Whether this is adviseable or not is a discussion for another day. For the time being at least, it’s a moot point in any case.
Screen readers (or magnifiers) don’t have user agent strings of their own. They work on top of the browser, so as far as your website’s concerned it’s dealing with the browser and that’s that. Well…. Almost.
Several Windows screen readers (and magnifiers) make use of the Microsoft Active Accessibility (MSAA) layer. It’s an API that enables access technologies to interact with standard and custom UI objects. It’s the MSAA layer that’s the basis of the Flash technique you’ve heard about.
Apart from the (obvious) fact that you need Flash to begin with, this technique is completely indiscriminate. It can only detect applications that use MSAA. It can’t tell the difference between a screen reader, screen magnifier, or a speech recognition application (and if you’re thinking about automatically serving up tailored content that’s a train crash waiting to happen)!
It's also a Windows based solution, completely oblivious to the growing numbers of screen readers and magnifiers used on Linux, Mac and other platforms. Another point worth noting is that not all Windows based screen readers use MSAA to begin with.
So if you were hoping to discover how to detect screen readers and other access technologies, I'm sorry to disappoint. In the meantime, your best bet is to stick to well structured, standards compliant and inclusive content delivery!