Skip to content

Commit

Permalink
Merge pull request #18 from Abhi13e/wikipedia
Browse files Browse the repository at this point in the history
Wikipedia Feature Added
  • Loading branch information
TobiasDemuth authored Feb 15, 2024
2 parents 3205676 + faed14f commit a11f93c
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion speech_assistent.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import tkinter as tk
from tkinter import simpledialog
from translate import Translator
import wikipedia

# ----------------------------------------------------------------------------------------------------
# ----------------------------------------------------------------------------------------------------
Expand All @@ -27,6 +28,7 @@
app_commands = ["start"]
trans_commands = ["translate"]
zoom_commands = ["zoom","scale"]
wikipedia_commands = ["wikipedia"]

# dictionarys
trans_dict = {
Expand Down Expand Up @@ -193,6 +195,9 @@ def zoom_scale(user_input):
if user_input in ["out","down"]:
return pyautogui.hotkey('ctrl', '-')

def get_wikipedia(user_input):
result = wikipedia.summary(user_input,1)
return result
# ----------------------------------------------------------------------------------------------------
# ----------------------------------------------------------------------------------------------------
# ----------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -221,7 +226,12 @@ def personal_assistant():
translation = offline_translate(text,input_lang)
print(translation)
response = translation


if key in user_input.lower() and any(command in user_input.lower() for command in wikipedia_commands):
search_query = user_input.lower().replace(key, "").strip()
search_query = "".join([word if word not in wikipedia_comamnds else "" for word in search_query.split(" ")])
response = get_wikipedia(search_query)

if key in user_input.lower() and any(command in user_input.lower() for command in app_commands):
response = user_input.lower()
app_query = user_input.lower().replace(key, "").strip()
Expand Down

0 comments on commit a11f93c

Please sign in to comment.