I could tell you more accurately if I were riding with you and could hear the noise and where it came from. But, I can tell you these things for certain:
Clean and lube your pedal bearings. Do not skimp and just add some oil. Also make sure your pedals and crankarms are tightened to the correct recommended torque.
Do not delay before applying these maintenance measures. I say "do not delay" because the cause could be that the crankarms are not torqued down properly. This is not likely, but it is possible, and if it is the reason? Then you can ruin the crankset within a few miles of riding. That's right - ruin - to the point of a crankarm or the crank spider cracking and eventually breaking. If it cracks you will see it happening - and it won't be sudden - so in that way it is not unsafe, ok? But it will be relatively expensive to fix.
So the first thing you need to do is to make sure the moving parts involved (pedals, crankarms, bottom bracket) have proper maintenance and lubrication. Your problem is likely somewhere in there.