This project is a sample application that uses OpenAI and Azure Speech to create a QnA "Medical Assistant". It can answer questions about a patient's medical history in natural language, much like ChatGPT but with its own knowledge base.
The project has two principal components.
The project Azure_Functions_OpenAI is an Azure Function API that uses the OpenAI Python SDK to send the request to OpenAI service and returns the response
The project Blazor_QnA_OpenAI is a Blazor WASM app that asks the user for a prompt (in text or voice), uses the Azure Speech SDK to convert voice to text, sends the prompt to the Azure Function API, and displays the response.
- Visual Studio Code
- Azure Functions SDK
- .NET 6.0 (or later)
- OpenAI subscription key
- Azure Speech subscription key
First, we need to run the Azure Functions API, open the project Azure_Functions_OpenAI in VS Code, edit the file local.settings.json and change the next key with your OpenAI subscription key
"OPENAI_API_KEY": "{OpenAI KEY}"
Then open a terminal to run the command:
func start
The API runs in http://localhost:7071/api/CallQnAApi
Second, we need to run the web project, open the project Blazor_QnA_OpenAI in VS Code, edit the file CQnAOpenAI.razor.js and change the next line with your Azure Speech subscription key and region
var subscriptionKey = "{Azure Speech Subscription Key}", serviceRegion = "{Azure Speech Region}";
If you want the project to understand you in English you have to change the value of the next line to en-US
speechConfig.speechRecognitionLanguage = "es-MX";
Then open a terminal to run the command:
dotnet watch
The project runs in http://localhost:5082
You can change the dummy patient history and ask any question about the history in text or by voice. Much like ChatGPT it will understand the natural language and give you a response.
Blog Post ChatGPT | Asistente Médico con OpenAI usando Blazor y Azure Speech