Changeset 2078 for pjproject/trunk/pjsip-apps/src/test-pjsua/mod_pesq.py
- Timestamp:
- Jun 27, 2008 9:12:12 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip-apps/src/test-pjsua/mod_pesq.py
r2075 r2078 22 22 23 23 # Load configuration 24 cfg_file = imp.load_source("cfg_file", sys.argv[2])24 cfg_file = imp.load_source("cfg_file", ARGS[1]) 25 25 26 26 # PESQ configs 27 # PESQ_THRESHOLD specifies the minimum acceptable PESQ MOS value, so test can be declared successful 28 PESQ = "tools/pesq.exe" 29 PESQ_DEFAULT_THRESHOLD = 3.4 27 PESQ = "tools/pesq.exe" # PESQ executable path 28 PESQ_DEFAULT_THRESHOLD = 3.4 # Default minimum acceptable PESQ MOS value 30 29 31 # UserData 32 class mod_pesq_user_data: 33 # Sample rate option for PESQ 34 pesq_sample_rate_opt = "" 35 # Input/Reference filename 36 input_filename = "" 37 # Output/Degraded filename 38 output_filename = "" 30 # PESQ params 31 pesq_sample_rate_opt = "" # Sample rate option for PESQ 32 input_filename = "" # Input/Reference filename 33 output_filename = "" # Output/Degraded filename 34 39 35 40 36 # Test body function 41 def test_func(t, user_data): 37 def test_func(t): 38 global pesq_sample_rate_opt 39 global input_filename 40 global output_filename 42 41 43 42 ua1 = t.process[0] … … 45 44 46 45 # Get input file name 47 user_data.input_filename = re.compile(const.MEDIA_PLAY_FILE).search(ua1.inst_param.arg).group(1)46 input_filename = re.compile(const.MEDIA_PLAY_FILE).search(ua1.inst_param.arg).group(1) 48 47 49 48 # Get output file name 50 user_data.output_filename = re.compile(const.MEDIA_REC_FILE).search(ua2.inst_param.arg).group(1)49 output_filename = re.compile(const.MEDIA_REC_FILE).search(ua2.inst_param.arg).group(1) 51 50 52 51 # Get WAV input length, in seconds 53 fin = wave.open( user_data.input_filename, "r")52 fin = wave.open(input_filename, "r") 54 53 if fin == None: 55 54 raise TestError("Failed opening input WAV file") … … 60 59 61 60 # Get clock rate of the output 62 mo_clock_rate = re.compile("\.(\d+)\.wav").search( user_data.output_filename)61 mo_clock_rate = re.compile("\.(\d+)\.wav").search(output_filename) 63 62 if (mo_clock_rate==None): 64 63 raise TestError("Cannot compare input & output, incorrect output filename format") … … 73 72 # (PESQ evaluates only files whose same clock rate & channel count) 74 73 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) 74 if re.search("\.\d+\.\d+\.wav", input_filename) != None: 75 input_filename = re.sub("\.\d+\.\d+\.wav", "." + str(channel_count) + "."+clock_rate+".wav", input_filename) 78 76 else: 79 user_data.input_filename = re.sub("\.\d+\.wav", 80 "." + str(channel_count) + "."+clock_rate+".wav", user_data.input_filename) 77 input_filename = re.sub("\.\d+\.wav", "." + str(channel_count) + "."+clock_rate+".wav", input_filename) 81 78 82 79 if (clock_rate != "8") & (clock_rate != "16"): … … 84 81 85 82 # Get conference clock rate of UA2 for PESQ sample rate option 86 user_data.pesq_sample_rate_opt = "+" + clock_rate + "000"83 pesq_sample_rate_opt = "+" + clock_rate + "000" 87 84 88 85 # UA1 making call … … 114 111 115 112 # Post body function 116 def post_func(t, user_data): 113 def post_func(t): 114 global pesq_sample_rate_opt 115 global input_filename 116 global output_filename 117 117 118 endpt = t.process[0] 118 119 119 120 # Execute PESQ 120 fullcmd = PESQ + " " + user_data.pesq_sample_rate_opt + " " + user_data.input_filename + " " + user_data.output_filename121 fullcmd = PESQ + " " + pesq_sample_rate_opt + " " + input_filename + " " + output_filename 121 122 endpt.trace("Popen " + fullcmd) 122 123 pesq_proc = subprocess.Popen(fullcmd, stdout=subprocess.PIPE, universal_newlines=True) … … 147 148 test.test_func = test_func 148 149 test.post_func = post_func 149 test.user_data = mod_pesq_user_data()150 150
Note: See TracChangeset
for help on using the changeset viewer.