There are do it yourself kits, but I've yet to do it.
I go to a "ear doctor" in an effort to get a good job done.
They fill your ear with a quick set foam of some sort, feels like toothpaste, then send it off.
There are different ones available, some to block more sounds or frequencies and such, some to accommodate ear phones, etc.
You can hear your machine just fine, in some cases better, because it muffles all the extra clanging and banging going on.
At first it's like a knew pair of shoes, can kinda hurt your ears as they are so full, but you get used to it. You can feel the difference between them and put them in the correct ear, left or right, by feel with a little practice.
If you are going to be around something really noisy you can wear headphones at the same time and block all the harshness.
Get a bright color so you can find them when you drop them.........
They stay in place and don't get pulled out like the foam ones, they don't echo like headphones are prone to