diff --git a/AzSpeech.uplugin b/AzSpeech.uplugin index fe5a94d..0299d17 100644 --- a/AzSpeech.uplugin +++ b/AzSpeech.uplugin @@ -1,7 +1,7 @@ { "FileVersion": 3, - "Version": 30, - "VersionName": "1.6.13", + "Version": 31, + "VersionName": "1.6.14", "FriendlyName": "AzSpeech - Voice and Text", "Description": "Integrates Azure Speech Cognitive Services into the Engine by adding functions to perform recognition and synthesis via asynchronous tasks.", "Category": "Game Features", diff --git a/Source/AzSpeech/Private/AzSpeech/Runnables/Recognition/Bases/AzSpeechRecognitionRunnableBase.cpp b/Source/AzSpeech/Private/AzSpeech/Runnables/Recognition/Bases/AzSpeechRecognitionRunnableBase.cpp index 155b59c..95eaefd 100644 --- a/Source/AzSpeech/Private/AzSpeech/Runnables/Recognition/Bases/AzSpeechRecognitionRunnableBase.cpp +++ b/Source/AzSpeech/Private/AzSpeech/Runnables/Recognition/Bases/AzSpeechRecognitionRunnableBase.cpp @@ -183,6 +183,13 @@ bool FAzSpeechRecognitionRunnableBase::InitializeAzureObject() ApplySDKSettings(SpeechConfig); + const auto TaskAudioConfig = GetAudioConfig(); + if (!SpeechConfig) + { + UE_LOG(LogAzSpeech_Internal, Error, TEXT("Thread: %s; Function: %s; Message: Invalid audio config"), *GetThreadName(), *FString(__func__)); + return false; + } + if (RecognizerTask->GetRecognitionOptions().bUseLanguageIdentification) { const std::vector Candidates = GetCandidateLanguages(); @@ -193,15 +200,11 @@ bool FAzSpeechRecognitionRunnableBase::InitializeAzureObject() return false; } - SpeechRecognizer = MicrosoftSpeech::SpeechRecognizer::FromConfig(SpeechConfig, MicrosoftSpeech::AutoDetectSourceLanguageConfig::FromLanguages(Candidates), GetAudioConfig()); - } - else if (const std::shared_ptr TaskAudioConfig = GetAudioConfig()) - { - SpeechRecognizer = MicrosoftSpeech::SpeechRecognizer::FromConfig(SpeechConfig, TaskAudioConfig); + SpeechRecognizer = MicrosoftSpeech::SpeechRecognizer::FromConfig(SpeechConfig, MicrosoftSpeech::AutoDetectSourceLanguageConfig::FromLanguages(Candidates), TaskAudioConfig); } else { - return false; + SpeechRecognizer = MicrosoftSpeech::SpeechRecognizer::FromConfig(SpeechConfig, TaskAudioConfig); } return InsertPhraseList() && ConnectRecognitionStartedSignals() && ConnectRecognitionUpdatedSignals(); diff --git a/Source/AzSpeech/Private/AzSpeech/Runnables/Synthesis/AzSpeechSynthesisRunnable.cpp b/Source/AzSpeech/Private/AzSpeech/Runnables/Synthesis/AzSpeechSynthesisRunnable.cpp index ce31ac4..1ad3d42 100644 --- a/Source/AzSpeech/Private/AzSpeech/Runnables/Synthesis/AzSpeechSynthesisRunnable.cpp +++ b/Source/AzSpeech/Private/AzSpeech/Runnables/Synthesis/AzSpeechSynthesisRunnable.cpp @@ -181,18 +181,21 @@ bool FAzSpeechSynthesisRunnable::InitializeAzureObject() ApplySDKSettings(SpeechConfig); - if (!SynthesizerTask->IsSSMLBased() && SynthesizerTask->GetSynthesisOptions().bUseLanguageIdentification) + const auto TaskAudioConfig = GetAudioConfig(); + if (!SpeechConfig) { - UE_LOG(LogAzSpeech_Internal, Display, TEXT("Thread: %s; Function: %s; Message: Initializing auto language detection"), *GetThreadName(), *FString(__func__)); - SpeechSynthesizer = MicrosoftSpeech::SpeechSynthesizer::FromConfig(SpeechConfig, MicrosoftSpeech::AutoDetectSourceLanguageConfig::FromOpenRange(), GetAudioConfig()); + UE_LOG(LogAzSpeech_Internal, Error, TEXT("Thread: %s; Function: %s; Message: Invalid audio config"), *GetThreadName(), *FString(__func__)); + return false; } - else if (const std::shared_ptr TaskAudioConfig = GetAudioConfig()) + + if (!SynthesizerTask->IsSSMLBased() && SynthesizerTask->GetSynthesisOptions().bUseLanguageIdentification) { - SpeechSynthesizer = MicrosoftSpeech::SpeechSynthesizer::FromConfig(SpeechConfig, TaskAudioConfig); + UE_LOG(LogAzSpeech_Internal, Display, TEXT("Thread: %s; Function: %s; Message: Initializing auto language detection"), *GetThreadName(), *FString(__func__)); + SpeechSynthesizer = MicrosoftSpeech::SpeechSynthesizer::FromConfig(SpeechConfig, MicrosoftSpeech::AutoDetectSourceLanguageConfig::FromOpenRange(), TaskAudioConfig); } else { - return false; + SpeechSynthesizer = MicrosoftSpeech::SpeechSynthesizer::FromConfig(SpeechConfig, TaskAudioConfig); } return ConnectVisemeSignal() && ConnectSynthesisStartedSignal() && ConnectSynthesisUpdateSignals();