---
title: "AI Speech Recognition in Unity"
description: "Speech recognition can be added to a Unity game with the Hugging Face Unity API by recording microphone input, encoding it as WAV and sending it for transcription."
url: "https://swe.quest/articles/ai-speech-recognition-in-unity-c468b32989ceef77"
canonical: "https://huggingface.co/blog/unity-asr"
source: "Hugging Face"
published: "2023-06-02"
difficulty: "medium"
kind: "How-to"
reading_minutes: 6
tags: ["speech-audio","gaming","dotnet"]
---

# AI Speech Recognition in Unity

A post on [Hugging Face](https://swe.quest/sources/hugging-face.md), published 2023-06-02, 6 min read, How-to. Original: [https://huggingface.co/blog/unity-asr](https://huggingface.co/blog/unity-asr)

## Summary

Speech recognition can be added to a Unity game with the Hugging Face Unity API by recording microphone input, encoding it as WAV and sending it for transcription. The C# walkthrough builds start/stop buttons and records up to 10 seconds at 44.1 kHz with Microphone.Start. It truncates the clip at the stop position and hand-writes a 16-bit PCM WAV header before calling HuggingFaceAPI.AutomaticSpeechRecognition with success and error callbacks. Button interactability and status messages are added for UX. Reader comments note that the hosted inference endpoint now returns 403 or timeout errors.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Speech & audio](https://swe.quest/tags/speech-audio.md) (AI & ML)
- [Games](https://swe.quest/tags/gaming.md) (Domains)
- [.NET](https://swe.quest/tags/dotnet.md) (Languages)

## Prerequisites

- Unity basics
- C# scripting ([easy posts on .NET](https://swe.quest/tags/dotnet.md?difficulty=easy))

## Keywords

Unity, Hugging Face Unity API, TextMeshPro, WAV, C#

## Related posts

- [How to Install and Use the Hugging Face Unity API](https://swe.quest/articles/how-to-install-and-use-the-hugging-face-unity-api-cf69490aaf6eefa7.md): Hugging Face · 2023-05-01 · Medium · 3 min read · Games, Inference & serving, .NET
  The Hugging Face Unity API wraps the Hugging Face Inference API so Unity projects can call hosted models.
- [Build a Speech-to-Text App with AssemblyAI on Replit](https://swe.quest/articles/build-a-speech-to-text-app-with-assemblyai-on-replit-b259386c71ff4ae2.md): Replit · 2022-03-29 · Medium · 9 min read · Speech & audio, React, JavaScript, API design
  A Next.js app on Replit transcribes uploaded audio files with AssemblyAI's speech-to-text API.
- [Speech Synthesis, Recognition, and More With SpeechT5](https://swe.quest/articles/speech-synthesis-recognition-and-more-with-speecht5-f8b2cd78391a59c0.md): Hugging Face · 2023-02-08 · Medium · 9 min read · Speech & audio, Machine learning, Python
  SpeechT5, Microsoft Research Asia's unified speech model, is now in 🤗 Transformers.
- [Fine-Tune Wav2Vec2 for English ASR in Hugging Face with 🤗 Transformers](https://swe.quest/articles/fine-tune-wav2vec2-for-english-asr-in-hugging-face-with-transformers-3965ec4df26fb19a.md): Hugging Face · 2021-03-12 · Medium · 24 min read · Speech & audio, Model training, Python
  Wav2Vec2, pretrained with a contrastive masked objective on 50k+ hours of unlabeled speech, can be fine-tuned with CTC on small labeled datasets for end-to-end English ASR without a language model.
- [Blazingly fast whisper transcriptions with Inference Endpoints](https://swe.quest/articles/blazingly-fast-whisper-transcriptions-with-inference-endpoints-d93b7d262c3a1210.md): Hugging Face · 2025-05-13 · Easy · 6 min read · Inference & serving, Speech & audio, Performance engineering
  Hugging Face Inference Endpoints now offers a Whisper deployment built on vLLM that delivers up to roughly 8x higher real-time factor (RTFx) than the Transformers implementation, with comparable word error rate.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
