That sounds like a really interesting problem. You'd need microphones good enough, small enough, and cheap enough to hear the signal,
Signals processing/machine learning software robust enough to pick up a user-selected pattern and in a reasonable latency, and then a processor small enough and power efficient enough to process it all while again also being economical enough, and then have it last 8 hours.
"Completely blocking out" is out of reach, technologically; you'd need 80+ dB of attenuation, and the best anyone can do with things that fit around your head (earplugs, noise-canceling, etc.) is about 40, before you even start to touch the questions of selectivity and power usage. If you need 80 dB of attenuation your best bet is to contract an acoustics engineer to build a wall out of several layers of different materials.
Part of snoring is low frequency sounds, which even with fully plugged ears, transmits through bone conduction.
also long term use of ear plugs with sleeping can cause unwanted side-effects.
When we sleep our hearing system does not turn off (safety), and when you wear ear plugs while sleeping you run the risk of making your hearing work harder - and then if you have no plugs in your hearing system is now (hopefully temporarily) more sensitive than before.
I've got a product similar to these and they're great. You can have a normal conversation and it didn't take me long to realize their eavesdropping potential. My Surface headphones also have a feature that more or less acts as a hearing aid.
Some years ago there was a set of headphones sold for hunting (amplifying sounds of animals and reducing gunshot noise) that were very popular among the hearing-impaired community as a cheaper alternative to hearing aids.