A Simple Voice Controlled AI Assistant in C#

A Simple Voice Controlled AI Assistant in C#

TLDR;

A week ago I wanted to see if I could make calls to AI endpoints from inside an XR experience using my natural voice and have the response return in a natural voice as well and managed it successfully. I've since abstracted it into a more generic way so that it can be used in a bog standard WPF or C# application.

The (basic) Architecture

  1. Firstly, it records a question or command and saves it to a byte array.
  2. Then the audio data is sent to the OpenAI transcription service API to determine what was said and return it as a string (the transcription).
  3. Assuming a question is asked, this transcription is sent to the OpenAI GPT API and it returns an answer to the question.
  4. Now that we have a response and we want it spoken to us in a natural sounding voice, the text we want to be spoken is sent to the Azure Cognitive Services API (Text-To-Speech API).
  5. The audio data is returned back to the original app and played to the user.

Video Demonstration

I've created a video demonstration of the technologies on my YouTube channel and embedded it below.

Azure Text To Speech Voice Gallery

I have to mention that you can have the TTS (Text-To-Speech) generated audio returned in a number of accents, that you can hear here at the Azure Voice Gallery, which is both fascinating and fun to play with.

https://speech.microsoft.com/portal/voicegallery

Brief Speech Recognition and Speech Synthesis History Lesson

For the longest time (up until .NET 5 I think), you could do Speech Recognition and Speech Synthesis offline and locally on your Windows PC using the System.Speech namespace.

Though it was never moved to .NET Core, probably because it relied on a lot of OS/PC specific globalisation language packs? and posed issues running on other platforms such as Mac & Linux. It also sounded very robotic and had limited default accents. A shame, because the System.Speech namespace was nice to work with.

For this reason, this article describes the use of cloud based, online APIs.

Experiment Yourself

If you are going to try this yourself, you will need an OpenAI API Key and an Azure Cognitive Services API Key.

Unfortunately as the code is propriety to the organisation I contract to, so I don't want to share it here. Though I know for certain that those willing and able are capable of getting ChatGPT to generate 90% of the correct code with the right prompts themselves.

Powerful Applications - Get in Touch!

This type of voice controlled AI assistant functionality can be used in many ways.

  1. As a standalone desktop voice controlled assistant or a new voice controlled application.
  2. Hooked into existing applications - perhaps you have an existing application that you want to add voice control to?
  3. Extended so that the intent of your command is understood and various operations execute accordingly?

If you want to explore adding AI voice control & responses to an existing application or the development of an AI voice controlled application, get in touch and we can discuss your thoughts and requirements.

-- Lee


This article was featured in the 2025 C# Advent Calendar. Check it out!



Lee Englestone

Head of Innovation | Senior Software Development Manager & Tech Lead | Cloud, Web, Desktop, Mobile, AI and XR Developer | 5 x Microsoft MVP | MSc Entrepreneurship and Innovation

2 个月

C# Advent Calendar https://csadvent.christmas/

回复

要查看或添加评论,请登录

Lee Englestone的更多文章

  • AI Hackathon Project BusinessModelMaker.ai

    AI Hackathon Project BusinessModelMaker.ai

    For the currently live Azure AI Developer Hackathon, I decided to dust off an idea i've been holding on to for a rainy…

  • Userware Joins Manchester Digital

    Userware Joins Manchester Digital

    Userware is an innovative software development consultancy providing web, desktop, mobile AI and XR development…

  • Combining Top Down and Bottom Up Innovation

    Combining Top Down and Bottom Up Innovation

    I believe the best innovators are capable of adopting many mental models and approaches when it comes to innovation…

  • End-To-End Innovation

    End-To-End Innovation

    TLDR; Innovation needs to happen at every stage of the value discovery, design and delivery process including customer…

    1 条评论
  • Putting Generative AI Tours Live

    Putting Generative AI Tours Live

    A while back when OpenAI and ChatGPT were starting to gain popularity, I took it upon myself to learn how to call the…

  • How Calm Whipped Up a Storm Book Review

    How Calm Whipped Up a Storm Book Review

    Disclaimer: I was sent this book free of charge and asked whether I would consider reviewing it. I have no incentive to…

    3 条评论
  • Growth Hacker Marketing Book Review

    Growth Hacker Marketing Book Review

    I know I recently said I would be reading less and learning less in favour of more building and business development…

    3 条评论
  • 2025 A Year of Bringing Ideas to Life

    2025 A Year of Bringing Ideas to Life

    I've written previously (though I can't find the link) about how like to spend my time focused in one of three areas…

  • SendMyself.com Launch Postponed Indefinitely

    SendMyself.com Launch Postponed Indefinitely

    I've decided not to launch SendMyself.com.

    2 条评论
  • Immersive Apps Are the New Mobile Apps

    Immersive Apps Are the New Mobile Apps

    OK, perhaps not yet, but in the near future, immersive apps will become as mainstream as mobile apps are today. While…

社区洞察

其他会员也浏览了