dsh-voice 0.9.1 → 0.10.0

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/lib/stt.d.ts CHANGED
@@ -39,6 +39,10 @@ export interface OversizeAudioPreparation {
39
39
  chunks: PreparedAudioChunk[];
40
40
  cleanup: () => void;
41
41
  }
42
+ /**
43
+ * 判断文件路径是否为常见视频封装容器(故意不含 `.webm`,确保浏览器麦克风录音无需本地 ffmpeg 即可直接转写)。
44
+ */
45
+ export declare function isVideoContainerFile(filePath: string): boolean;
42
46
  /** 字节数超过 25MB 时抛错:调用方可在读文件前先按 statSync 大小快速拒绝,避免白读整文件。 */
43
47
  export declare function assertAudioSize(bytes: number): void;
44
48
  /** 传给 transcribe 的 fetch:可以像代理那样一并带上自己的 FormData/Blob 构造器。 */
package/lib/stt.js CHANGED
@@ -11,6 +11,25 @@ import { isLoopbackBaseUrl } from './config.js';
11
11
  const MAX_AUDIO_BYTES = 25 * 1024 * 1024;
12
12
  const COMPRESSED_CHUNK_LIMIT_BYTES = 24 * 1024 * 1024;
13
13
  const SEGMENT_DURATION_SECONDS = 1200;
14
+ const VIDEO_CONTAINER_EXTENSIONS = new Set([
15
+ '.mp4',
16
+ '.mkv',
17
+ '.mov',
18
+ '.avi',
19
+ '.flv',
20
+ '.wmv',
21
+ '.m4v',
22
+ '.ts',
23
+ '.mts',
24
+ ]);
25
+ /**
26
+ * 判断文件路径是否为常见视频封装容器(故意不含 `.webm`,确保浏览器麦克风录音无需本地 ffmpeg 即可直接转写)。
27
+ */
28
+ export function isVideoContainerFile(filePath) {
29
+ if (typeof filePath !== 'string' || filePath.trim() === '')
30
+ return false;
31
+ return VIDEO_CONTAINER_EXTENSIONS.has(extname(filePath.trim()).toLowerCase());
32
+ }
14
33
  /** 字节数超过 25MB 时抛错:调用方可在读文件前先按 statSync 大小快速拒绝,避免白读整文件。 */
15
34
  export function assertAudioSize(bytes) {
16
35
  if (bytes > MAX_AUDIO_BYTES) {
package/lib/tools.d.ts CHANGED
@@ -2,7 +2,7 @@ import { type ResolvedVoiceConfig } from './config.js';
2
2
  import { fetchEdgeVoices, synthesizeSpeech, synthesizeSpeechWithMetadata } from './edge-tts.js';
3
3
  import { synthesizeOpenAiSpeech } from './openai-tts.js';
4
4
  import { prepareAudioForAsr, splitStereoChannelsForDiarization, transcribe } from './stt.js';
5
- import { mixAudioWithBgm, normalizeAudioLoudness } from './tts-text.js';
5
+ import { fitAudioToWindow, mixAudioWithBgm, normalizeAudioLoudness } from './tts-text.js';
6
6
  /** 模型可见的内容块。 */
7
7
  export interface ContentBlock {
8
8
  type: 'text';
@@ -38,6 +38,7 @@ export interface VoiceToolDeps {
38
38
  normalizeAudio?: typeof normalizeAudioLoudness;
39
39
  mixBgm?: typeof mixAudioWithBgm;
40
40
  splitStereo?: typeof splitStereoChannelsForDiarization;
41
+ fitWindow?: typeof fitAudioToWindow;
41
42
  }
42
43
  /**
43
44
  * 构建五个语音工具定义(支持静态配置对象或活引用配置 getter)。