Changeset 2075 for pjproject/trunk/pjsip-apps/src/test-pjsua/mod_pesq.py
- Timestamp:
- Jun 27, 2008 4:18:13 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip-apps/src/test-pjsua/mod_pesq.py
r2063 r2075 50 50 user_data.output_filename = re.compile(const.MEDIA_REC_FILE).search(ua2.inst_param.arg).group(1) 51 51 52 # Find appropriate clock rate for the input file 52 # Get WAV input length, in seconds 53 fin = wave.open(user_data.input_filename, "r") 54 if fin == None: 55 raise TestError("Failed opening input WAV file") 56 inwavlen = fin.getnframes() * 1.0 / fin.getframerate() 57 inwavlen += 0.2 58 fin.close() 59 print "WAV input len = " + str(inwavlen) + "s" 60 61 # Get clock rate of the output 53 62 mo_clock_rate = re.compile("\.(\d+)\.wav").search(user_data.output_filename) 54 63 if (mo_clock_rate==None): 55 64 raise TestError("Cannot compare input & output, incorrect output filename format") 56 65 clock_rate = mo_clock_rate.group(1) 57 user_data.input_filename = re.sub("\.\d+\.wav", "."+clock_rate+".wav", user_data.input_filename) 66 67 # Get channel count of the output 68 channel_count = 1 69 if re.search("--stereo", ua2.inst_param.arg) != None: 70 channel_count = 2 71 72 # Get matched input file from output file 73 # (PESQ evaluates only files whose same clock rate & channel count) 74 if channel_count == 2: 75 if re.search("\.\d+\.\d+\.wav", user_data.input_filename) != None: 76 user_data.input_filename = re.sub("\.\d+\.\d+\.wav", 77 "." + str(channel_count) + "."+clock_rate+".wav", user_data.input_filename) 78 else: 79 user_data.input_filename = re.sub("\.\d+\.wav", 80 "." + str(channel_count) + "."+clock_rate+".wav", user_data.input_filename) 58 81 59 82 if (clock_rate != "8") & (clock_rate != "16"): … … 62 85 # Get conference clock rate of UA2 for PESQ sample rate option 63 86 user_data.pesq_sample_rate_opt = "+" + clock_rate + "000" 64 65 # Get WAV input length, in seconds66 fin = wave.open(user_data.input_filename, "r")67 if fin == None:68 raise TestError("Failed opening input WAV file")69 inwavlen = fin.getnframes() // fin.getframerate()70 if (fin.getnframes() % fin.getframerate()) > 0:71 inwavlen = inwavlen + 172 fin.close()73 87 74 88 # UA1 making call … … 110 124 111 125 # Parse ouput 112 mo_pesq_out = re.compile("Prediction[^=]+=\s+([\ d\.]+)\s*").search(pesq_out[0])126 mo_pesq_out = re.compile("Prediction[^=]+=\s+([\-\d\.]+)\s*").search(pesq_out[0]) 113 127 if (mo_pesq_out == None): 114 128 raise TestError("Failed to fetch PESQ result")
Note: See TracChangeset
for help on using the changeset viewer.