Open chingizagha opened 1 year ago
bump
The implementation doesn't currently provide a way to stop a speech before it reaches its natural conclusion. You will have to implement your own StopSpeech() method in the SpeechComponent class.
If you do implement this feature, please consider contributing it back to this project via pull request!
Since i am using this just for a PoC i dont have the time right now to implement it properly. For everyone interested, i picked up @Krxtopher suggestion and implemented a hacky "StopSpeech()" function.
File: SpeecComponent.cpp
void USpeechComponent::StopSpeaking() {
FScopeLock lock(&Mutex);
VisemeEvent CurrentVisemeEvent;
CurrentVisemeEvent.Viseme = GetVisemeValueFromString("sil"); // Reset to the silent visme otherwise we get stuck with the last visme
CurrentVisemeEvent.TimeMilliseconds = 100;
VisemeEventArray.Empty();
VisemeEventArray.Add(CurrentVisemeEvent);
CurrentVisemeIndex = -1; // Current Index - 1 because the Function PlayNextVisme will get invoced and increase the CurrentVisemeIndex by 1;
return;
}
File: SpeecComponent.h
/*
* Stops Speaking
*/
UFUNCTION(BlueprintCallable, Category = "Amazon Polly")
void StopSpeaking();
Build the solution and you should be ready to get the "StopSpeaking" Function in your characters blueprint. In Case you are wondering how to stop the sound as well: i changed the "playSound2D" with "spawnSound2D" which allowed me to get a reference and simple stopping it via the soundcomponent "stop" function after calling the "StopSpeaking" method.
I am not a C++, nor an unreal developer, so i am welcome for any feedback.
@zvaehn I entered the C++ you provided well, but When I run the project, it crashes.
Ah, it's solved. CurrentVisemeIndex = -1; It was solved by setting it to 0 instead of -1.
How I can make to stop speech?