Aslamu Alaykum. I was once praying and I made the sin of riya by beautifing my voice for someone elee that was not Allah during that salah. I did this before I found out what riya actually is as I did not know at the time that there was a ruling regarding riya. This was a long time ago and I gained more knowlege and I repented from it Alhamdulilah. Should I repeat that salah or am I excused for not knowing the ruling until much later because I was ignorant about riya and I was not intending to do such a sin?
All perfect praise be to Allah, The Lord of the Worlds. I testify that there is none worthy of worship except Allah, and that Muhammad is His slave and Messenger.
If your intention behind improving your voice while reciting the Quran was to benefit the person who was listening to you and not to impress him to praise you for your good voice, for example, this is not considered Riya’ (Showing-off). It was authentically narrated that the Prophet, sallallaahu 'alayhi wa sallam, listened to the recitation of Abu Musa Al-Ash`ari who was known for his good voice.
However, if your intention behind improving your voice was to be praised by the person you mentioned, this is considered Riya’, but you will not be considered sinful because you are excused due to ignorance, as you did not commit Riya’ intentionally. Allah, the Almighty, says: {Allah does not impose blame upon you for what is unintentional in your oaths, but He imposes blame upon you for what your hearts have earned. And Allah is Forgiving and Forbearing.} [Quran 2: 225]
As for your prayer, it is valid and you are not required to repeat it.
Allah knows best.
You can search for fatwa through many choices