1
This commit is contained in:
57
keyBoard/Class/AiTalk/VM/VoiceChatWebSocketClient.h
Normal file
57
keyBoard/Class/AiTalk/VM/VoiceChatWebSocketClient.h
Normal file
@@ -0,0 +1,57 @@
|
||||
//
|
||||
// VoiceChatWebSocketClient.h
|
||||
// keyBoard
|
||||
//
|
||||
// Created by Mac on 2026/1/21.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@protocol VoiceChatWebSocketClientDelegate <NSObject>
|
||||
@optional
|
||||
- (void)voiceChatClientDidConnect;
|
||||
- (void)voiceChatClientDidDisconnect:(NSError *_Nullable)error;
|
||||
- (void)voiceChatClientDidStartSession:(NSString *)sessionId;
|
||||
- (void)voiceChatClientDidStartTurn:(NSInteger)turnIndex;
|
||||
- (void)voiceChatClientDidReceiveEagerEndOfTurnWithTranscript:(NSString *)text
|
||||
confidence:(double)confidence;
|
||||
- (void)voiceChatClientDidResumeTurn;
|
||||
- (void)voiceChatClientDidReceiveInterimTranscript:(NSString *)text;
|
||||
- (void)voiceChatClientDidReceiveFinalTranscript:(NSString *)text;
|
||||
- (void)voiceChatClientDidReceiveLLMStart;
|
||||
- (void)voiceChatClientDidReceiveLLMToken:(NSString *)token;
|
||||
- (void)voiceChatClientDidReceiveAudioChunk:(NSData *)audioData;
|
||||
- (void)voiceChatClientDidCompleteWithTranscript:(NSString *)transcript
|
||||
aiResponse:(NSString *)aiResponse;
|
||||
- (void)voiceChatClientDidReceiveErrorCode:(NSString *)code
|
||||
message:(NSString *)message;
|
||||
- (void)voiceChatClientDidFail:(NSError *)error;
|
||||
@end
|
||||
|
||||
/// WebSocket client for realtime voice chat.
|
||||
@interface VoiceChatWebSocketClient : NSObject
|
||||
|
||||
@property(nonatomic, weak) id<VoiceChatWebSocketClientDelegate> delegate;
|
||||
|
||||
/// Base WebSocket URL, e.g. wss://api.yourdomain.com/api/ws/chat
|
||||
@property(nonatomic, copy) NSString *serverURL;
|
||||
|
||||
@property(nonatomic, assign, readonly, getter=isConnected) BOOL connected;
|
||||
@property(nonatomic, copy, readonly, nullable) NSString *sessionId;
|
||||
|
||||
- (void)connectWithToken:(NSString *)token;
|
||||
- (void)disconnect;
|
||||
|
||||
- (void)startSessionWithLanguage:(nullable NSString *)language
|
||||
voiceId:(nullable NSString *)voiceId;
|
||||
- (void)enableAudioSending;
|
||||
- (void)disableAudioSending;
|
||||
- (void)sendAudioPCMFrame:(NSData *)pcmFrame;
|
||||
- (void)endAudio;
|
||||
- (void)cancel;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
Reference in New Issue
Block a user