There are a couple of things it could be.
• A wire broken inside the cable.
• A loose wire in the pedal.
• A failing rheostat in the pedal (the part that varies the voltage to the motor on older machines)
• A failing capacitor inside the pedal (newer machines).
All these can be tested without having to connect the cable to an electrical outlet, using a cheap digital multimeter (eBay, Amazon – something like
https://www.amazon.com/dp/B07R39SQWH/)