From 1b0dfdebfd7f21bd7c82ec9af27c25b5cb4d79d2 Mon Sep 17 00:00:00 2001 From: Aryash123 <119963945+Aryash2003@users.noreply.github.com> Date: Mon, 5 May 2025 23:22:23 +0530 Subject: [PATCH 1/2] Update voice_banking_test_suite.py --- .../voice_banking_test_suite.py | 36 +++++++++++++++---- 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/voice_driven_banking/voice_banking_test_suite.py b/voice_driven_banking/voice_banking_test_suite.py index 5f327f84..c7e3fce4 100644 --- a/voice_driven_banking/voice_banking_test_suite.py +++ b/voice_driven_banking/voice_banking_test_suite.py @@ -4,6 +4,7 @@ from voice_simulator import VoiceCommandSimulator from selenium_automation import VoiceBankingAutomation + class VoiceBankingTestSuite: """ Integrates the voice simulator with the Selenium automation to create @@ -70,7 +71,10 @@ def _load_config(self, config_file): "What are my recent transactions" ] } - ] + ], + # Add support for LAMs and voice biometrics + "regional_languages_accents": ["en-US", "hi-IN", "ta-IN"], + "enable_voice_biometrics": True } if config_file and os.path.exists(config_file): @@ -129,6 +133,18 @@ def run_tests(self): # Clean up self.automation.close() + def _simulate_voice_biometrics(self, command_text): + """Simulate voice biometric authentication for secure access""" + if not self.config.get("enable_voice_biometrics", False): + return True # Skip biometric if disabled + + print(f"Simulating voice biometrics for command: '{command_text}'") + # Placeholder for biometric simulation logic + # For now, assume biometric authentication passes + biometric_success = True + + return biometric_success + def _test_command(self, command_name, command_text): """Test a single voice command and record results""" # Simulate voice command @@ -149,8 +165,15 @@ def _test_command(self, command_name, command_text): print(f"Warning: Could not identify command type for '{command_name}'") command_type = "unknown" - # Execute the command in the banking interface - result = self.automation.execute_voice_command(command_type) + # Simulate voice biometric authentication + biometric_result = self._simulate_voice_biometrics(command_text) + + # Execute the command in the banking interface only if biometric passed + if biometric_result: + result = self.automation.execute_voice_command(command_type) + else: + print("Voice biometric authentication failed.") + result = False # Record the test result test_result = { @@ -158,6 +181,7 @@ def _test_command(self, command_name, command_text): "original_command": command_text, "recognized_command": recognized_text, "confidence": voice_result["results"][0]["alternatives"][0]["confidence"], + "biometric_success": biometric_result, "success": result, "timestamp": time.strftime("%Y-%m-%d %H:%M:%S") } @@ -165,8 +189,8 @@ def _test_command(self, command_name, command_text): self.results["tests"].append(test_result) # Print result - status = "✅ PASSED" if result else "❌ FAILED" - print(f"{status} - Original: '{command_text}', Recognized: '{recognized_text}'") + status = "PASSED" if result else "FAILED" + print(f"{status} - Original: '{command_text}', Recognized: '{recognized_text}', Biometric: {'Passed' if biometric_result else 'Failed'}") return result @@ -206,4 +230,4 @@ def main(): test_suite.run_tests() if __name__ == "__main__": - main() \ No newline at end of file + main() From 0d1571a4e497fdd217783ad2c2f7d609410af77b Mon Sep 17 00:00:00 2001 From: Aryash123 <119963945+Aryash2003@users.noreply.github.com> Date: Mon, 5 May 2025 23:31:55 +0530 Subject: [PATCH 2/2] Update voice_simulator.py Extend VoiceCommandSimulator to accept and handle regional languages and accents (LAMs). Add a method to simulate NLP intent recognition, returning an intent label based on the command text. Add a method to simulate voice biometric authentication, returning success/failure. Modify simulate_command to include intent recognition and biometric authentication simulation results in the returned data structure. Preserve existing behavior and randomness for voice command simulation. --- voice_driven_banking/voice_simulator.py | 49 ++++++++++++++++++++++--- 1 file changed, 44 insertions(+), 5 deletions(-) diff --git a/voice_driven_banking/voice_simulator.py b/voice_driven_banking/voice_simulator.py index ee05acdd..a7d1fc31 100644 --- a/voice_driven_banking/voice_simulator.py +++ b/voice_driven_banking/voice_simulator.py @@ -8,9 +8,10 @@ class VoiceCommandSimulator: text that mimics what would come from a speech-to-text system. """ - def __init__(self, language="en-US", confidence_range=(0.85, 0.98)): + def __init__(self, language="en-US", confidence_range=(0.85, 0.98), supported_languages=None): self.language = language self.confidence_range = confidence_range + self.supported_languages = supported_languages or ["en-US", "hi-IN", "ta-IN"] # Common words that might be misheard self.sound_alikes = { @@ -68,10 +69,34 @@ def generate_voice_result(self, command_text): return result + def simulate_intent_recognition(self, command_text): + """ + Simulate NLP intent recognition by returning an intent label + based on keywords in the command text. + """ + command_text_lower = command_text.lower() + if "balance" in command_text_lower: + return "balance_inquiry" + elif "transfer" in command_text_lower or "pay" in command_text_lower: + return "fund_transfer" + elif "transaction" in command_text_lower or "history" in command_text_lower: + return "transaction_history" + else: + return "unknown_intent" + + def simulate_voice_biometrics(self, command_text): + """ + Simulate voice biometric authentication. + For now, randomly succeed or fail with high probability of success. + """ + # 90% chance of successful biometric authentication + success = random.random() < 0.9 + return success + def simulate_command(self, command_text): """ Simulate the process of speaking a command, with realistic timing - Returns the simulated recognition result + Returns the simulated recognition result including intent and biometric info """ # Simulate the time it takes to speak the command speaking_time = 0.1 * len(command_text.split()) # ~100ms per word @@ -81,8 +106,20 @@ def simulate_command(self, command_text): processing_delay = random.uniform(0.2, 0.8) # 200-800ms time.sleep(processing_delay) - # Generate and return the result - return self.generate_voice_result(command_text) + # Generate voice recognition result + voice_result = self.generate_voice_result(command_text) + + # Simulate intent recognition + intent = self.simulate_intent_recognition(command_text) + + # Simulate voice biometric authentication + biometric_success = self.simulate_voice_biometrics(command_text) + + # Add intent and biometric info to the result + voice_result["intent"] = intent + voice_result["biometric_success"] = biometric_success + + return voice_result def test_simulator(): """Test the voice command simulator with sample commands""" @@ -101,8 +138,10 @@ def test_simulator(): result = simulator.simulate_command(command) print(f"Simulated result: '{result['results'][0]['alternatives'][0]['transcript']}'") print(f"Confidence: {result['results'][0]['alternatives'][0]['confidence']:.2f}") + print(f"Intent: {result['intent']}") + print(f"Biometric Success: {result['biometric_success']}") print(f"Processing time: {result['processing_time_ms']}ms") print("-" * 50) if __name__ == "__main__": - test_simulator() \ No newline at end of file + test_simulator()