Changeset 2052 for pjproject/trunk/pjsip-apps/src/test-pjsua/mod_pesq.py
- Timestamp:
- Jun 25, 2008 6:18:32 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip-apps/src/test-pjsua/mod_pesq.py
r2038 r2052 39 39 # Test body function 40 40 def test_func(t, user_data): 41 # module debugging purpose42 #user_data.pesq_sample_rate_opt = "+16000"43 #user_data.input_filename = "wavs/input.16.wav"44 #user_data.output_filename = "wavs/tmp.16.wav"45 #return46 47 41 ua1 = t.process[0] 48 42 ua2 = t.process[1] 49 43 50 # Get conference clock rate of UA2 for PESQ sample rate option51 ua2.send("cl")52 clock_rate_line = ua2.expect("Port \#00\[\d+KHz")53 if (clock_rate_line == None):54 raise TestError("Failed getting")55 clock_rate = re.match("Port \#00\[(\d+)KHz", clock_rate_line).group(1)56 user_data.pesq_sample_rate_opt = "+" + clock_rate + "000"57 58 44 # Get input file name 59 ua1.sync_stdout() 60 ua1.send("dc") 61 line = ua1.expect(const.MEDIA_PLAY_FILE) 62 user_data.input_filename = re.compile(const.MEDIA_PLAY_FILE).match(line).group(1) 45 user_data.input_filename = re.compile(const.MEDIA_PLAY_FILE).search(ua1.inst_param.arg).group(1) 63 46 64 47 # Get output file name 65 ua2.sync_stdout() 66 ua2.send("dc") 67 line = ua2.expect(const.MEDIA_REC_FILE) 68 user_data.output_filename = re.compile(const.MEDIA_REC_FILE).match(line).group(1) 48 user_data.output_filename = re.compile(const.MEDIA_REC_FILE).search(ua2.inst_param.arg).group(1) 69 49 70 50 # Find appropriate clock rate for the input file 71 clock_rate = re.compile(".+(\.\d+\.wav)$").match(user_data.output_filename)72 if ( clock_rate==None):51 mo_clock_rate = re.compile("\.(\d+)\.wav").search(user_data.output_filename) 52 if (mo_clock_rate==None): 73 53 raise TestError("Cannot compare input & output, incorrect output filename format") 74 user_data.input_filename = re.sub("\.\d+\.wav$", clock_rate.group(1), user_data.input_filename) 54 clock_rate = mo_clock_rate.group(1) 55 user_data.input_filename = re.sub("\.\d+\.wav", "."+clock_rate+".wav", user_data.input_filename) 75 56 76 time.sleep(1) 77 ua1.sync_stdout() 78 ua2.sync_stdout() 57 if (clock_rate != "8") & (clock_rate != "16"): 58 raise TestError("PESQ only works on clock rate 8kHz or 16kHz, clock rate used = "+clock_rate+ "kHz") 59 60 # Get conference clock rate of UA2 for PESQ sample rate option 61 user_data.pesq_sample_rate_opt = "+" + clock_rate + "000" 79 62 80 63 # UA1 making call … … 82 65 ua1.send(t.inst_params[1].uri) 83 66 ua1.expect(const.STATE_CALLING) 84 67 ua2.expect(const.STATE_CONFIRMED) 68 69 # Disconnect mic -> rec file to avoid echo recorded when using sound device 70 ua2.send("cd 0 1") 71 85 72 # Auto answer, auto play, auto hangup 86 73 # Just wait for call disconnected 87 88 if ua1.expect(const.STATE_CONFIRMED, False)==None: 89 raise TestError("Call failed") 90 ua2.expect(const.STATE_CONFIRMED) 91 92 while True: 74 # Assumed WAV input is no more than 30 secs 75 while 1: 93 76 line = ua2.proc.stdout.readline() 94 77 if line == "": 95 78 raise TestError(ua2.name + ": Premature EOF") 79 96 80 # Search for disconnected text 97 81 if re.search(const.STATE_DISCONNECTED, line) != None: … … 116 100 # Evaluate the similarity value 117 101 pesq_res = mo_pesq_out.group(1) 118 if ( pesq_res>= PESQ_THRESHOLD):102 if (float(pesq_res) >= PESQ_THRESHOLD): 119 103 endpt.trace("Success, PESQ result=" + pesq_res) 120 104 else:
Note: See TracChangeset
for help on using the changeset viewer.