-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Define the human input source, such as a chatbot, a voice assistant, …
…or a web interface, based on the task requirements and the agent's mode.
- Loading branch information
Showing
4 changed files
with
99 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
class Chatbot: | ||
def __init__(self): | ||
self.name = "Chatbot" | ||
self.greeting = "Hello! How can I assist you today?" | ||
|
||
def get_name(self): | ||
return self.name | ||
|
||
def set_name(self, name): | ||
self.name = name | ||
|
||
def get_greeting(self): | ||
return self.greeting | ||
|
||
def set_greeting(self, greeting): | ||
self.greeting = greeting | ||
|
||
def respond(self, message): | ||
# Implement your chatbot's response logic here | ||
# ... | ||
return "I'm sorry, I don't understand. Can you please rephrase?" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import pyttsx3 | ||
import speech_recognition as sr | ||
|
||
|
||
class VoiceAssistant: | ||
def __init__(self): | ||
self.recognizer = sr.Recognizer() | ||
self.engine = pyttsx3.init() | ||
|
||
def listen(self): | ||
with sr.Microphone() as source: | ||
self.recognizer.adjust_for_ambient_noise(source) | ||
audio = self.recognizer.listen(source) | ||
try: | ||
text = self.recognizer.recognize_google(audio) | ||
return text | ||
except sr.UnknownValueError: | ||
return None | ||
|
||
def speak(self, text): | ||
self.engine.say(text) | ||
self.engine.runAndWait() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
class WebInterface: | ||
def __init__(self): | ||
# Initialize necessary attributes | ||
self.user_input = None | ||
self.response = None | ||
|
||
def get_user_input(self): | ||
# Get user input from the web interface | ||
self.user_input = input("Enter your input: ") | ||
|
||
def send_response(self): | ||
# Send the response back to the web interface | ||
print(self.response) |