@aim-packages/subtitle 0.1.4 → 0.1.6

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
@@ -312,6 +312,21 @@ declare function chunkArrayStrings(strings: string[], characterLimit: number): s
312
312
  match: string;
313
313
  }[];
314
314
 
315
+ /**
316
+ * 修复whisper json的解码问题
317
+ *
318
+ * @export
319
+ * @param {Buffer} inputBuffer 读取的json文件
320
+ * @return {*}
321
+ * @example
322
+ *
323
+ * const { readFile, writeFile } = require("fs/promises");
324
+ * const inputJsonBuffer = await readFile(inputPath)
325
+ * fixWhisperJsonDecode(inputJsonBuffer)
326
+ *
327
+ */
328
+ declare function fixWhisperJsonDecode(inputBuffer: Buffer): Promise<any>;
329
+
315
330
  /**
316
331
  * 将秒数转换为 xx:xx:xx.xxx 格式
317
332
  *
@@ -463,6 +478,7 @@ declare function chunkArrayStrings(strings: string[], characterLimit: number): s
463
478
  assToAimSegments,
464
479
  tingwuToAimSegments,
465
480
  openaiToAimSegments,
481
+ whisperJsonToAimSegments,
466
482
  create as createWhisperStreamParser,
467
483
  create_2 as createTranslateStreamParser,
468
484
  create_3 as createSegmentStreamParser
@@ -706,7 +722,8 @@ declare function chunkArrayStrings(strings: string[], characterLimit: number): s
706
722
  outputLrc,
707
723
  outputTxt,
708
724
  outputMarkdown,
709
- outputAss
725
+ outputAss,
726
+ fixWhisperJsonDecode
710
727
  }
711
728
  }
712
729
 
@@ -745,4 +762,37 @@ declare function chunkArrayStrings(strings: string[], characterLimit: number): s
745
762
  fontFile?: string;
746
763
  };
747
764
 
765
+ declare interface WhisperJSONResult {
766
+ "result": {
767
+ "language": string;
768
+ };
769
+ "transcription": Array<{
770
+ "timestamps": {
771
+ "from": string;
772
+ "to": string;
773
+ };
774
+ "offsets": {
775
+ "from": number;
776
+ "to": number;
777
+ };
778
+ "text": string;
779
+ "tokens": Array<{
780
+ "text": string;
781
+ "timestamps": {
782
+ "from": string;
783
+ "to": string;
784
+ };
785
+ "offsets": {
786
+ "from": number;
787
+ "to": number;
788
+ };
789
+ "id": number;
790
+ "p": number;
791
+ "t_dtw": number;
792
+ }>;
793
+ }>;
794
+ }
795
+
796
+ declare function whisperJsonToAimSegments(json: WhisperJSONResult): Promise<AimSegments[]>;
797
+
748
798
  export { }