1
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user