53 lines
1.5 KiB
Objective-C
53 lines
1.5 KiB
Objective-C
//
|
|
// DeepgramWebSocketClient.h
|
|
// keyBoard
|
|
//
|
|
// Created by Mac on 2026/1/21.
|
|
//
|
|
|
|
#import <Foundation/Foundation.h>
|
|
|
|
NS_ASSUME_NONNULL_BEGIN
|
|
|
|
@protocol DeepgramWebSocketClientDelegate <NSObject>
|
|
@optional
|
|
- (void)deepgramClientDidConnect;
|
|
- (void)deepgramClientDidDisconnect:(NSError *_Nullable)error;
|
|
- (void)deepgramClientDidReceiveInterimTranscript:(NSString *)text;
|
|
- (void)deepgramClientDidReceiveFinalTranscript:(NSString *)text;
|
|
- (void)deepgramClientDidFail:(NSError *)error;
|
|
@end
|
|
|
|
/// WebSocket client for Deepgram live transcription.
|
|
@interface DeepgramWebSocketClient : NSObject
|
|
|
|
@property(nonatomic, weak) id<DeepgramWebSocketClientDelegate> delegate;
|
|
|
|
@property(nonatomic, copy) NSString *serverURL; // wss://api.deepgram.com/v1/listen
|
|
@property(nonatomic, copy) NSString *apiKey;
|
|
|
|
@property(nonatomic, copy, nullable) NSString *language;
|
|
@property(nonatomic, copy, nullable) NSString *model;
|
|
@property(nonatomic, assign) BOOL punctuate;
|
|
@property(nonatomic, assign) BOOL smartFormat;
|
|
@property(nonatomic, assign) BOOL interimResults;
|
|
|
|
@property(nonatomic, copy) NSString *encoding; // linear16
|
|
@property(nonatomic, assign) double sampleRate;
|
|
@property(nonatomic, assign) int channels;
|
|
|
|
@property(nonatomic, assign, readonly, getter=isConnected) BOOL connected;
|
|
|
|
- (void)connect;
|
|
- (void)disconnect;
|
|
- (void)sendAudioPCMFrame:(NSData *)pcmFrame;
|
|
- (void)finish;
|
|
- (void)sendKeepAlive;
|
|
|
|
- (void)enableAudioSending;
|
|
- (void)disableAudioSending;
|
|
|
|
@end
|
|
|
|
NS_ASSUME_NONNULL_END
|