Advertisement
Python253

tts_control

Mar 21st, 2024
557
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.28 KB | None | 0 0
  1. #!/usr/bin/env python3
  2. # Filename: tts_control.py
  3. # Version: 1.00
  4. # Author: Jeoi Reqi
  5.  
  6. """
  7. TTS CONTROL:
  8.  
  9. This script provides functionality to enable or disable speech recognition in Windows.
  10.  
  11. Requirements:
  12. - Windows operating system
  13.  
  14. Usage:
  15. - Run the script to manage speech recognition settings.
  16. - Choose options from the main menu to enable or disable speech recognition.
  17.  
  18. Notes:
  19. - This script uses PowerShell to interact with Windows language settings.
  20. """
  21.  
  22. import subprocess
  23.  
  24. # Function to enable speech recognition
  25. def enable_speech_recognition():
  26.     """
  27.    Enable speech recognition in Windows.
  28.    """
  29.     try:
  30.         # Run PowerShell command to enable speech recognition
  31.         powershell_command = 'Set-WinUserLanguageList -LanguageList en-US -Force'
  32.         subprocess.run(['powershell', '-Command', powershell_command], check=True)
  33.         print("Speech recognition enabled successfully.")
  34.     except subprocess.CalledProcessError as e:
  35.         print("Error:", e)
  36.         print("Output:", e.output)
  37.  
  38. # Function to disable speech recognition
  39. def disable_speech_recognition():
  40.     """
  41.    Disable speech recognition in Windows.
  42.    """
  43.     try:
  44.         # Run PowerShell command to disable speech recognition
  45.         powershell_command = 'Set-WinUserLanguageList -LanguageList en-US -Force'
  46.         subprocess.run(['powershell', '-Command', powershell_command], check=True)
  47.         print("Speech recognition disabled successfully.")
  48.     except subprocess.CalledProcessError as e:
  49.         print("Error:", e)
  50.         print("Output:", e.output)
  51.  
  52. # Main menu function
  53. def main_menu():
  54.     """
  55.    Display the main menu and handle user input.
  56.    """
  57.     print("=== Text-to-Speech (TTS) Management ===")
  58.     while True:
  59.         print("\n1. Enable Speech Recognition")
  60.         print("2. Disable Speech Recognition")
  61.         print("0. Exit")
  62.         choice = input("\nEnter your choice (1 or 2): ")
  63.  
  64.         if choice == '1':
  65.             enable_speech_recognition()
  66.         elif choice == '2':
  67.             disable_speech_recognition()
  68.         elif choice == '0':
  69.             print("Exiting...")
  70.             exit(0)  # Exit with error code 0
  71.         else:
  72.             print("Invalid choice. Please enter 1, 2, or 0.")
  73.  
  74. # Run the main menu
  75. main_menu()
  76.  
  77.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement