private int iterationResult; // Stores result of iteration #endregion Fields #region Constructors /// <summary> /// Class constructor /// </summary> /// <param name="_iterationResult"></param> /// <param name="_category"></param> /// <param name="_callerData"></param> /// <param name="_calleeData"></param> /// <param name="_spResult"></param> private IterationResult(int _iterationResult, CallerIterationInfo _callerData, CalleeIterationInfo _calleeData, SpeechRecognizerResult _callerSpResult, SpeechRecognizerResult _calleeSpResult) { iterationResult = _iterationResult; callerData = _callerData; calleeData = _calleeData; callerSpeechResult = _callerSpResult; calleeSpeechResult = _calleeSpResult; audioPowerResult = AudioVolume.NOT_ATTENUATED; audioVolConf = AudioVolumeConfidence.GOOD_CONFIDENCE; // determine the classification (category) for IterationResult if (iterationResult == ValidationErrors.NO_ERROR) category = TestIterationCategory.PASSED; else if (conditionExists(iterationResult, ValidationErrors.FAILED_CALL) || conditionExists(iterationResult, ValidationErrors.MISSING_HANGUP) || conditionExists(iterationResult, ValidationErrors.ECHO_DETECTED) || conditionExists(iterationResult, ValidationErrors.CALLER_NOISE_DETECTED) || conditionExists(iterationResult, ValidationErrors.CALLEE_NOISE_DETECTED) || conditionExists(iterationResult, ValidationErrors.CALLEE_NOT_HEARD) || conditionExists(iterationResult, ValidationErrors.CALLER_NOT_HEARD)) category = TestIterationCategory.FAILED; //if(iterationResult == ValidationErrors.FAILED_CALL || iterationResult == ValidationErrors.NOISE_DETECTED || iterationResult == ValidationErrors.ECHO_DETECTED) // category = TestIterationCategory.FAILED; else { // Use invalid for all others errors such as callee could not play prompt, execution error etc category = TestIterationCategory.INVALID; } }
/// <summary> /// Private helper method to analyze if the recorded wav file has audio signal volume loss by comparing it with the /// played audio wav file. /// </summary> /// <param name="filePlayed"></param> /// <param name="fileRecorded"></param> /// <param name="audioVolConf"></param> /// <returns></returns> private AudioVolume isSignalAttenuated(string filePlayed, string fileRecorded, out AudioVolumeConfidence audioVolConf) { AudioVolume result = AudioVolume.NOT_ATTENUATED; audioVolConf = AudioVolumeConfidence.GOOD_CONFIDENCE; // The tolerance represents the % difference between the number of frames used to compute // average power between the played and the recorded files. // If the number of frames used to compute the average power differs more than the threshold, // then it implies that the audio waveform could be different, and hence, should not be analyzed // for signal attenuation, since the answer would not be reliable. double tolerance = 0.1; // Represents the minimum difference in power levels between the recorded and the played files that should be // considered to flag audio signal attenuation warning double powerThreshold = 6.0; WavDataCharacteristics wdRec = WavFile.getInstance(fileRecorded).analyzeData(); WavDataCharacteristics wdPlayed = WavFile.getInstance(filePlayed).analyzeData(); double pRec = wdRec.AveragePower; double fRec = Convert.ToDouble(wdRec.NumFramesForAvgPower); double pPlayed = wdPlayed.AveragePower; double fPlayed = Convert.ToDouble(wdPlayed.NumFramesForAvgPower); /** * If the difference in the power levels between the played file and the recorded exceeds the power threshold, * it implies signal attenuation. Thus, in this case, we determine the confidence level of the algorithm. * If the number of frames used to compute the average power in the recorded file is more than the number of frames used to * compute the average power from the played file, it implies distortion of the recorded file. Thus, we set the confidence level * of the algorithm to "LOW". To determine the confidence level, if the number of frames used to compute avg. power in the recorded * file exceeds the number of frames used to compute avg. power in the played file by a threshold percentage, we set the confidence * level to "low", or set the confidence level to "Good" otherwise. */ if (pPlayed - pRec >= powerThreshold) { Console.WriteLine("Power Level of Played File = " + pPlayed + " Power Level of Recorded File = " + pRec + " . Flagging Signal Attenuation Warning"); result = AudioVolume.ATTENUATED; if (fRec > fPlayed + tolerance * fPlayed) { audioVolConf = AudioVolumeConfidence.LOW_CONFIDENCE; } else { audioVolConf = AudioVolumeConfidence.GOOD_CONFIDENCE; } } else { result = AudioVolume.NOT_ATTENUATED; } return result; }