2026-01-26 18:43:07 +08:00
|
|
|
//
|
|
|
|
|
// KBVoiceToTextManager.m
|
|
|
|
|
// keyBoard
|
|
|
|
|
//
|
|
|
|
|
// Created by Mac on 2026/1/26.
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
#import "KBVoiceToTextManager.h"
|
|
|
|
|
#import "KBVoiceInputBar.h"
|
2026-03-07 13:29:29 +08:00
|
|
|
#import "KBLocalizationManager.h"
|
2026-01-26 18:43:07 +08:00
|
|
|
|
2026-03-08 21:29:10 +08:00
|
|
|
@interface KBVoiceToTextManager () <KBVoiceInputBarDelegate>
|
2026-01-26 18:43:07 +08:00
|
|
|
|
|
|
|
|
@property(nonatomic, weak) KBVoiceInputBar *inputBar;
|
|
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
@implementation KBVoiceToTextManager
|
|
|
|
|
|
|
|
|
|
- (instancetype)initWithInputBar:(KBVoiceInputBar *)inputBar {
|
|
|
|
|
self = [super init];
|
|
|
|
|
if (self) {
|
|
|
|
|
_inputBar = inputBar;
|
|
|
|
|
_inputBar.delegate = self;
|
|
|
|
|
}
|
|
|
|
|
return self;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#pragma mark - KBVoiceInputBarDelegate
|
|
|
|
|
|
|
|
|
|
- (void)voiceInputBarDidBeginRecording:(KBVoiceInputBar *)inputBar {
|
2026-03-08 21:29:10 +08:00
|
|
|
inputBar.statusText = KBLocalized(@"Voice Recording...");
|
2026-01-26 18:43:07 +08:00
|
|
|
|
|
|
|
|
if ([self.delegate respondsToSelector:@selector
|
|
|
|
|
(voiceToTextManagerDidBeginRecording:)]) {
|
|
|
|
|
[self.delegate voiceToTextManagerDidBeginRecording:self];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)voiceInputBarDidEndRecording:(KBVoiceInputBar *)inputBar {
|
2026-03-08 21:29:10 +08:00
|
|
|
inputBar.statusText = KBLocalized(@"Voice Recording Ended");
|
2026-01-26 18:43:07 +08:00
|
|
|
|
|
|
|
|
if ([self.delegate respondsToSelector:@selector
|
|
|
|
|
(voiceToTextManagerDidEndRecording:)]) {
|
|
|
|
|
[self.delegate voiceToTextManagerDidEndRecording:self];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)voiceInputBarDidCancelRecording:(KBVoiceInputBar *)inputBar {
|
2026-03-07 13:29:29 +08:00
|
|
|
inputBar.statusText = KBLocalized(@"Voice Cancelled");
|
2026-01-26 18:43:07 +08:00
|
|
|
|
|
|
|
|
if ([self.delegate respondsToSelector:@selector
|
|
|
|
|
(voiceToTextManagerDidCancelRecording:)]) {
|
|
|
|
|
[self.delegate voiceToTextManagerDidCancelRecording:self];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@end
|