By Justin Tamayo and Jorge Troncoso
About this Project
Darcy is a public transportation assistant that answers questions from riders.
Video
Problem Statement
Bus signs are great at telling riders which buses pass by the stop they are waiting at, but they fail to answer more complicated questions like, "Does bus X pass by stop Y?" With the advent of voice recognition technology, riders no longer have to be constrained to the information provided in traditional bus signs. Today, we can extract all the information a user would want from a server and present it through a voice-user interface.
How Does It Work?
Darcy consists of a BeagleBone Black connected to a PCB, speaker, microphone, and Wi-Fi adapter. The speaker, microphone, and Wi-Fi adapter are connected to the BeagleBone through a 4-port USB hub, and the PCB is connected using jumper wires.
In order to answer questions from riders, the BeagleBone runs Amazon’s Alexa Voice Service (AVS), a cloud-based service that enables voice recognition for Internet-connected devices. Alexa is most commonly used in the Amazon Echo wireless speaker; however, the AVS API allows all developers to utilize Alexa in their own websites and products.
In terms of software, Darcy runs as a custom Alexa skill (app). The Alexa Skills Kit allows developers to create their own skills and extend the capabilities of Alexa.
Darcy’s main feature is telling riders when the next bus or train will arrive. When Darcy is opened, the first thing you should do is tell her which bus stop or train station you are at. Every DART bus stop and train station has its own unique 5-digit number - the easiest way to obtain a stop’s ID is by using Google Maps and clicking on the stop. Once you have the ID, press and hold the pushbutton and tell Darcy, “My stop ID is 12345”, where 12345 is your stop ID. The next step is to tell Darcy a route and direction for her to remember – tell Darcy in the form of, “My bus route is 582 going southbound”, or “My train line is red going northbound”. Finally, ask Darcy when the next arrival is by saying, “Where is my bus (or train)?”
Darcy has several other features. Below is a list of other commands that you can ask her:
- “Where is the next 582 bus going southbound?” or “Where is the next red train going northbound?” – If you have already told Darcy your stop, you can ask her about any routes that service that stop, not just the one that she has saved for you.
- “Does my route go to stop number 67890?” – Darcy can tell you whether the route she saved for you goes to a particular stop. This can be useful if you know your home stop and want to check whether a route will take you there.
- “How much is a ticket?” or “How much is a reduced fare ticket?” – If you’re unfamiliar with DART, Darcy can give you basic fare information so you’re ready to pay when the bus finally arrives.
Block Diagram
Code
About Alexa Skills
Creating a custom Alexa skill like Darcy consists of two parts: designing the front-end interaction model, and writing the back-end code that processes user interactions. The interaction model describes how someone should use the skill. Any custom skill is programmed to listen for certain spoken phrases, called utterances, which correspond to the user’s intended actions, called intents. For example, the WheresMyBus intent is triggered when a user asks, “Where is the next bus?” Some intents are designed to handle variables, called slots; for instance, the MyStopIs intent responds to a phrase such as, “My stop ID is 12345”, where 12345 can be any five-digit number. Alexa handles the challenge of converting speech into text, but it is the responsibility of the developer to account for all the possible phrases that users can say when running their skill. This also means that front-end development is straightforward when extending an Alexa skill with new features. The back-end code for Alexa skills is hosted through AWS Lambda, an Amazon Web Service that eliminates the hassle of maintaining a server. When a user utters a valid phrase to Darcy, Alexa packages the specified intent and any user-provided information into a JSON object and sends it to Darcy’s lambda function for processing. Darcy’s lambda function is a Python program containing the code required to validate user-provided information, communicate with DART’s servers, and formulate Alexa’s spoken responses. For example, when Darcy’s lambda function receives a MyStopIs intent, it opens a text file containing a list of DART stops, verifies that the user gave a valid stop number, makes note of the stop’s real name, and returns a string for Alexa to read aloud: “Okay, I’ve saved your stop ID to LBJ/Central Station.” AWS Lambda also provides tools to monitor usage and log errors. For more information about how Alexa skills work and how to develop a custom skill, click here.
Fetching Arrival Information from DART
Most transit agencies openly provide information about their transit systems as a GTFS feed, a zip file that is formatted in a standardized structure. Some transit agencies also provide their real-time information as an extension of GTFS. While DART provides their transit info in the GTFS format, their live info is not available as GTFS realtime, so utilizing the GTFS feed would not suffice for Darcy. Instead, we developed a way to utilize DART’s mobile website to obtain the arrival information that Darcy wants. To load the web page that provides arrival information, the stop ID, route ID, and route direction ID are passed in the URL. DART returns information in a simple and consistent HTML format, so sending an HTTP GET request and parsing the response is trivial using Python. And because Darcy communicates directly with DART, users can trust that her information is accurate.
Step-by-Step Instructions to Run Darcy on a BeagleBone
- Install Debian Linux on the BeagleBone.
- Wire up the Darcy PCB to the BeagleBone (refer to the table further down the page for pin connections).
- Connect the USB hub with audio and Wi-Fi dongle to the BeagleBone. Set up and verify your Internet connection on the BeagleBone. Make note of the BeagleBone’s IP address.
- (Note: this video provides a helpful walkthrough of steps 4 and 5.) Create an Amazon developer account at developer.amazon.com. Click on Alexa, then Alexa Voice Service, then Register a Product Type > Device. This will take you to a form to associate a new Alexa device to your account.
- Fill in the fields Device Type ID and Display Name.
- Create a new security profile. Go to Web Settings. Under Allowed Origins, add http://localhost:5000/ and http://{your BeagleBone’s IP addr}:5000/. Under Allowed Return URLs, add http://localhost:5000/code and http://{your BeagleBone’s IP addr}:5000/code.
- Complete the rest of the device registration.
- Install git on the BeagleBone and clone the AlexaBeagleBone repo into a local directory. Then run setup.sh. The script will prompt you for things such as Product ID and Security Profile Description – these fields are the same ones found under the new security profile you created. Enter the appropriate information and follow the rest of the script to complete Alexa setup. At this point, you should be able to use your BeagleBone almost as if it were an Amazon Echo.
- To create your own copy of Darcy, it’s best to follow this Amazon tutorial, which provides a clear walkthrough on setting up a custom skill. When configuring the Lambda function, be sure to select Python 2.7 under Runtime, and upload the entire darcy-bus-assistant repo as a .zip file. When creating the interaction model, use darcy_interaction_model.txt from the GitHub repo to fill in the appropriate fields.
- To run Darcy, navigate into the AlexaBeagleBone directory that was previously cloned, then enter sudo python main.py to start Alexa. When Alexa is ready, hold the pushbutton down to start recording, and say "Alexa, open Darcy." If everything is working, Darcy will respond, and you can check where your bus (or train) is!
GitHub Repositories
Code to run Alexa on a BeagleBone (Credit: Mike Erdahl, TIer)
Code to run Darcy as an Alexa skill
Custom-Made Parts
Printed Circuit Board (PCB)
A printed circuit board with red and green LEDs connects to the BeagleBone and provides feedback to users. The red LEDs light up when Darcy is recording audio and the green LEDs light up when Darcy is speaking. All relevant schematics and board files can be found in the following Eagle project folder.
Schematic
Top Layer
Bottom Layer
As indicated in the schematic, the pin connections are as follows:
If you're interested in replicating this project but haven't designed a PCB before, Sparkfun has two amazing Eagle tutorials that walk you through the process:
Mounting Structure
A 3D printed structure holds all the components together. The USB dongle is installed on the left, the BeagleBone in the middle, and the PCB on the right.
The SolidWorks Model and STL file can be found in the following zip file.
What's Next
Instructions on how to go from one place to another
In a future version, we would like add a feature where riders can ask Darcy how to go from one place to another. This feature, which can be implemented using the Google Maps API, would benefit all users, especially those who don't have Internet access while commuting.
Use bus stop names instead of IDs
Currently, riders have to provide a 5-digit ID to set a bus stop. Although this method works, the user experience would improve significantly if riders could provide an intersection or the name of a bus stop instead. To implement this feature, we will have to wait for Amazon's Alexa Voice Service to improve. Right now, Alexa has a limited set of words she can understand. In order for Alexa to distinguish different bus stop names, she will have to expand her vocabulary.
Things Used in this Project
Tools and Fabrication Machines
- soldering iron
- solder
- 3D printer
Software
- Ubuntu
- Alexa Voice Service
- Alexa Skills Kit
- AWS Lambda
- Python 2.7
- Eagle
- SolidWorks
Other Resources
Getting Started with the BeagleBone Black
Acknowledgments
Special thanks to Mike Erdahl, our mentor, for providing us with the BeagleBone and Alexa resources to get Darcy started.





Comments