目录
作用:右键 对象 拖出来的时候,看到函数的类别名字:
作用:右键 对象 拖出来的时候,看到函数的类别名字:
D:\WebSocketClient.h
#pragma once #include "CoreMinimal.h" #include "UObject/Object.h" #include "IWebSocket.h" #include "WebSocketClient.generated.h" DECLARE_DYNAMIC_MULTICAST_DELEGATE(FOnWebSocketConnected); DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnTTSFinished, const FString&, WavPath); UCLASS(Blueprintable, BlueprintType) class METAHUMANCHARACTERHEIXI_API UWebSocketClient : public UObject { GENERATED_BODY() public: UFUNCTION(BlueprintCallable, Category = "WebSocket") void Connect(const FString& Url); UFUNCTION(BlueprintCallable, Category = "TTS") void SendTextChunk(const FString& Text, const FString& Speaker, int32 ChunkId); UPROPERTY(BlueprintAssignable, Category = "WebSocket") FOnWebSocketConnected OnConnectedEvent; UPROPERTY(BlueprintAssignable, Category = "TTS") FOnTTSFinished OnTTSFinished; private: TSharedPtr<IWebSocket> WebSocket; // 音频缓存 TArray<uint8> ReceivedPCM; int32 SampleRate = 16000; int32 NumChannels = 1; // WebSocket回调 void OnConnected(); void OnMessageReceived(const FString& Message); void OnConnectionError(const FString& Error); void OnClosed(int32 StatusCode, const FString& Reason, bool bWasClean); void SaveWav(const FString& FilePath); };