| 1 |
# HablarConSara.activity |
| 2 |
# A simple hack to attach a chatterbot to speak activity |
| 3 |
# Copyright (C) 2008 Sebastian Silva Fundacion FuenteLibre sebastian@fuentelibre.org |
| 4 |
# |
| 5 |
# Style and structure taken from Speak.activity Copyright (C) Joshua Minor |
| 6 |
# |
| 7 |
# HablarConSara.activity is free software: you can redistribute it and/or modify |
| 8 |
# it under the terms of the GNU General Public License as published by |
| 9 |
# the Free Software Foundation, either version 3 of the License, or |
| 10 |
# (at your option) any later version. |
| 11 |
# |
| 12 |
# HablarConSara.activity is distributed in the hope that it will be useful, |
| 13 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 |
# GNU General Public License for more details. |
| 16 |
# |
| 17 |
# You should have received a copy of the GNU General Public License |
| 18 |
# along with HablarConSara.activity. If not, see <http://www.gnu.org/licenses/>. |
| 19 |
|
| 20 |
import aiml |
| 21 |
from gettext import gettext as _ |
| 22 |
|
| 23 |
class defaultBrain: |
| 24 |
def __init__(self, voice): |
| 25 |
self.language = voice.language |
| 26 |
self.kernel = aiml.Kernel() |
| 27 |
|
| 28 |
if self.language=="es": |
| 29 |
self.kernel.loadBrain("sara.brn") |
| 30 |
self.kernel.setBotPredicate("nombre_bot","Sara") |
| 31 |
self.kernel.setBotPredicate("botmaster","la comunidad Azucar") |
| 32 |
elif self.language=="en-uk": |
| 33 |
self.kernel.loadBrain("alice.brn") |
| 34 |
self.kernel.setBotPredicate("name","Alice") |
| 35 |
self.kernel.setBotPredicate("master","the Sugar Community") |
| 36 |
else: |
| 37 |
self.kernel.respond = lambda x: x |
| 38 |
|
| 39 |
def respond(self, text): |
| 40 |
return self.kernel.respond(text) |