Skip to content

Development tips

abaart edited this page Apr 21, 2016 · 2 revisions

###Changing the python code Flask has an useful built-in development mode. It automatically refreshes the server when a change in the code is detected. Change debug to True in config.py, to enable debugging reports, whenever your application crashes. For more information: http://flask.pocoo.org/docs/0.10/quickstart/
###Debugging VXML files When a vxml document is not functioning as expected, the VXML interpreter does not give any hints on why this is happening. The call is just suddenly terminated.
To get some logs:

  1. stop the asterisk service: sudo /etc/init.d/asterisk stop
  2. start asterisk manually with a CLI: asterisk -cvvv
  3. tell openvxi to give more info: vxml debug interpreter

Now, call your service with your phone until the error occurs. There is a symlink to the log file already made for you. This is accessible at: http://IP_ADDRESS/log.txt. Scroll all the way to the bottom and go up until you see errors. Everything the interpreter does is posted, so don’t worry about skipping a lot of lines! Example of an useful error:
Jan 18 17:24:57.64|1985049680|0|8010|DEV|Parse error in file "http://127.0.0.1/FlaskKasadaka/placeProductOffer.vxml?lang=en", line 485, column 16 - either the 'src' attribute or inlined content may be provided, not both

After you are done, close the asterisk CLI and restart the service again.
Tip: when developing, use detaching from a byobu/tmux/screen session to keep the cli open, even when not connected to the RPi!
Tip: an online XML validator can also be useful to find errors!
###Using Text to Speech to generate audio files When you quickly want to generate some audio files, and do not want to spend a lot of time in Audacity, you can use a TTS engine. A free, lightweight and open-source engine has been installed in the installation guide. This program is called flite. It produces wav files in the correct format for VXI, so they can be used without further work.
Example to generate an audio file:
flite -t "Hello World!" -o helloworld.wav

This will save in the current directory.
NOTE: the speech is not very spectacular, but sufficient in English. Other languages are not recommended.

###Audio files availability page When developing a new use case, it is essential to have voicelabels for all possible spoken subjects in your application. These voicelabels also have to reference an existing wave sound file. Also, all the audio files used in the interface (asking questions, etc) have to exist.
To assist you in this, there is a page that scans all your python files and templates, and scans the triple store for audio files, and checks whether these files are accessible. Subjects in the triple store without a voicelabel are also shown.
The page can be accessed at:
http://IP_ADDRESS/FlaskKasadaka/audioreferences.html ###Wav files requirements VXI is picky about audio files. Supported audio files are listed here: https://wiki.i6net.org/doku.php/vxi_installation_guide:management:start