Sunday, March 30, 2025

Jarvis But... Name is changed

 If you want to change the name of your assistant to "Hoomer", you can easily update the code where the assistant speaks or reacts. Here’s how you can adjust the code to reflect that change.

Where to Update the Name in Code

1. Speech Output (When Hoomer Speaks)

Whenever the assistant speaks, change the name "Jarvis" to "Hoomer". For example, in the speak() function:

def speak(text):
    engine = pyttsx3.init()
    engine.say(text)
    engine.runAndWait()

You might want to personalize the assistant's introduction:

speak("Hello, I am Hoomer, your personal assistant.")

2. Change the Name in Commands

Whenever you check for specific commands, replace "Jarvis" with "Hoomer". For example, if you have a command to "wake up" or "call" the assistant, use the new name:

if "hoomer" in command:
    # Respond when the user says "Hoomer"
    speak("Yes, how can I help you?")

3. Personalize Responses

Anywhere in the code where the assistant mentions its name (like when it introduces itself or answers queries), just replace "Jarvis" with "Hoomer":

if "time" in command:
    time = tell_time()
    speak(f"Hoomer says the time is {time}")

4. Using the Name in Commands

If you'd like the assistant to respond to "Hoomer" instead of "Jarvis," you can update the listen() function to check for "Hoomer" as the wake-up word:

def listen():
    recognizer = sr.Recognizer()
    with sr.Microphone() as source:
        print("Listening...")
        audio = recognizer.listen(source)
    
    try:
        print("Recognizing...")
        query = recognizer.recognize_google(audio, language="en-US")
        print(f"You said: {query}")
    except Exception as e:
        print("Sorry, I didn't get that.")
        return None
    
    return query.lower()

if "hoomer" in command:  # Hoomer as wake-up word
    speak("Yes, how can I assist you?")

Example: Change All Instances

Here’s an updated snippet where "Hoomer" replaces "Jarvis":

import pyttsx3
import speech_recognition as sr
import datetime
import pywhatkit as kit
import wikipedia
import pyjokes

def listen():
    recognizer = sr.Recognizer()
    with sr.Microphone() as source:
        print("Listening...")
        audio = recognizer.listen(source)
    
    try:
        print("Recognizing...")
        query = recognizer.recognize_google(audio, language="en-US")
        print(f"You said: {query}")
    except Exception as e:
        print("Sorry, I didn't get that.")
        return None
    return query.lower()

def speak(text):
    engine = pyttsx3.init()
    engine.say(text)
    engine.runAndWait()

def tell_time():
    now = datetime.datetime.now()
    return now.strftime("%H:%M:%S")

def play_music(query):
    song = query.replace("play", "").strip()
    speak(f"Playing {song}")
    kit.playonyt(song)

def search_wikipedia(query):
    try:
        result = wikipedia.summary(query, sentences=2)
    except wikipedia.exceptions.DisambiguationError as e:
        result = f"Multiple options found. Please be more specific. Possible options: {e.options}"
    except wikipedia.exceptions.HTTPTimeoutError:
        result = "Sorry, I couldn't fetch information. Please try again later."
    except Exception as e:
        result = "Sorry, there was an error with the Wikipedia search."
    return result

def tell_joke():
    joke = pyjokes.get_joke()
    return joke

if __name__ == "__main__":
    speak("Hello, I am Hoomer, your personal assistant.")
    while True:
        command = listen()
        if command:
            if "hoomer" in command:  # Respond when "Hoomer" is called
                speak("Yes, how can I help you?")
            elif "time" in command:
                time = tell_time()
                speak(f"Hoomer says the time is {time}")
            elif "play" in command:
                play_music(command)
            elif "wikipedia" in command:
                query = command.replace("wikipedia", "")
                result = search_wikipedia(query)
                speak(result)
            elif "joke" in command:
                joke = tell_joke()
                speak(joke)
            elif "exit" in command:
                speak("Goodbye!")
                break

Summary of Changes:

  • Replace all instances of "Jarvis" with "Hoomer" in the code.

  • Update the assistant's responses to reflect the new name, like when it speaks or responds to commands.

  • Ensure that the assistant listens for "Hoomer" as the wake-up word.

Now, Hoomer will be your personalized assistant! 🎉

If you need help with any other changes or features, feel free to ask!


- All above codes are generated by Open AI for better Accuracy

No comments:

Post a Comment

Jarvis But... Name is changed

 If you want to change the name of your assistant to "Hoomer" , you can easily update the code where the assistant speaks or react...