PlayKit.ai

Speech Recognition

Convert player voice to text using AI-powered speech recognition

Speech Recognition

The PlayKit SDK provides two complementary components for speech-to-text:

ComponentUse Case
UPlayKitSTTComponentReal-time microphone recording + transcription
UPlayKitSTTClientTranscribe existing audio files or raw audio data

Prerequisites

Ensure the AudioCapture plugin is enabled:

  1. Edit > Plugins
  2. Search for "Audio Capture"
  3. Enable it and restart the editor

Real-Time Recording (UPlayKitSTTComponent)

UPlayKitSTTComponent handles the full record-then-transcribe pipeline. Add it to an Actor in the editor (Add Component → PlayKit STT Component).

Blueprint Setup

In the Actor's Event Graph, bind the response event and wire your record/stop logic:

Event BeginPlay
    → Bind Event to OnPlayKitTranscriptionResponded → HandleTranscript

[Key Press E]  → Start Recording
[Key Release E] → Stop Recording   (transcription starts automatically)

HandleTranscript (Result: FPlayKitTranscriptionResult)
    → Branch (Result.bSuccess)
        True  → Print String (Result.Text)
        False → Print String (Result.ErrorMessage)

C++ Setup

#include "Component/PlayKitSTTComponent.h"

UPROPERTY(VisibleAnywhere)
UPlayKitSTTComponent* STTComponent;

void AMyCharacter::BeginPlay()
{
    Super::BeginPlay();

    STTComponent = FindComponentByClass<UPlayKitSTTComponent>();
    STTComponent->OnPlayKitTranscriptionResponded.AddDynamic(
        this, &AMyCharacter::HandleTranscript);
    STTComponent->OnPlayKitTranscriptionError.AddDynamic(
        this, &AMyCharacter::HandleError);
}

void AMyCharacter::StartListening()
{
    STTComponent->StartRecording();
}

void AMyCharacter::StopListening()
{
    STTComponent->StopRecording();
    // Transcription dispatches automatically after StopRecording
}

void AMyCharacter::HandleTranscript(const FPlayKitTranscriptionResult& Result)
{
    if (Result.bSuccess)
        ProcessVoiceCommand(Result.Text);
    else
        UE_LOG(LogTemp, Warning, TEXT("Transcription failed: %s"), *Result.ErrorMessage);
}

Transcription Options

For explicit control, use StartTranscription instead of relying on auto-dispatch:

FPlayKitTranscriptionRequest Request;
Request.Language = TEXT("en");   // Optional language hint

STTComponent->StartTranscription(Request);

Or StartTranscriptionSimple() to transcribe the last recording with default settings.

File/Data Transcription (UPlayKitSTTClient)

Use UPlayKitSTTClient when you already have an audio file or raw PCM data. Add it as an ActorComponent.

#include "Client/PlayKitSTTClient.h"

UPROPERTY(VisibleAnywhere)
UPlayKitSTTClient* STTClient;

void AMyActor::BeginPlay()
{
    Super::BeginPlay();

    STTClient = FindComponentByClass<UPlayKitSTTClient>();
    STTClient->OnTranscriptionComplete.AddDynamic(
        this, &AMyActor::HandleTranscription);
}

void AMyActor::TranscribeFile(const FString& FilePath)
{
    STTClient->TranscribeFile(FilePath);
}

void AMyActor::TranscribeRawAudio(const TArray<uint8>& AudioBytes)
{
    STTClient->TranscribeAudioData(AudioBytes, TEXT("recording.wav"));
}

void AMyActor::HandleTranscription(const FPlayKitTranscriptionResult& Result)
{
    if (Result.bSuccess)
        UE_LOG(LogTemp, Log, TEXT("Transcript: %s"), *Result.Text);
}

Language Support

// Set a default language on the component
STTClient->SetLanguage(TEXT("en"));

// Or transcribe a file with an explicit language
STTClient->TranscribeFileWithLanguage(FilePath, TEXT("zh"));

Supported codes: "en", "zh", "ja", "ko", "es", and all other Whisper-supported languages. Leave empty for auto-detect.

Voice Commands Example

void AGameController::ProcessVoiceCommand(const FString& Transcript)
{
    FString LowerText = Transcript.ToLower();

    if (LowerText.Contains(TEXT("open inventory")))
        OpenInventory();
    else if (LowerText.Contains(TEXT("attack")))
        PerformAttack();
    else
    {
        // Pass to NPC via Talk()
        NPCClient->Talk(Transcript);
    }
}

Platform Considerations

Windows / macOS / Linux

Full support for microphone recording.

Consoles

Check platform-specific microphone permission requirements.

Mobile

Request microphone permission before recording and handle denial gracefully.

Blueprint Nodes Reference

NodeComponentDescription
Start RecordingUPlayKitSTTComponentBegin microphone capture
Stop RecordingUPlayKitSTTComponentStop capture (transcription auto-starts)
Start TranscriptionUPlayKitSTTComponentTranscribe with explicit options
Start Transcription SimpleUPlayKitSTTComponentTranscribe with defaults
Transcribe FileUPlayKitSTTClientTranscribe a local audio file
Transcribe Audio DataUPlayKitSTTClientTranscribe raw PCM bytes
Set LanguageUPlayKitSTTClientSet the recognition language

Next Steps