Test the speaker by using the phones diagnostic tool.
In the phone app choose the dialer and type in *#0*# and use the test speaker .
If it's definitely not working and it's not been dropped or had water damage then a Samsung Experience Store or Samsung Service Centre can run a diagnostic on the phone.
To add if the phone was supplied by a network then they may offer a 30 day cooling off period to swap it out.
Check the Terms and Conditions.
Current Phone ~
Samsung Note 20 Ultra 5G SM-9820 _256Gb SnapDragon 865+
Samsung One Ui 2.5/ Android 10.