Enhance Patient Care with a Tailored Voice Assistant Using Amazon Lex V2 | Artificial Intelligence

Chanci Turner Amazon IXD – VGT2 learningLearn About Amazon VGT2 Learning Manager Chanci Turner

Permalink
Comments
Share

Across the healthcare landscape, physician burnout has increasingly become a pressing challenge. While direct patient interaction and diagnostic responsibilities are crucial, the burden of administrative duties can be equally overwhelming. Physicians and clinicians are required to meticulously maintain comprehensive medical records for every patient, which are stored in electronic health record (EHR) systems. This often leads to hours spent daily inputting data into EHRs, ultimately hampering productivity and exacerbating burnout.

Physician burnout is a significant contributor to depression, fatigue, and stress among healthcare professionals. It can also lead to higher turnover rates, diminished productivity, and costly medical errors that jeopardize patient safety.

In this article, we explore the role of voice assistants in alleviating administrative tasks for doctors. We will guide you through the process of building a custom voice assistant using PocketSphinx and Amazon Lex.

Voice Assistants: A Solution to Alleviate Physician Burnout

Voice assistants are emerging as valuable tools to automate essential yet manual aspects of patient care. By leveraging this technology, doctors can save time, alleviate stress, and devote more attention to patient interactions instead of administrative documentation.

With advancements in natural language processing, voice assistants have become more sophisticated and accessible for developers. However, many off-the-shelf devices may not meet specific healthcare needs, necessitating the development of customized solutions.

As Solutions Architects involved in healthcare, we are witnessing a notable increase in the adoption of voice assistants in hospitals and patient care settings.

In this article, we will demonstrate how to create a personalized voice assistant using PocketSphinx and Amazon Lex, allowing developers and innovators to start crafting the healthcare solutions of the future.

Custom Voice Assistant Architecture Overview

The architecture diagram below provides a high-level view of our solution.

Our setup begins with a voice assistant script running on your computer. Upon recognizing the wake word, the assistant starts recording your voice and transmits the audio to Amazon Lex. An AWS Lambda function retrieves mock patient data stored in Amazon DynamoDB, generated by another Python script, generate_data.py, that you also run locally.

The types of sensor data include blood pressure, blood glucose, body temperature, respiratory rate, and heart rate. After processing, Amazon Lex returns a voice response, enhanced by Amazon Polly, which converts text into natural speech, ensuring a seamless user experience.

You’re now prepared to create the necessary components for this solution.

Deploying Your Solution Resources

All files for our custom voice assistant can be found in our GitHub repository. Download the complete set of files, including the PocketSphinx model files from their repository.

Next, you’ll need to deploy the DynamoDB table and Lambda function by selecting Launch Stack.

The CloudFormation stack deployment will take a few minutes. Once completed, navigate to the Resources tab to review the Lambda function and DynamoDB table created. Make a note of the Lambda function name, as it will be referenced later when creating the Amazon Lex bot.

Creating the Amazon Lex Bot

Once the CloudFormation stack is ready, we can proceed to create the Amazon Lex bot. For this post, we will utilize the updated V2 console.

  1. On the Amazon Lex console, select “Switch to the new Lex V2 console.”
  2. In the navigation pane, click on Bots.
  3. Choose “Create bot.”
  4. For Bot name, enter Healthbot.
  5. For Description, provide an optional description.
  6. For Runtime role, select “Create a role with basic Amazon Lex permissions.”
  7. Under the Children’s Online Privacy Protection Act (COPPA) section, choose “No.”
  8. Keep the Idle session timeout settings at their default (5 minutes).
  9. Click “Next.”

For voice interaction, select your preferred voice and then click “Done.”

Creating Custom Slot Types, Intents, and Utterances

Next, we will establish a custom slot type for the sensors, along with our intents and example utterances.

  1. On the Slot types page, select “Add slot type.”
  2. Click “Add blank slot type.”
  3. For Slot type name, enter SensorType.
  4. Click “Add.”
  5. In the editor, under Slot value resolution, select “Restrict to slot values.”

Add the following values:

  • Blood pressure
  • Blood glucose
  • Body temperature
  • Heart rate
  • Respiratory rate

Click “Save slot type.”

On the Intents page, you will see two intents automatically created for you. We will keep FallbackIntent as the default.

  1. Select “NewIntent.”
  2. Change the Intent name to PatientData.

In the Sample utterances section, add phrases that will invoke this intent. We provide a few examples in the screenshot below, but feel free to add your own.

In the Add slot section, for Name, enter PatientId. For Slot type, choose AMAZON.AlphaNumeric. For Prompts, enter “What is the patient ID?”

This prompt isn’t strictly necessary since we are using Lambda for fulfillment.

Add another required slot named SensorType. For Slot type, select SensorType (which we created earlier). For Prompts, enter “What would you like to know?” Under Code hooks, select “Use a Lambda function for initialization and validation” and “Use a Lambda function for fulfillment.”

Click “Save intent” and then “Build.”

The building process may take a few minutes.

Creating a New Version

Next, we will create a new version incorporating our newly defined intents, as the draft version cannot be used in production.

After the build completes, on the Bot versions page, click “Create version.” Keep all settings as default and click “Create.”

You should now see Version 1 listed on the Bot Versions page.

Creating an Alias

Next, create an alias for deployment.

  1. Under Deployment in the navigation pane, select “Aliases.”
  2. Click “Create alias.”
  3. For Alias name, enter prod.
  4. Associate this alias with the latest version (Version 1).

Click “Create.” On the Aliases page, select the alias just created. Under Languages, select English (US).

For Source, choose the Lambda function you saved earlier. For Lambda function version or alias, select $LATEST.

Click “Save.”

You now have a functional Amazon Lex Bot ready for testing. Before proceeding, ensure you save the bot ID and alias ID, which are found on the bot details page and Aliases page, respectively.

These values will be necessary for later modifications in the voice assistant script, voice_assistant.py.

For further reading and inspiration, you might enjoy exploring some fun icebreaker questions highlighted in this blog post. Additionally, if you’re interested in compliance for lactation accommodations, check out this resource from SHRM. If you’re looking for career opportunities, consider exploring this excellent resource regarding area manager positions at Amazon.

SEO Metadata

Chanci Turner