GithubHelp home page GithubHelp logo

dialog's Introduction

Dialog system framework

Overview

This project implements dialog system (DS) framework. This framework is designed for robotic pruposes, but it's possible to create spoken dialog interface for any Python software.

Documentation

Implemented framework isn't complicated, so it uses light-weight document generator Pycco. To build a documentation, simply run this command at the repository root.

pycco ./dialog/*.py -d ./docs

Virtual environment installation

Make sure, that you have a Python3 and pip3 and/or easy_install-3.x installed.

sudo apt-get install python3-setuptools python3.4-dev python3-pip

You should see a path to executable. If it's available, you can run initialization script:

. ./init.sh

init.sh file creates virtual environment, downloads and compiles Link Grammar Parser.

Anyway, to run spoken dialog system you also need to install this packages:

sudo apt-get install portaudio19-dev mpg123 flac

After, you can run examples

python3 examples/pr2_control/main.py

To leave a virtual environment:

deactivate

To activate an environment again:

source env/bin/activate

To leave and delete a virtual environment:

. ./clean.sh

Custom installation

Recommended way to install this package is using the pip3. Run this command inside of a project directory.

pip3 install ./

If you don't have a root:

pip3 install --user ./

After this command, you can import inside of your python3 programs. Also this installation adds a command-line dialog_system command. Use this command to run slave activity code.

To uninstall this package:

pip3 uninstall dialog

Dependencies

This DS framework use Link Grammar parser for natural language processing. You can install Link Grammar parser from the aptitude:

sudo apt-get install link-grammar

Another option is to compile from sources: http://www.abisource.com/projects/link-grammar/#download. DS tested with 5.2.5 version.

If you would like to run spoken dialog system (not in text mode):

sudo apt-get install portaudio19-dev mpg123 flac
easy_install-3.x pyaudio

For WebSocket DS you also need a Tornado webserver:

pip3 install tornado

Getting started

Your code should have this structure:

from dialog import Dialog

# your variables definitions
# your functions/callable objects definition

if __name__ == "__main__":
	DLG = Dialog(globals(), storage="./")
	DLG.load("example.dlg")
	DLG.start_spoken()

In storage directory DS will create tmp folder (changed! for now, data is link-grammar data folder) for recorded answers/questions and sentences database. Storage directory by default is ./. DLG.start_text() оr DLG.start_spoken() define spoken mode or text mode.

Dialog description files

.dlg file describe a dialog model.

Examples

First of all, take a look at the unfinished documentation here: http://markbirger.info/dialog/. It also includes version 0.2 interactive demo. This version doesn't support duplex routines, but can explain some principles.

In examples directory you can find a few usage examples:

  • features_demo uses all DS framework features
  • pr2_control allows to control PR2 robot
  • slave_mode implements the same as a features_demo, but for slave activity code execution

PR2 implementation

Microphone issue

The PR2 robot don't have an access to Kinect microphone. Spoken DS isn't be able to record an audio at the PR2. We've created a DLG.start_socket(port=42424) option to run DS. In this example dialog system listens 42424 port, receives text messages and responds with speech. You need to run special remote configuration at the basestation, which can send recognized messages to the socket.

Run remote client in text mode:

python3 remote/text_mode.py -p 42424 127.0.0.1
python3 remote/spoken_mode.py -p 42424 127.0.0.1

Note, that spoken mode client stores question in ./tmp/ directory!

Python 2 issue

PR2 has a ROS hydro onboard. hydro distribution uses Python 2 as a default interpreter and it wasn't possible to run Python3 program, which uses rospy. Recommended way to solve this issue is execnet module:

pip3 install execnet

This module allows to communicate between Python2 and Python3 interpreters. Take a look at examples/pr2_control/ for an example.

How to run dialog system with pr2 simulation

Run your ROS hydro or connect to robodev1.fit.vutbr.cz server with this instruction Robodev1 How to get remote desktop.

  • Create an empty work catkin workspace
  • Put this repo (PR2/pr2_simulator) inside of the src/ directory
  • Make catkin workspace
  • source devel/setup.bash
  • vglrun roslaunch pr2_gazebo pr2_empty_world.launch

You should see a PR2 robot inside of the simulation. Then you can run your Python code from anywhere.

Other stuff

To run from the command line:

dialog_system -s examples/web_interface/test_slave.py -d examples/web_interface/test_slave.dlg --spoken
dialog_system -s code1.py code2.py -d dialog1.dlg dialog2.dlg --spoken

To generate a modules graph:

pyreverse -f 'ALL' -m y -o png -p Dialog *

To run websocket server in background mode:

screen -S dialog_screen -d -m python3 server.py

The MIT License (MIT)

Copyright (c) 2015 Mark Birger

dialog's People

Contributors

kusha avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

dialog's Issues

Duplex routine failed at parsing with space after >

(env) kusha@ubuntu:~/Desktop/dialog$ python3 examples/robot_control/main.py -t
Data storage path: /home/kusha/Desktop/dialog/tmp
Traceback (most recent call last):
File "examples/robot_control/main.py", line 93, in
DLG.load("examples/robot_control/dialog.dlg")
File "/home/kusha/Desktop/dialog/env/lib/python3.4/site-packages/dialog/interpreter.py", line 57, in load
parser = Parser(filename, self.scope, self.returns)
File "/home/kusha/Desktop/dialog/env/lib/python3.4/site-packages/dialog/parser.py", line 30, in init
self._parse()
File "/home/kusha/Desktop/dialog/env/lib/python3.4/site-packages/dialog/parser.py", line 107, in _parse
new = Literal2(line)
File "/home/kusha/Desktop/dialog/env/lib/python3.4/site-packages/dialog/states.py", line 210, in init
super(Literal2, self).init(value)
File "/home/kusha/Desktop/dialog/env/lib/python3.4/site-packages/dialog/states.py", line 185, in init
self.value = ast.literal_eval(value)
File "/usr/lib/python3.4/ast.py", line 46, in literal_eval
node_or_string = parse(node_or_string, mode='eval')
File "/usr/lib/python3.4/ast.py", line 35, in parse
return compile(source, filename, mode, PyCF_ONLY_AST)
File "", line 1
"no way"
^

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.