They come in many sizes and shapes but all have some common features such as a threaded base, a spring-loaded test lever and some vents or exhaust ports around the top. This one was also advertised as a whistle and given the size of these two safety valves, they are not likely to even be railroad related. It is, obviously, an air horn, but at least this one makes noise and has a good chance of being from a locomotive. Another misleading thing is the way people refer to the size of a whistle. A whistles size is correctly given by refering to the outside diameter of the bell.
Size can also be a useful idicator of a whistles origin.
Whistles smaller than that are not likely to be of railroad origin although it is possible. However, the smaller they are, the less likely. If you look long enough, you are sure to find an example of an size or kind of whistle in any enviroment. I'm just trying to give you some guidelines. Here's a prime example of what I mean.