Set volume recording level for HTML5 audio element

Does anyone know how to set the volume for recording audio when using the HTML5 audio element? I know you can set the volume for playing the audio, but I need to set it for recording. Currently when I record audio using a headset, the volume when playing back is too loud.

For my project, the audio element is in a .NET web application. I’m using Matt Diamond’s recorder.js logic. Is there a way to set the recording volume using Javascript (or even in the code using Sox)? Or does the recording volume level depend upon the volume level the user has set on their computer?

var player = document.getElementById(‘player’).volume=‘1.0’;

Thanks for such a prompt response! That will set the volume level for recording? Or does that only set the volume level for playing back the audio? Once the audio is recorded the files are provided to another application which does not use the HTML5 audio controls. So I need to be able to set the volume level when the user records.

I’m not sure there’s an option available, nor do I think that’s really the right approach since everyone has different settings to start with.

I would suggest that you have a small step in between where the user could review the recording before actually submitting it? That would allow the user to adjust the volume on their microphone and redo it.

2 Likes

I wasn’t sure if it was possible either. Everything I’ve read refers to setting the volume when playing the audio back. Due to the nature of the application that will be playing the files, the volume needs to be about the same level for all files…which btw are recorded by different users.

We do use SoX to normalize the audio prior to providing the files to the other application. I’ve been trying some volume adjustments in the code with the SoX commands, but have not had much luck.

Currently we’re using the Nanogong applet for recording, in which the volume sounds fine and does not appear to have the same issue as the HTML5 audio element. However, with the NPAPI plugin being phased out we have to find an alternative to the applet.

The users can playback and re-record the audio as many times as they want before submitting. A different set of users reviews the audio files and gives the final approval.

I was hoping for an alternative other than having the user adjust their volume levels as it would be better if it could be done programmatically rather than put the onus on them. :slight_smile:

It’s ‘possible’ that the Web Audio API may offer something for your needs, though I still don’t see anything for the recording aspect - it looks like an audio file would need to be uploaded first.

The Web Audio API provides a simple yet powerful mechanism to implement and manipulate audio content inside web applications. It allows you to develop complex audio mixing, effects, panning and more. In this article we will explain the basics of using the Web Audio API, via a couple of fairly simple examples.

I don’t think it’s possible. In fact, I did a quick search, and while you can apparently raise or lower it, there’s no way to autolevel it.

I have to agree. I’ve done a lot of searches, but have only found ways to adjust the playback of the audio. It’s possible to set the gain via JavaScript to prevent feedback during recording, but I’ve not been able to find anything related to setting the volume level.

I’ve not worked a whole lot with audio though so I figured it was worth a shot to ask to see if someone else might know of a way.

I appreciate everyone’s feedback!

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.