Example #1
0
    def answering(self, location="montreal"):
        command = str(self.question.strip().split(" ")[0])
        if self.question in self.dictionary.keys():
            res = self.dictionary.get(self.question)

        elif command in self.dictionary.keys():
            res = self.dictionary.get(command)
            if command == 'kina':
                search_term = str(self.question.split("kina ")[1])
                results = YoutubeSearch(search_term, max_results=1).to_json()
                i = results.find('link')
                j = results.find(',', i, -1)

                needed = results[i:j]
                i1 = needed.find('/')
                needed2 = needed[i1:-1]
                res = "https://www.youtube.com" + needed2
                self.is_command = True

        else:
            self.audio = "Ntago mbyumvise"
            res = 'Ntago mbyumvise!'
        '''if command == 'iteganyagihe':
            res = self.get_temperature(location)
            self.question = command'''
        return res
Example #2
0
def answering(dictionary, data):
    conv = data
    if conv in dictionary:
        if str(conv) in dictionary:
            value = dictionary.get(conv)
            if conv == 'kina':
                search_term = input("Kadogo: Mbwira izina ry'indirimbo: ")
                results = YoutubeSearch(search_term, max_results=10).to_json()
                i = results.find('link')
                j = results.find(',', i, -1)

                needed = results[i:j]
                i1 = needed.find('/')
                needed2 = needed[i1:-1]
                a_website = "https://www.youtube.com" + needed2
                answer = webbrowser.open_new(a_website)

            answer = playsound.playsound("soundsConv/" + str(key) + ".wav",
                                         True)
            answer = str(value)

    else:
        answer = 'Ntago mbyumvise !'

    return answer