Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python3
- # Filename: tts_control.py
- # Version: 1.00
- # Author: Jeoi Reqi
- """
- TTS CONTROL:
- This script provides functionality to enable or disable speech recognition in Windows.
- Requirements:
- - Windows operating system
- Usage:
- - Run the script to manage speech recognition settings.
- - Choose options from the main menu to enable or disable speech recognition.
- Notes:
- - This script uses PowerShell to interact with Windows language settings.
- """
- import subprocess
- # Function to enable speech recognition
- def enable_speech_recognition():
- """
- Enable speech recognition in Windows.
- """
- try:
- # Run PowerShell command to enable speech recognition
- powershell_command = 'Set-WinUserLanguageList -LanguageList en-US -Force'
- subprocess.run(['powershell', '-Command', powershell_command], check=True)
- print("Speech recognition enabled successfully.")
- except subprocess.CalledProcessError as e:
- print("Error:", e)
- print("Output:", e.output)
- # Function to disable speech recognition
- def disable_speech_recognition():
- """
- Disable speech recognition in Windows.
- """
- try:
- # Run PowerShell command to disable speech recognition
- powershell_command = 'Set-WinUserLanguageList -LanguageList en-US -Force'
- subprocess.run(['powershell', '-Command', powershell_command], check=True)
- print("Speech recognition disabled successfully.")
- except subprocess.CalledProcessError as e:
- print("Error:", e)
- print("Output:", e.output)
- # Main menu function
- def main_menu():
- """
- Display the main menu and handle user input.
- """
- print("=== Text-to-Speech (TTS) Management ===")
- while True:
- print("\n1. Enable Speech Recognition")
- print("2. Disable Speech Recognition")
- print("0. Exit")
- choice = input("\nEnter your choice (1 or 2): ")
- if choice == '1':
- enable_speech_recognition()
- elif choice == '2':
- disable_speech_recognition()
- elif choice == '0':
- print("Exiting...")
- exit(0) # Exit with error code 0
- else:
- print("Invalid choice. Please enter 1, 2, or 0.")
- # Run the main menu
- main_menu()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement