Giter VIP home page Giter VIP logo

Comments (5)

ahmadfaizalbh avatar ahmadfaizalbh commented on August 29, 2024 1

If you are looking to make it as web application then checkout example Django application https://github.com/ahmadfaizalbh/WebBot

If you want to help you with the creating middleware, I would need more information about what kind of middleware you are looking at, how you want the middleware to function, in which language your application runs, etc.

if you don't want to disclose details here you can always email me at [email protected]

from chatbot.

littledivy avatar littledivy commented on August 29, 2024

I actually need to pass all the response of the chatbot to a text to speech engine.

Language: Python 3

def speak(msg):
  # I run a command here to trigger a script for text to speech

Please note: every thing is running smoothly there are no issues.

But I can't a way to obtain every response of the chatbot. Is there a way to do that?

Thanks.

from chatbot.

ahmadfaizalbh avatar ahmadfaizalbh commented on August 29, 2024

You can in inherit Chat and override conversation

from chatbot import Chat

class MyChat(Chat):
    def converse(self, first_question=None, quit="quit", session_id="general"):
        """
        Conversation initiator
        :type first_question: str
        :param first_question: Start up message
        :type quit: str
        :param quit: Conversation termination command
        :type session_id: str
        :param session_id: Current User session when used for multi user scenario
        :rtype: str
        """
        if first_question:
            self.conversation[session_id].append(first_question)
            speak(first_question)
        input_sentence = ""
        while input_sentence != quit:
            # Read Input source
            input_sentence = input("> ")
            if input_sentence:
                self.conversation[session_id].append(input_sentence)
                input_sentence = input_sentence.rstrip("!.")
                message = self.respond(input_sentence, session_id=session_id)
                self.conversation[session_id].append(message)
                # call output function
                speak(message)

first_question = "Hi, how are you?"
chat = MyChat(os.path.join(os.path.dirname(os.path.abspath(__file__)), "Example.template"))
chat.converse(first_question)

if you have any voice listener function that returns user text then replace input with listener function

from chatbot.

littledivy avatar littledivy commented on August 29, 2024

Oh okay! I'll give it a try and get back to you. Thanks

from chatbot.

littledivy avatar littledivy commented on August 29, 2024

Thanks dude 👍 It worked just fine.

I have another question I'll open another issue for that.

from chatbot.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.