This project brings together several examples of API programming with Max. The pandorabots.api patch contains an example of using curl to generate an XML response file, then converts XML to JSON using a Python script. The resulting JSON file is read into Max and parsed using the [js] object.
Here is an audio recording of my conversation (using Max) with a text chatbot named ‘Chomsky’
My voice gets recorded by Max then converted to text by the Google speech-api.
The text is passed to the Pandorabots API. The chatbot response gets spoken by the aka.speech external which uses the Mac OS built-in text-to-speech system.
Note: The above recording was processed with a ‘silence truncate’ effect because there were 3-5 second delays between responses. In realtime it has the feel of the Houston/Apollo dialogs.
pandorabots-api.maxpat (which handles chatbot responses) gets text input from speech-to-google-text-api2.maxpat – a patch that converts speech to text using the Google speech-API.
https://reactivemusic.net/?p=4690
The output (responses from chatbot) get sent to twitter-search-to-speech2.maxpat which “speaks” using the Mac OS text-to-speech program using the aka.speech external.
files
Max
- speech-to-google-text-api2.maxpat
- JSON-google-speech.js
- pandorabots-api.maxpat
- JSON-pandorabot.js
- text-to-speech2.maxpat
externals:
- [aka.speech] and [aka.shell] from http://www.iamas.ac.jp/~aka/max/ – download this external and add the folder to Options | File Preferences, in Max
[authorization]
- none required
external programs:
- sox: sox audio conversion program must be in the computer’s executable file path, ie., /usr/bin – or you can rewrite the [sprintf] input to [aka.shell] with the actual path. Get sox from: http://sox.sourceforge.net
- xml2json (python) in tkzic/internetsensors/: xml2json/xml2json.py and xml2json/setup.py (for translating XML to JSON) – [NOTE] you will need to change the path in the [sprintf] object in pandorabots.api to point to the folder containing this python script.
instructions
- Open the three Max patches.
- speech-to-google-text-api2.maxpat
- pandorabots-api.maxpat
- text-to-speech2.maxpat
- Clear the custid in the pandorabots-api patch
- Start audio in the Google speech patch. Then toggle the mic button and say something.
- After the first response, go to the pandorabots-api patch and click the new custid – so that the chatbot retains the thread of the conversation.
download:
The files for this project can be downloaded from the intenet-sensors archive at github