mirror of
https://github.com/undera/pylgbst.git
synced 2020-11-18 19:37:26 -08:00
Minor improvements (#5)
* folder build shoud be ignored * added hint about gTTS support to get vernie chatter * determines full path to vernie.commands * catches tts exception if an empty text passed to `say` command
This commit is contained in:
parent
8a753e6880
commit
a4ed419156
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,3 +1,4 @@
|
|||||||
.idea
|
.idea
|
||||||
*.iml
|
*.iml
|
||||||
*.pyc
|
*.pyc
|
||||||
|
build
|
@ -29,7 +29,9 @@ Demonstrational videos:
|
|||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
_Please note that it requires [gattlib](https://bitbucket.org/OscarAcena/pygattlib) to be installed, which is not supported on Windows._
|
_Please note:_
|
||||||
|
- _it requires [gattlib](https://bitbucket.org/OscarAcena/pygattlib) to be installed, which is not supported on Windows._
|
||||||
|
- _to enable the text-to-speech functionality [gTTS](https://github.com/pndurette/gTTS) may be installed but is not required by default._
|
||||||
|
|
||||||
Install library like this:
|
Install library like this:
|
||||||
```bash
|
```bash
|
||||||
|
@ -41,7 +41,8 @@ SPEECH_LANG_MAP = {
|
|||||||
"commands help": "Available commands are: "
|
"commands help": "Available commands are: "
|
||||||
"forward, backward, turn left, turn right, "
|
"forward, backward, turn left, turn right, "
|
||||||
"head left, head right, head straight, shot and say",
|
"head left, head right, head straight, shot and say",
|
||||||
"finished": "Thank you! Robot is now turning off"
|
"finished": "Thank you! Robot is now turning off",
|
||||||
|
"text is empty": "Please, enter not empty text to say!"
|
||||||
},
|
},
|
||||||
"ru": {
|
"ru": {
|
||||||
"ready": "Робот Веернии готов к работе",
|
"ready": "Робот Веернии готов к работе",
|
||||||
@ -49,9 +50,10 @@ SPEECH_LANG_MAP = {
|
|||||||
"ok": "хорошо",
|
"ok": "хорошо",
|
||||||
"commands help": "Доступные команды это: вперёд, назад, влево, вправо, "
|
"commands help": "Доступные команды это: вперёд, назад, влево, вправо, "
|
||||||
"голову влево, голову вправо, голову прямо, выстрел, скажи",
|
"голову влево, голову вправо, голову прямо, выстрел, скажи",
|
||||||
"Finished": "Робот завершает работу. Спасибо!",
|
"finished": "Робот завершает работу. Спасибо!",
|
||||||
"commands from file": "Исполняю команды из файла",
|
"commands from file": "Исполняю команды из файла",
|
||||||
"fire": "Выстрел!",
|
"fire": "Выстрел!",
|
||||||
|
"text is empty": "Пожалуйста, наберите не пустой текст!"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -132,6 +134,9 @@ class Vernie(MoveHub):
|
|||||||
confirm(cmd)
|
confirm(cmd)
|
||||||
self.head(STRAIGHT)
|
self.head(STRAIGHT)
|
||||||
elif cmd[0] in ("say", "скажи", "сказать"):
|
elif cmd[0] in ("say", "скажи", "сказать"):
|
||||||
|
if not cmd[1:]:
|
||||||
|
self.say("text is empty")
|
||||||
|
return
|
||||||
say(' '.join(cmd[1:]))
|
say(' '.join(cmd[1:]))
|
||||||
elif cmd[0] in ("fire", "shot", "огонь", "выстрел"):
|
elif cmd[0] in ("fire", "shot", "огонь", "выстрел"):
|
||||||
say("fire")
|
say("fire")
|
||||||
|
@ -9,7 +9,7 @@ def confirmation(command):
|
|||||||
robot.say(command[0])
|
robot.say(command[0])
|
||||||
|
|
||||||
|
|
||||||
with open("vernie.commands") as fhd:
|
with open(os.path.join(os.path.dirname(__file__), "vernie.commands")) as fhd:
|
||||||
for cmd in fhd.readlines():
|
for cmd in fhd.readlines():
|
||||||
sys.stdout.write("%s" % cmd)
|
sys.stdout.write("%s" % cmd)
|
||||||
robot.interpret_command(cmd, confirmation)
|
robot.interpret_command(cmd, confirmation)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user