Personally I would have at least two emtter/receiver setups in the pipe as far apart as possible, so that as objects pass through, the microcontroller "sees" the breaks, and measures the time between them, then calculates speed.
If you can use at least two pairs so that the smallest object will break at least one of them, that would be better. You will have to have the software based on hardware interrupts that disable the redundant ones as soon as the first is broken.