添加语音websocket等,还没测试
This commit is contained in:
37
keyBoard/Class/AiTalk/VM/Segmenter.h
Normal file
37
keyBoard/Class/AiTalk/VM/Segmenter.h
Normal file
@@ -0,0 +1,37 @@
|
||||
//
|
||||
// Segmenter.h
|
||||
// keyBoard
|
||||
//
|
||||
// Created by Mac on 2026/1/15.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/// 句子切分器
|
||||
/// 将 LLM 输出的 token 流切分成可触发 TTS 的句子片段
|
||||
@interface Segmenter : NSObject
|
||||
|
||||
/// 累积字符数阈值(超过此值强制切分)
|
||||
/// 默认:30
|
||||
@property(nonatomic, assign) NSUInteger maxCharacterThreshold;
|
||||
|
||||
/// 追加 token
|
||||
/// @param token LLM 输出的 token
|
||||
- (void)appendToken:(NSString *)token;
|
||||
|
||||
/// 获取并移除已准备好的片段
|
||||
/// @return 可立即进行 TTS 的片段数组
|
||||
- (NSArray<NSString *> *)popReadySegments;
|
||||
|
||||
/// 获取剩余的未完成片段(用于最后 flush)
|
||||
/// @return 剩余片段,可能为空
|
||||
- (NSString *)flushRemainingSegment;
|
||||
|
||||
/// 重置状态
|
||||
- (void)reset;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
Reference in New Issue
Block a user