azureazure-web-app-serviceaudio-recordingnaudioasp.net-core-6.0

BadDeviceId calling waveInOpen , I am using Naudio on .net core 6 and getting error after deploy web app for recording on azure


I created application which is recording audio calls using NAudio .net package c#. It is working fine and it is opening mic for recording on loclhost. But when i deployed my web app on azure server then it is giving error **BadDeviceId calling waveInOpen ** and not recording audios in files, also not opening mic on my system.

WaveInEvent waveIn = new WaveInEvent();
                // Set the desired format for the captured microphone sound
                waveIn.WaveFormat = new WaveFormat(16000, 16, 1);
                
               ;
                //}
                chunkFileName = Path.Combine(path + nameOfFolderUsingDate , "mic" + fileNameCounter + ".wav");               

                micWriteChunk = new WaveFileWriter(chunkFileName, waveIn.WaveFormat);
                //micWriter = new WaveFileWriter(Path.Combine(AppDomain.CurrentDomain.BaseDirectory+ "/Recordings/"+ userName + "/" + nameOfFolderUsingDate, "mic_complete_file.wav"), waveIn.WaveFormat);
                micWriter = new WaveFileWriter(Path.Combine(path + nameOfFolderUsingDate, "mic_complete_file.wav"), waveIn.WaveFormat);

                // AudioChunkRecorder recorder = new AudioChunkRecorder(sampleRate, channels, bitDepth, chunkDurationMs, outputFolder, outputPrefix);

                // Register event handlers for DataAvailable events of both capture instances                
                waveIn.DataAvailable += WaveIn_DataAvailable;


                // Set up the timer to save audio chunks every 3 seconds               
                waveIn.StartRecording();

1.I want to ask what happens for recording and for mic access when i open my web application on browser which is deployed on azure server, will it open mic on my system or is it using some audio devices on server.

2.Also what should i need to do for my app records when i open it on browser, which is deployed on azure server.


Solution

  • Try to imagine our C# code, using the NAudio .net package, and finally compiles the .dll file and deploys it in the server. The web application is opened through a browser and wants to call mic, and the code is executed, but the server mic is called, right? That's why we're having this issue.

    The NAudio .net package is for desktop applications such as WPF.

    In webapplication, we should use Web Audio API. Here is Web Audio API SAMPLE.