I’m pretty new to UE5 Development, and besides problems with my project dying several times from unknown conditions, i’ve run into a problem with using library. So to be short, i want to use Vosk voice recognition library, but whatever i try to do, it’s either won’t link at all (link errors), or simply successfully builds and tells me that “Patch could not be activated“. So, there is my code:
practice_2025.Build.cs
// Copyright Epic Games, Inc. All Rights Reserved.
using System;
using System.IO;
using UnrealBuildTool;
public class practice_2025 : ModuleRules
{
public practice_2025(ReadOnlyTargetRules Target) : base(Target)
{
PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;
PublicDependencyModuleNames.AddRange(new string[]
{
"Core",
"CoreUObject",
"Engine",
"InputCore",
"Slate",
"SlateCore",
"UMG",
"AudioCapture",
"SignalProcessing",
"AudioMixer"
});
// Library Path - 'practice_2025/ThirdParty/Vosk/'
var VoskPath = Path.Combine(ModuleDirectory, "..", "..", "ThirdParty", "Vosk");
// Header file (.h)
PublicIncludePaths.Add(Path.Combine(VoskPath, "Include"));
// Library file (.lib)
PublicAdditionalLibraries.Add(Path.Combine(VoskPath, "Lib", "libvosk.lib"));
// Runtime-dependencies(.dll)
RuntimeDependencies.Add(Path.Combine(VoskPath, "Binaries", "libvosk.dll"), StagedFileType.NonUFS);
RuntimeDependencies.Add(Path.Combine(VoskPath, "Binaries", "libstdc++-6.dll"), StagedFileType.NonUFS);
RuntimeDependencies.Add(Path.Combine(VoskPath, "Binaries", "libgcc_s_seh-1.dll"), StagedFileType.NonUFS);
RuntimeDependencies.Add(Path.Combine(VoskPath, "Binaries", "libwinpthread-1.dll"), StagedFileType.NonUFS);
PublicDelayLoadDLLs.Add("libvosk.dll");
if (Target.Platform == UnrealTargetPlatform.Win64)
{
PublicDefinitions.Add("VOSK_EXPORT=__declspec(dllimport)");
}
PrivateDependencyModuleNames.AddRange(new string[] { });
}
}
VoskListener.h
#pragma once
#include "CoreMinimal.h"
#include "VoskListener.generated.h"
struct VoskModel;
struct VoskRecognizer;
UCLASS()
class PRACTICE_2025_API AVoskListener : public AActor
{
GENERATED_BODY()
public:
AVoskListener();
virtual ~AVoskListener();
UFUNCTION(BlueprintCallable, Category = "Vosk")
void InitVosk();
private:
class FVoskInternal;
FVoskInternal* VoskInternal;
bool isRunning = false;
};
VoskListener.cpp
#include "VoskListener.h"
#include "vosk_api.h"
class AVoskListener::FVoskInternal
{
public:
VoskModel* Model = nullptr;
VoskRecognizer* Recognizer = nullptr;
float SampleRate = 16000.f;
~FVoskInternal()
{
if (Model) vosk_model_free(Model);
if (Recognizer) vosk_recognizer_free(Recognizer);
}
};
AVoskListener::AVoskListener()
{
VoskInternal = new FVoskInternal();
InitVosk();
}
AVoskListener::~AVoskListener(){ delete VoskInternal; };
void AVoskListener::InitVosk()
{
UE_LOG(LogTemp, Log, TEXT("Initializing Vosk..."))
vosk_set_log_level(0);
FString ModelPath = FPaths::Combine("..", "VoskModels", "rus");
VoskInternal->Model = vosk_model_new(TCHAR_TO_UTF8(*ModelPath));
VoskInternal->Recognizer = vosk_recognizer_new(VoskInternal->Model, VoskInternal->SampleRate);
if (!VoskInternal->Model || !VoskInternal->Recognizer)
{
UE_LOG(LogTemp, Error, TEXT("Unable to load model or recognizer!"))
return;
}
UE_LOG(LogTemp, Log, TEXT("General library components are loaded successfully!"))
}
So, currently it should be added to the level and just initialize model and recognizer objects, when this will be working i could make anything i want (stream recognition), but for now i don’t even have a single idea on how to fix this issue (was trying to debug it whole night but failed)
Hope anyone could help me, thank you in advance.