Changeset 2063 for pjproject/trunk/pjsip-apps/src/test-pjsua/mod_pesq.py
- Timestamp:
- Jun 26, 2008 6:52:16 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip-apps/src/test-pjsua/mod_pesq.py
r2057 r2063 16 16 import re 17 17 import subprocess 18 import wave 18 19 import inc_const as const 19 20 … … 26 27 # PESQ_THRESHOLD specifies the minimum acceptable PESQ MOS value, so test can be declared successful 27 28 PESQ = "tools/pesq.exe" 28 PESQ_ THRESHOLD = 3.029 PESQ_DEFAULT_THRESHOLD = 3.4 29 30 30 31 # UserData … … 39 40 # Test body function 40 41 def test_func(t, user_data): 41 42 if len(t.process) == 0:43 return44 42 45 43 ua1 = t.process[0] … … 65 63 user_data.pesq_sample_rate_opt = "+" + clock_rate + "000" 66 64 65 # Get WAV input length, in seconds 66 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 + 1 72 fin.close() 73 67 74 # UA1 making call 68 75 ua1.send("m") 69 76 ua1.send(t.inst_params[1].uri) 70 77 ua1.expect(const.STATE_CALLING) 78 79 # UA2 wait until call established 71 80 ua2.expect(const.STATE_CONFIRMED) 72 81 73 # Disconnect mic -> rec file to avoid echo recorded when using sound device 74 ua2.send("cd 0 1") 82 # Disconnect mic -> rec file, to avoid echo recorded when using sound device 83 # Disconnect stream -> spk, make it silent 84 # Connect stream -> rec file, start recording 85 ua2.send("cd 0 1\ncd 4 0\ncc 4 1") 75 86 76 # Auto answer, auto play, auto hangup 77 # Just wait for call disconnected 78 # Assumed WAV input is no more than 30 secs 79 while 1: 80 line = ua2.proc.stdout.readline() 81 if line == "": 82 raise TestError(ua2.name + ": Premature EOF") 87 # Disconnect mic -> stream, make stream purely sending from file 88 # Disconnect stream -> spk, make it silent 89 # Connect file -> stream, start sending 90 ua1.send("cd 0 4\ncd 4 0\ncc 1 4") 83 91 84 # Search for disconnected text 85 if re.search(const.STATE_DISCONNECTED, line) != None: 86 break 87 92 time.sleep(inwavlen) 93 94 # Disconnect files from bridge 95 ua2.send("cd 4 1") 96 ua2.expect(const.MEDIA_DISCONN_PORT_SUCCESS) 97 ua1.send("cd 1 4") 98 ua1.expect(const.MEDIA_DISCONN_PORT_SUCCESS) 99 88 100 89 101 # Post body function … … 102 114 raise TestError("Failed to fetch PESQ result") 103 115 104 # Evaluate the similarity value 116 # Get threshold 117 if (cfg_file.pesq_threshold != None) | (cfg_file.pesq_threshold > -0.5 ): 118 threshold = cfg_file.pesq_threshold 119 else: 120 threshold = PESQ_DEFAULT_THRESHOLD 121 122 # Evaluate the PESQ MOS value 105 123 pesq_res = mo_pesq_out.group(1) 106 if (float(pesq_res) >= PESQ_THRESHOLD):124 if (float(pesq_res) >= threshold): 107 125 endpt.trace("Success, PESQ result = " + pesq_res) 108 126 else:
Note: See TracChangeset
for help on using the changeset viewer.