Skip to content

Commit 38e7055

Browse files
Merge pull request #2430 from Avdhesh-Varshney/openWebsite
[GSSoC'23] Open websites by Speaking
2 parents 6b742c7 + 5439979 commit 38e7055

File tree

3 files changed

+78
-0
lines changed

3 files changed

+78
-0
lines changed

SCRIPTS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,4 +119,5 @@
119119
| 109\. | Domain Name Availability Checker | This script is a Python tool that allows you to check the availability of domain names using the GoDaddy API. | [Take Me](./Domain_Name_Availability/) | [Sabhi Sharma](https//github.com/sabhisharma-ise)
120120
| 110\. | Automatic Spelling Checker and Corrector | This Script is used to detect spelling errors in a text and correct them if the user wishes to do so. | [Take Me](./Automatic_Spelling_Checker_Corrector/) | [Sabhi Sharma](https//github.com/sabhisharma-ise)
121121
| 111\. | File Searcher | The File Search script is a Python tool that allows you to search for files with a specific extension in a directory. It recursively searches through all subdirectories of the specified directory and returns a list of files that match the provided file extension. | [Take Me](https://github.com/avinashkranjan/Amazing-Python-Scripts/tree/master/File\Search) | [Srujana Vanka](https://github.com/srujana-16)
122+
| 112\. | Open Websites By Speaking | This python script can allow user to open any website just by speaking. | [Take Me](./Websites_Automation) | [Avdhesh Varshney](https://github.com/Avdhesh-Varshney)
122123
| 112\. | Advisor App | This python script allows user to give so many advices and motivation quote lines. | [Take Me](./Advisor_App) | [Avdhesh Varshney](https://github.com/Avdhesh-Varshney)

Websites_Automation/README.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# WEBSITE AUTOMATION
2+
3+
This is a Python Script help in opening the websites just by speaking the name of the websites.
4+
5+
---
6+
7+
## Requirements
8+
9+
For this script to run you need to have speech recognition and webbrowser packages installed
10+
11+
Run the command in terminal to install package
12+
13+
```
14+
$ pip install SpeechRecognition
15+
```
16+
```
17+
$ pip install webbrowser
18+
```
19+
Run the program using command
20+
21+
```
22+
$ python websites.py
23+
```
24+
25+
## Created By
26+
27+
[Avdhesh Varshney](https://github.com/Avdhesh-Varshney)
28+
29+
<br>
30+
31+
**Thanks for using this program**
32+

Websites_Automation/websites.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import speech_recognition as sr
2+
import webbrowser
3+
4+
def takeCommand():
5+
recognizer = sr.Recognizer()
6+
7+
with sr.Microphone() as source:
8+
print("\nListening...\n")
9+
recognizer.adjust_for_ambient_noise(source)
10+
audio = recognizer.listen(source)
11+
12+
try:
13+
command = recognizer.recognize_google(audio).lower()
14+
print(f"\nCommand: {command}\n")
15+
return command
16+
except sr.UnknownValueError:
17+
print("Could not understand audio. Please try again.")
18+
return None
19+
except sr.RequestError as e:
20+
print(f"\nError occurred while requesting results: {e}\n")
21+
return None
22+
23+
def openWebsite(website):
24+
website = website.replace("Open", "")
25+
website = website.replace(" ", "")
26+
url = f"https://www.{website}.com"
27+
webbrowser.open(url)
28+
29+
def displayInstructions():
30+
print('''\n\n1. Say "Open ${Website Name}" to open the Website.
31+
2. Say "exit" to close the program.\n
32+
''')
33+
34+
if __name__ == "__main__":
35+
displayInstructions()
36+
while True:
37+
command = takeCommand()
38+
39+
if command == "exit":
40+
print("\nExiting...\n")
41+
print("Thanks for using this program !\n")
42+
break
43+
44+
elif command:
45+
openWebsite(command)

0 commit comments

Comments
 (0)