Both are correct. You can think of it as a basic expression
"afraid of". After the "of" you can put a noun or a gerund
(
-ing word).
afraid of snakes
afraid of spiders
afraid of speaking to strangers
afraid of running across the road
afraid of eating okra
But when you use an infinitive (
to and a verb) after "afraid of" you must remove the "of".
afraid to speak to strangers
afraid to run across the road
afraid to eat okra
The meaning is the same whether you use "of" and the gerund or whether you remove "of" and use the infinitive.
CJ