This commit is contained in:
2026-01-27 16:28:17 +08:00
parent ce889e1ed0
commit 2b749cd2b0
26 changed files with 1092 additions and 128 deletions

View File

@@ -46,6 +46,12 @@
@implementation KBAiMessageResponse
@end
@implementation KBAiSpeechTranscribeData
@end
@implementation KBAiSpeechTranscribeResponse
@end
@implementation AiVM
- (void)syncChatWithTranscript:(NSString *)transcript
@@ -126,15 +132,16 @@ autoShowBusinessError:NO
completion:^(NSDictionary *_Nullable json,
NSURLResponse *_Nullable response,
NSError *_Nullable error) {
KBAiMessageResponse *model =
[KBAiMessageResponse mj_objectWithKeyValues:json];
if (error) {
if (completion) {
completion(nil, error);
completion(model, error);
}
return;
}
KBAiMessageResponse *model =
[KBAiMessageResponse mj_objectWithKeyValues:json];
id dataObj = json[@"data"];
if (!model.data && [dataObj isKindOfClass:[NSString class]]) {
KBAiMessageData *data = [[KBAiMessageData alloc] init];
@@ -261,6 +268,42 @@ autoShowBusinessError:NO
}];
}
- (void)transcribeAudioFileAtURL:(NSURL *)fileURL
completion:(AiVMSpeechTranscribeCompletion)completion {
if (!fileURL || !fileURL.isFileURL) {
NSError *error = [NSError errorWithDomain:@"AiVM"
code:-1
userInfo:@{NSLocalizedDescriptionKey : @"invalid fileURL"}];
if (completion) {
completion(nil, error);
}
return;
}
[[KBNetworkManager shared] uploadFile:API_AI_SPEECH_TRANSCRIBE
fileURL:fileURL
name:@"file"
mimeType:@"audio/m4a"
parameters:nil
headers:nil
completion:^(NSDictionary *_Nullable json,
NSURLResponse *_Nullable response,
NSError *_Nullable error) {
if (error) {
if (completion) {
completion(nil, error);
}
return;
}
KBAiSpeechTranscribeResponse *model =
[KBAiSpeechTranscribeResponse mj_objectWithKeyValues:json];
if (completion) {
completion(model, nil);
}
}];
}
#pragma mark -
- (void)fetchPersonasWithPageNum:(NSInteger)pageNum