@aim-packages/subtitle 0.0.8 → 0.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -66,6 +66,15 @@ declare interface AimSegments {
66
66
 
67
67
  declare function assToAimSegments(text: string): Promise<AimSegments[]>;
68
68
 
69
+ declare function chunkArrayStrings(strings: string[], characterLimit: number): string[];
70
+
71
+ declare function chunkSegmentStringsWithIndex(segments: AimSegments[], characterLimit: number): {
72
+ segmentsResult: AimSegments[][];
73
+ stringResult: string[];
74
+ indexStringResult: string[];
75
+ indexResult: number[];
76
+ };
77
+
69
78
  /**
70
79
  * 匹配中文、日文、韩文字符的正则表达式
71
80
  *
@@ -99,6 +108,15 @@ declare function create(options?: ParserOptions<AimSegments[], AimSegments[], st
99
108
 
100
109
  declare function create_2(options?: ParserOptions<RequiredByKey<Partial<AimSegments>, "index">[], Partial<AimSegments>[], string>): Parser<string>;
101
110
 
111
+ declare function create_3(options?: ParserOptions<AimSegments[], AimSegments[], AimSegments[]> & {
112
+ sentenceLength?: number;
113
+ repeatString?: string[];
114
+ }): Parser<AimSegments[]>;
115
+
116
+ declare function detectAllLanguage(text: string): LanguageDetectionResultsEntry[];
117
+
118
+ declare function detectLanguage(text: string): LanguageDetectionResultsEntry;
119
+
102
120
  export declare namespace filter {
103
121
  export {
104
122
  StreamFilter
@@ -114,6 +132,23 @@ export declare namespace filter {
114
132
  */
115
133
  declare function formatTime(seconds: number): string;
116
134
 
135
+ declare type LanguageCode = "auto" | "none" | "zh" | "zh_cn" | "zh_tw" | "yue" | "en" | "ja" | "ko" | "fr" | "es" | "ru" | "de" | "it" | "tr" | "pt" | "vi" | "id" | "th" | "ms" | "ar" | "hi" | "ro" | "ug" | "uz" | "kk" | "az" | "ky" | "fa" | "tg";
136
+
137
+ /**
138
+ * 将语言代码转换为名称
139
+ *
140
+ * @export
141
+ * @param {LanguageCode} languageCode
142
+ * @return {*}
143
+ */
144
+ declare function languageCodeToName(languageCode: LanguageCode): string;
145
+
146
+ declare interface LanguageDetectionResultsEntry {
147
+ language: LanguageCode;
148
+ languageName: string;
149
+ probability: number;
150
+ }
151
+
117
152
  declare interface OpenAIResult {
118
153
  task: string;
119
154
  language: string;
@@ -194,7 +229,8 @@ export declare namespace parser {
194
229
  tingwuToAimSegments,
195
230
  openaiToAimSegments,
196
231
  create as createWhisperStreamParser,
197
- create_2 as createTranslateStreamParser
232
+ create_2 as createTranslateStreamParser,
233
+ create_3 as createSegmentStreamParser
198
234
  }
199
235
  }
200
236
 
@@ -236,6 +272,8 @@ declare interface RepeatCheckOption {
236
272
 
237
273
  declare type RequiredByKey<T, K extends keyof T> = Omit<T, K> & Required<Pick<T, K>>;
238
274
 
275
+ declare function splitToSentences(text: string, languageCode?: LanguageCode): string[];
276
+
239
277
  declare function srtToAimSegments(text: string): Promise<AimSegments[]>;
240
278
 
241
279
  declare class StreamFilter {
@@ -305,7 +343,11 @@ export declare namespace tools {
305
343
  subtitleOptimization,
306
344
  RepeatCheckOption,
307
345
  RepeatCheck,
308
- subtitleOptimizationRegExp
346
+ subtitleOptimizationRegExp,
347
+ detectAllLanguage,
348
+ detectLanguage,
349
+ LanguageDetectionResultsEntry,
350
+ splitToSentences
309
351
  }
310
352
  }
311
353
 
@@ -314,7 +356,10 @@ export declare namespace utils {
314
356
  padNumber,
315
357
  formatTime,
316
358
  convertToSeconds,
317
- containsCJKCharacters
359
+ containsCJKCharacters,
360
+ languageCodeToName,
361
+ chunkArrayStrings,
362
+ chunkSegmentStringsWithIndex
318
363
  }
319
364
  }
320
365