Files
keyboard/keyBoard/Class/AiTalk/VM/Segmenter.h

38 lines
816 B
Objective-C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// 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