Follow the steps as given below:
- Go to Settings -> Battery
- Tap on the top right 3-dot menu, and choose Battery Optimisation.
- There should be a dropdown below the actionbar on the top left, choose All Apps from the list.
- Find Voice Recorder app in the list
- Tap on it. You will get a popup with 2 options, Optimise and Don't Optimise
- Select "Don't Optimise" (as on image), and press "Done" below.