Lag in microphone playback in speakers

I needed to hear the audio of my microphone from the loudspeakers connected to my pc…
I got the desired result with the following command:

arecord -l
arecord -D hw:0,0 -f dat | aplay

What I would like to correct now is a delay in the reproduction of the audio compared to the output of my voice.

I think the buffer needs to be set in arecord / aplay command-line, but I have no idea of the correct code that should be used.

These are my devices:

aplay -l                                                                                                                 ✔ 
**** List of PLAYBACK Hardware Devices ****
card 0: PCH [HDA Intel PCH], device 0: ALC891 Analog [ALC891 Analog]
  Subdevices: 1/1

arecord -l                                                                                                               ✔ 
**** List of CAPTURE Hardware Devices ****
card 0: PCH [HDA Intel PCH], device 0: ALC891 Analog [ALC891 Analog]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 2: ALC891 Alt Analog [ALC891 Alt Analog]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

Welcome to Manjaro forum

Onboard audio devices usually have zero latency monitoring of audio capture inputs in ALSA

Check ALSA audio settings:

amixer -c0

OR if you prefer to adjust audio controls manually:

sudo alsamixer -c0 --view=playback

Some audio codecs have a control switch for Loopback Mixing like this:

Simple mixer control 'Loopback Mixing',0
  Capabilities: enum
  Items: 'Disabled' 'Enabled'
  Item0: 'Disabled'

use this command to turn it on

amixer -c PCH sset 'Loopback Mixing' Enabled

All audio codecs usually have playback controls for monitoring audio inputs like this:

Simple mixer control 'Front Mic',0
  Capabilities: pvolume pswitch cswitch cswitch-joined cswitch-exclusive
  Capture exclusive group: 0
  Playback channels: Front Left - Front Right
  Capture channels: Mono
  Limits: Playback 0 - 31
  Mono: Capture [on]
  Front Left: Playback 0 [0%] [-34.50dB] [off]
  Front Right: Playback 0 [0%] [-34.50dB] [off]

Use this command to unmute monitor control and set level low to avoid feedback between speakers and mic

amixer -c PCH sset 'Front Mic' 50% unmute