Automating the audio call quality with Selenium WebDriver and Python

2,843 views
Skip to first unread message

Rakesh Mishra

unread,
Jan 18, 2016, 3:32:55 AM1/18/16
to discuss-webrtc
I am new to WebRTC, We have web portal which allows to make call browser to browser. Need to automate the making call process and analysis the call quality. 
Able to automate the call making process using selenium with python binding. But stuck at call analysis part. 

Let me explain the automation process so far I automated: 
I opening two Chrome incognito instances and entering the  required setting on both the chrome instances, enter the number of second browser to first and hit the call button. 
the line is get connected. 

Idea for testing the audio quality: - from microphone speak simple sentence like "Hello Welcome", to record I running the PyAudio script to capture the audio. for another instance I am running another PyAudio Script to capture the audio from speaker. but it is failing keep throwing the bad channel  below is the code:
{
def record_music_speaker(self):
        CHUNK = 1024
        FORMAT = pyaudio.paInt16
        CHANNELS = 2
        RATE = 44100
        RECORD_SECONDS = 10
        WAVE_OUTPUT_FILENAME = "output.wav"
        
        p = pyaudio.PyAudio()
        
        for i in range(0, p.get_device_count()):
            print(i, p.get_device_info_by_index(i)['name'])

        device_index = int(input('Device index: '))
        
        stream = p.open(format=FORMAT,
                        channels=CHANNELS,
                        rate=RATE,
                        input=True,
                        frames_per_buffer=CHUNK,
                        input_device_index=device_index)
        
        print("* Speaker recording")
        
        frames = []
        
        for i in range(0, int(RATE / CHUNK * RECORD_SECONDS)):
            data = stream.read(CHUNK)
            frames.append(data)
        
        print("* Speaker done recording")
        
        stream.stop_stream()
        stream.close()
        p.terminate()
        
        wf = wave.open(WAVE_OUTPUT_FILENAME, 'wb')
        wf.setnchannels(CHANNELS)
        wf.setsampwidth(p.get_sample_size(FORMAT))
        wf.setframerate(RATE)
        wf.writeframes(b''.join(frames))
        wf.close()
}
Below are the devices index 
(0, u'Microsoft Sound Mapper - Input')
(1, u'External Mic (Realtek High Defi')
(2, u'Microphone (Realtek High Defini')
(3, u'Microsoft Sound Mapper - Output')
(4, u'Realtek HD Audio 2nd output (Re')
(5, u'Speaker/HP (Realtek High Defini')

When ever I used 5 it throws below:
{
 stream = Stream(self, *args, **kwargs)
  File "C:\Python27\lib\site-packages\pyaudio.py", line 441, in __init__
    self._stream = pa.open(**arguments)
IOError: [Errno -9998] Invalid number of channels
}

Any suggestion here to resolve the issue or better idea to do it 

Thanks,
Rakesh

Christoffer Jansson

unread,
Jan 18, 2016, 4:46:54 AM1/18/16
to discuss-webrtc
Hi,

Not sure this is the best approach for this but with regard to your error, have you tried change the channels to 1?

Doing a quick search it seems like there can be some issues with channels on output devices.

/Chris

--

---
You received this message because you are subscribed to the Google Groups "discuss-webrtc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to discuss-webrt...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/discuss-webrtc/4d7961bd-83b2-4409-b286-00cb0597abe7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Philipp Hancke

unread,
Jan 18, 2016, 10:58:17 AM1/18/16
to discuss...@googlegroups.com
2016-01-18 1:46 GMT-08:00 'Christoffer Jansson' via discuss-webrtc <discuss...@googlegroups.com>:
Hi,

Not sure this is the best approach for this but with regard to your error, have you tried change the channels to 1?

Doing a quick search it seems like there can be some issues with channels on output devices.

/Chris

On Mon, Jan 18, 2016 at 9:32 AM Rakesh Mishra <festiv...@gmail.com> wrote:
I am new to WebRTC, We have web portal which allows to make call browser to browser. Need to automate the making call process and analysis the call quality. 
Able to automate the call making process using selenium with python binding. But stuck at call analysis part. 

Let me explain the automation process so far I automated: 
I opening two Chrome incognito instances and entering the  required setting on both the chrome instances, enter the number of second browser to first and hit the call button. 
the line is get connected. 

Idea for testing the audio quality: - from microphone speak simple sentence like "Hello Welcome"

You might want to use the --use-file-for-fake-audio-capture flags instead. See http://googletesting.blogspot.com/2015/10/audio-testing-automatic-gain-control.html
Instead of recording audio at the receiver, it might be possible to use the aec dumps from chrome://webrtc-internals. It should be possible to automate the download of those using selenium. Alternative, MediaStreamRecorder should now work with remote streams so you can record at the remote end and compare that to the original input file.


Reply all
Reply to author
Forward
0 new messages