dsh-vidi 0.7.3 → 0.7.4

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.
Files changed (2) hide show
  1. package/lib/index.mjs +16 -3
  2. package/package.json +1 -1
package/lib/index.mjs CHANGED
@@ -4732,6 +4732,8 @@ const HARD_CJK = 34;
4732
4732
  const HARD_LATIN = 110;
4733
4733
  /** A stream quiet this long ends its sentence (a pause without punctuation). */
4734
4734
  const QUIET_SEC = 1.6;
4735
+ /** …or this long when it is only a few words so far. */
4736
+ const QUIET_SHORT_SEC = 3.5;
4735
4737
  /**
4736
4738
  * Builds sentences from one text stream. The service stamps every delta
4737
4739
  * with the audio position it was produced at (elapsed_ms); a sentence's
@@ -4813,7 +4815,13 @@ var Stream = class {
4813
4815
  }
4814
4816
  close() {
4815
4817
  const text = this.text.trim();
4816
- if (text) this.done.push({
4818
+ const prev = this.done.at(-1);
4819
+ if (text && !/[\p{L}\p{N}]/u.test(text)) {
4820
+ if (prev) {
4821
+ prev.text += text;
4822
+ prev.end = Math.max(prev.end, this.open.at(-1).t);
4823
+ }
4824
+ } else if (text) this.done.push({
4817
4825
  text,
4818
4826
  start: this.open[0].t,
4819
4827
  end: this.open.at(-1).t,
@@ -4821,6 +4829,11 @@ var Stream = class {
4821
4829
  });
4822
4830
  this.open = [];
4823
4831
  }
4832
+ /** Long enough to stand as a line of its own (when cutting without punctuation). */
4833
+ get substantial() {
4834
+ const text = this.text.trim();
4835
+ return (this.cjk ? Array.from(text).length : text.length) >= (this.cjk ? 10 : 24);
4836
+ }
4824
4837
  };
4825
4838
  /**
4826
4839
  * OpenAI live interpretation (gpt-realtime-translate): audio streams in, the
@@ -4969,7 +4982,7 @@ var OpenAITranslateProvider = class {
4969
4982
  else {
4970
4983
  const next = this.src.done[this.srcUsed];
4971
4984
  if (next && this.tr.text.trim() && t - next.end >= 1.2) {
4972
- if (!this.tr.closeAtPause() && t - next.end >= 3) this.tr.close();
4985
+ if (!this.tr.closeAtPause() && t - next.end >= 3 && this.tr.substantial) this.tr.close();
4973
4986
  }
4974
4987
  this.tr.add(piece);
4975
4988
  }
@@ -4979,7 +4992,7 @@ var OpenAITranslateProvider = class {
4979
4992
  }
4980
4993
  /** Close streams that went quiet (a pause without punctuation), then pair what is complete. */
4981
4994
  settle() {
4982
- for (const s of [this.src, this.tr]) if (s.last !== void 0 && Date.now() - s.lastWall > QUIET_SEC * 1e3) s.close();
4995
+ for (const s of [this.src, this.tr]) if (s.last !== void 0 && Date.now() - s.lastWall > (s.substantial ? QUIET_SEC : QUIET_SHORT_SEC) * 1e3) s.close();
4983
4996
  this.pair(false);
4984
4997
  this.draft();
4985
4998
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-vidi",
3
- "version": "0.7.3",
3
+ "version": "0.7.4",
4
4
  "description": "A video tool for DeepSeek Harness: watch live streams, videos and podcasts with real-time subtitles in any language, then clip and download",
5
5
  "type": "module",
6
6
  "license": "PolyForm-Noncommercial-1.0.0",