@joplo-app/server 0.2.17 → 0.2.18

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/voice.d.ts CHANGED
@@ -1,101 +1,151 @@
1
1
  import { DEFAULT_STYLE, type Project, type VoiceConfig, type VoiceIndex } from '@joplo-app/core';
2
+ import type { CloudSpeechResult, CloudVoiceBridge, CloudVoiceCatalog } from './cloud.js';
2
3
  export { DEFAULT_STYLE };
3
- export type ProfileKind = 'openai' | 'elevenlabs' | 'http';
4
- /** 返回内容:音频文件本身;JSON 里的 base64;JSON 里的音频链接。 */
4
+ export type CloudCatalog = CloudVoiceCatalog;
5
+ /** 声音来源的类型。http 只出现在本机旧的 profile 里(不再支持)。 */
6
+ export type ProfileKind = 'cloud' | 'openai' | 'elevenlabs' | 'http';
7
+ /** 返回内容:音频文件本身;JSON 里的 base64;JSON 里的音频链接。后两种只出现在旧的 profile 里,只用于算指纹。 */
5
8
  export type ResponseMode = 'audio' | 'json-base64' | 'json-url';
6
- export type PresetId = 'openai' | 'elevenlabs' | 'aihubmix';
9
+ export type PresetId = 'cloud' | 'openai' | 'elevenlabs';
7
10
  export type VoiceProfile = {
8
11
  id: string;
9
12
  name: string;
10
13
  kind: ProfileKind;
11
14
  preset?: PresetId;
12
- /** openai / elevenlabs:接口根地址(例如 https://api.openai.com/v1);http:完整的请求地址。 */
15
+ /** openai / elevenlabs:固定的官方接口根地址;cloud:空(用 CLI 登录的服务器);旧 profile:原来的地址(只用于算指纹)。 */
13
16
  baseUrl: string;
14
17
  model: string;
15
- /** 默认音色(旁白);elevenlabs 是 voice_id。 */
18
+ /** 默认音色(旁白);elevenlabs 是 voice_id;cloud 是 Joplo 音色 id。 */
16
19
  voice: string;
17
20
  response: ResponseMode;
18
- /** response 是 JSON 时音频所在的字段路径,例如 data.audio、choices.0.audio。 */
19
21
  path?: string;
20
- /** 额外请求头;值里的 {{key}} 换成 Key。http 类型不写时用 Authorization: Bearer {{key}}。 */
21
22
  headers?: Record<string, string>;
22
- /** http 类型的请求体模板(JSON),{{text}} {{voice}} {{model}} 换成对应的值(已按 JSON 字符串转义)。 */
23
23
  body?: string;
24
- /** 说话风格(OpenAI 兼容接口的 instructions;tts-1 系列不支持,不发)。缺省用 DEFAULT_STYLE。 */
24
+ /** 说话风格(OpenAI 的 instructions;tts-1 系列不支持,不发)。缺省用 DEFAULT_STYLE。 */
25
25
  style?: string;
26
26
  key?: string;
27
+ /** 不再支持的旧 profile(D85):不能再生成;声音指纹不变,已生成的音频照常播放与发布。由 ProfileStore 标出,不写进文件。 */
28
+ unsupported?: true;
29
+ /** 旧 id=cloud 的持久兼容别名;新项目默认 cloud 与明确选择官方 cloud 不使用它。 */
30
+ legacyId?: 'cloud';
27
31
  };
28
- /** 预设音色:名字、性别、口音(BCP-47,没有表示多语言通用)、是否推荐。看板按旁白语言排序、按界面语言显示说明。 */
32
+ /**
33
+ * 预设音色:名字、性别、口音(BCP-47,没有表示多语言通用)、是否推荐。看板按旁白语言排序、按界面语言显示说明。
34
+ * cloud 的音色另有 labels(按界面语言的名字)与 samples(按界面语言的样音地址,试听不扣字数)。
35
+ */
29
36
  export type VoiceChoice = {
30
37
  id: string;
31
38
  name: string;
32
39
  gender: 'female' | 'male' | 'neutral';
33
40
  accent?: string;
34
41
  recommended?: boolean;
42
+ labels?: Record<string, string>;
43
+ samples?: Record<string, string>;
35
44
  };
36
- export type PublicProfile = Omit<VoiceProfile, 'key'> & {
45
+ export type PublicProfile = Omit<VoiceProfile, 'key' | 'unsupported'> & {
37
46
  key: {
38
47
  saved: boolean;
39
48
  hint: string | null;
40
49
  env: string | null;
41
50
  envSet: boolean;
42
51
  };
43
- /** 这个接口的预设音色(看板里作为候选;可以填别的)。 */
52
+ /** 这个来源的音色候选。 */
44
53
  voices: VoiceChoice[];
45
- /** 可以删除(自建的);预设只能恢复默认。 */
54
+ /** 可以删除(本机旧的 profile);预设只能恢复默认。 */
46
55
  removable: boolean;
56
+ /** 不再支持(D85):看板标出,不能再生成。 */
57
+ unsupported: boolean;
58
+ };
59
+ /** Joplo Cloud 的 6 个音色 id(契约固定,都是多语言);云端连不上时用它们和下面的英文标签。 */
60
+ export declare const CLOUD_VOICE_IDS: readonly ["narrator-warm-f", "narrator-calm-m", "bright-f", "friendly-m", "clear-f", "deep-m"];
61
+ export declare const CLOUD_DEFAULT_VOICE = "narrator-warm-f";
62
+ export declare const BUILTIN_CLOUD_CATALOG: CloudCatalog;
63
+ /** OpenAI / ElevenLabs 的官方地址(D85:固定,不能改)。 */
64
+ export declare const OFFICIAL_BASE_URL: {
65
+ readonly openai: "https://api.openai.com/v1";
66
+ readonly elevenlabs: "https://api.elevenlabs.io/v1";
47
67
  };
48
68
  type Preset = Omit<VoiceProfile, 'key' | 'id'> & {
49
69
  id: PresetId;
50
- env: string;
70
+ env: string | null;
51
71
  voices: VoiceChoice[];
52
72
  };
73
+ /** 预设:Joplo Cloud 朗读排第一(D85)。 */
53
74
  export declare const PRESETS: Preset[];
75
+ /** 声音来源的错误码;cloud 的错误码与 CloudVoiceBridge.speech 抛出的一致。 */
76
+ export type VoiceErrorCode = 'NO_KEY' | 'HTTP' | 'NOT_AUDIO' | 'BAD_RESPONSE' | 'NETWORK' | 'TOO_LARGE' | 'INVALID' | 'NOT_FOUND' | 'BUSY'
77
+ /** 不再支持的旧 profile(D85)。 */
78
+ | 'UNSUPPORTED'
79
+ /** 看板没有托管朗读的 bridge(旧 CLI 启动),或 cloud 的其他意外。 */
80
+ | 'CLOUD_UNAVAILABLE' | 'TTS_QUOTA_EXCEEDED' | 'AUTH_REQUIRED' | 'AUTH_EXPIRED' | 'EMAIL_UNVERIFIED' | 'FORBIDDEN' | 'RATE_LIMITED' | 'TTS_UNAVAILABLE' | 'BAD_REQUEST';
54
81
  export declare class VoiceError extends Error {
55
- readonly code: 'NO_KEY' | 'HTTP' | 'NOT_AUDIO' | 'BAD_RESPONSE' | 'NETWORK' | 'TOO_LARGE' | 'INVALID' | 'NOT_FOUND' | 'BUSY';
82
+ readonly code: VoiceErrorCode;
56
83
  readonly hint?: {
57
84
  response: ResponseMode;
58
85
  path: string;
59
86
  } | undefined;
60
- constructor(code: 'NO_KEY' | 'HTTP' | 'NOT_AUDIO' | 'BAD_RESPONSE' | 'NETWORK' | 'TOO_LARGE' | 'INVALID' | 'NOT_FOUND' | 'BUSY', message: string, hint?: {
87
+ /** cloud 错误的附加数据(例如 402 的 neededChars / remainingChars / usageUrl)。 */
88
+ readonly data?: Record<string, unknown> | undefined;
89
+ constructor(code: VoiceErrorCode, message: string, hint?: {
61
90
  response: ResponseMode;
62
91
  path: string;
63
- } | undefined);
92
+ } | undefined,
93
+ /** cloud 错误的附加数据(例如 402 的 neededChars / remainingChars / usageUrl)。 */
94
+ data?: Record<string, unknown> | undefined);
64
95
  }
65
- /** 校验看板提交的 profile(不含 id / key)。返回规整后的字段,或抛 VoiceError('INVALID')。 */
66
- export declare function normalizeProfile(input: unknown, base?: VoiceProfile): Omit<VoiceProfile, 'id' | 'key' | 'preset'>;
67
- /** `<JOPLO_HOME>/voice/profiles.json`:自建的 profile 与改过的预设(含 Key),权限 0600。 */
96
+ /** 换用提示(D85):旧 profile 不能再生成时告诉作者换成哪一个。 */
97
+ export declare const UNSUPPORTED_MESSAGE: (name: string) => string;
98
+ /**
99
+ * 校验看板提交的改动(只有预设能改):openai / elevenlabs 可以改默认音色、模型(openai 还有说话风格);cloud 只能改默认音色。
100
+ * 接口地址、返回格式、请求头与请求体都不能改(D85)。返回合并后的字段。
101
+ */
102
+ export declare function normalizeProfile(input: unknown, base: VoiceProfile): Omit<VoiceProfile, 'id' | 'key' | 'preset'>;
103
+ /**
104
+ * `<JOPLO_HOME>/voice/profiles.json`:改过的预设(Key、默认音色)与本机旧的 profile,权限 0600。
105
+ * `<JOPLO_HOME>/voice/cloud-voices.json`:最近一次从云端拿到的 Joplo 音色表(不含额度、没有秘密)。
106
+ */
68
107
  export declare class ProfileStore {
69
108
  private readonly env;
109
+ private readonly opts;
70
110
  readonly file: string;
71
- constructor(home: string, env?: Record<string, string | undefined>);
111
+ readonly catalogFile: string;
112
+ constructor(home: string, env?: Record<string, string | undefined>, opts?: {
113
+ catalog?: () => CloudCatalog | null;
114
+ });
72
115
  private read;
73
116
  private write;
74
- /** 预设(合并本机覆盖)在前,自建的在后。 */
117
+ /**
118
+ * 预设(合并本机改过的默认音色、模型、风格与 Key;地址固定)在前;本机旧的 profile(不再支持)在后。
119
+ * 旧版把 OpenAI / ElevenLabs 预设改成别的地址(代理)、请求头或返回格式的,不再当作官方预设:作为不再支持的旧 profile
120
+ * 按原来的字段算指纹(旧音频照常播放与打包),Key 不给出去(原本是给代理的,绝不能发到官方地址);删掉它才恢复官方预设。
121
+ */
75
122
  list(): VoiceProfile[];
123
+ /** 按 id 找;项目选着的 aihubmix 即使从没存过也找得到(不再支持)。 */
76
124
  get(id: string): VoiceProfile | null;
77
125
  /** 按 id 或名字(不区分大小写)找,config({ voice: { profile } }) 用。 */
78
126
  find(ref: string): VoiceProfile | null;
79
- /** Key:保存的优先,其次是预设对应的环境变量。 */
127
+ /** 项目升级前保存的 cloud 引用继续指向旧来源;官方名称始终可显式选用。 */
128
+ projectProfile(ref: string, officialCloud?: boolean): VoiceProfile | null;
129
+ /** Key:保存的优先,其次是预设对应的环境变量。cloud 不用 Key(用 CLI 的登录);旧 profile 不再生成,也不给 Key。 */
80
130
  keyOf(p: VoiceProfile): string | null;
81
131
  /**
82
- * 新建或修改。id 为 null 时新建(id 由名字生成)。key:undefined = 不改;null 或 '' = 删掉保存的 Key;字符串 = 保存。
132
+ * 改预设:默认音色、模型、风格(见 normalizeProfile)与 Key。key:undefined = 不改;null 或 '' = 删掉保存的 Key;字符串 = 保存。
133
+ * 不能新建(D85:不再提供 OpenAI 兼容与自定义 HTTP),也不能改旧的 profile。
83
134
  */
84
135
  upsert(id: string | null, input: unknown, key: string | null | undefined): VoiceProfile;
85
- /** 自建的删除;预设恢复默认(去掉本机覆盖,包括保存的 Key)。 */
136
+ /** 预设恢复默认(去掉本机覆盖,包括保存的 Key);本机旧的 profile 删除。 */
86
137
  remove(id: string): void;
138
+ /** Joplo 音色表:云端给的(内存)> 本机记下的上一次 > 内置的 6 个(英文标签,没有推荐与样音)。 */
139
+ cloudCatalog(): CloudCatalog;
140
+ /** 记下云端给的音色表(内容变了才写),build 与离线时按它选音色,与看板一致。 */
141
+ rememberCloudCatalog(c: CloudCatalog): void;
142
+ /** cloud 的音色候选(看板列表与试听)。 */
143
+ cloudVoices(): VoiceChoice[];
87
144
  publicOf(p: VoiceProfile): PublicProfile;
88
145
  }
89
- /** JSON 字符串转义后替换 {{text}} {{voice}} {{model}}(模板本身是 JSON,值放在引号里)。 */
90
- export declare function fillTemplate(tpl: string, v: {
91
- text: string;
92
- voice: string;
93
- model: string;
94
- key?: string;
95
- }): string;
96
- /** 发给模型的说话风格:只有 OpenAI 兼容接口、且不是 tts-1 系列(不支持 instructions)时才发。 */
146
+ /** 发给模型的说话风格:只有 OpenAI、且不是 tts-1 系列(不支持 instructions)时才发。 */
97
147
  export declare const styleOf: (p: VoiceProfile) => string | null;
98
- /** 这次合成的 HTTP 请求(不发出)。 */
148
+ /** 这次合成的 HTTP 请求(不发出):只有官方的 OpenAI 与 ElevenLabs(地址固定)。 */
99
149
  export declare function buildRequest(p: VoiceProfile, key: string | null, text: string, voice: string): {
100
150
  url: string;
101
151
  init: RequestInit;
@@ -107,27 +157,33 @@ export type AudioType = {
107
157
  export declare const AUDIO_TYPES: Record<AudioType['ext'], string>;
108
158
  /** 按文件头识别音频格式;不是音频返回 null。 */
109
159
  export declare function sniffAudio(b: Uint8Array): AudioType | null;
110
- /** 按 a.b.0.c 取值。 */
111
- export declare function getPath(v: unknown, p: string): unknown;
112
- /** 返回的是 JSON 时,找出像音频的字段,给出“返回内容 + 字段路径”的建议。 */
113
- export declare function suggestFromJson(v: unknown): {
114
- response: ResponseMode;
115
- path: string;
116
- } | null;
117
160
  export type FetchLike = (url: string, init?: RequestInit) => Promise<Response>;
118
- /** 合成一段:返回音频字节与格式。失败抛 VoiceError(信息里不含 Key)。 */
161
+ /** 用自带 Key 的官方接口合成一段:返回音频字节与格式。失败抛 VoiceError(信息里不含 Key)。 */
119
162
  export declare function synthesize(p: VoiceProfile, key: string | null, text: string, voice: string, opts?: {
120
163
  fetch?: FetchLike;
121
164
  signal?: AbortSignal;
122
165
  }): Promise<{
123
166
  bytes: Buffer;
124
167
  } & AudioType>;
125
- /** 声音指纹:接口、地址、模型、音色、返回格式、请求体模板、说话风格(不含 Key 与请求头)。 */
168
+ /** 托管朗读合成一段(D85):经 CLI 注入的 bridge,用 CLI 的登录,不要 Key。bridge 抛出的 { code, message, data } 转成 VoiceError。 */
169
+ export declare function synthesizeCloud(bridge: CloudVoiceBridge | undefined, req: {
170
+ text: string;
171
+ voice: string;
172
+ locale?: string | null;
173
+ project?: string | null;
174
+ }): Promise<{
175
+ bytes: Buffer;
176
+ result: CloudSpeechResult;
177
+ } & AudioType>;
178
+ /**
179
+ * 声音指纹:cloud 只看音色(换上游模型不让旧音频失效,D85);其他是接口、地址、模型、音色、返回格式、请求体模板、说话风格(不含 Key 与请求头)。
180
+ * 旧 profile 的算法与以前完全一样,已生成的音频的键不变。
181
+ */
126
182
  export declare function fingerprint(p: VoiceProfile, voice: string): string;
127
183
  export type ResolvedVoices = {
128
184
  profile: VoiceProfile | null;
129
- /** 选用来源:config = joplo.config.ts 的 voice.profile;board = 看板浮层里选的;null = 只用浏览器朗读。 */
130
- source: 'config' | 'board' | null;
185
+ /** 选用来源:config = joplo.config.ts 的 voice.profile;board = 看板浮层里选的;default = 没选过时的默认(已登录为 cloud);null = 只用浏览器朗读。 */
186
+ source: 'config' | 'board' | 'default' | null;
131
187
  /** config 里写了、但本机没有的 profile 名。 */
132
188
  missing: string | null;
133
189
  narrator: string | null;
@@ -137,16 +193,32 @@ export type ResolvedVoices = {
137
193
  narrator: string | null;
138
194
  roles: Record<string, string>;
139
195
  };
196
+ /**
197
+ * cloud 在非默认语言下自动选的音色(D84 / D85):基础音色 → 选中的音色。第一次在这种语言下生成成功时记进项目 index.json 的 pins
198
+ * (VoiceCache.pin),之后推荐列表变了、换了电脑也按记下的选,指纹不变。
199
+ */
200
+ autoPicks?: {
201
+ locale: string;
202
+ map: Record<string, string>;
203
+ };
140
204
  };
205
+ /** 项目里记下的 cloud 自动音色:内容语言 → (基础音色 → 选中的音色)。 */
206
+ export type VoicePins = Record<string, Record<string, string>>;
141
207
  /**
142
- * 某种内容语言用哪个音色(D84):音色有口音(ElevenLabs 预设)且口音不是这种语言、而预设里有这种语言的音色时,
143
- * 换成同语言的(优先同性别、推荐的);多语言音色(OpenAI 预设没有口音)原样用,由说话风格要求母语口音。
208
+ * 某种内容语言用哪个音色(D84):
209
+ * - ElevenLabs 预设:音色有口音且口音不是这种语言、而预设里有这种语言的音色时,换成同语言的(优先同性别、推荐的);
210
+ * - Joplo Cloud:云端给了这种语言的推荐音色(recommended[语言])时,音色在推荐里就不换,否则换成推荐里同性别的第一个,没有同性别的用第一个;
211
+ * - 多语言音色(OpenAI 预设没有口音)原样用,由说话风格要求母语口音。
144
212
  */
145
- export declare function autoVoiceFor(profile: Pick<VoiceProfile, 'preset'>, voice: string, locale: string | null | undefined): string;
213
+ export declare function autoVoiceFor(profile: Pick<VoiceProfile, 'preset'>, voice: string, locale: string | null | undefined, catalog?: CloudCatalog): string;
146
214
  /** 传给 resolveVoices 的语言:默认语言(源文件的语言)不自动换音色,保留作者原来的选择和已生成的音频。 */
147
215
  export declare const voiceLocaleOf: (project: Pick<Project, "i18n"> | null | undefined, locale: string | null | undefined) => string | null;
148
- /** locale:内容语言(D84,默认语言传 null,见 voiceLocaleOf)。config.voice.locales[locale] 优先,其次按 autoVoiceFor 自动选;不传时与之前一样。 */
149
- export declare function resolveVoices(config: VoiceConfig | undefined, selected: string | null, store: ProfileStore, locale?: string | null): ResolvedVoices;
216
+ /**
217
+ * locale:内容语言(D84,默认语言传 null,见 voiceLocaleOf)。config.voice.locales[locale] 优先,其次按 autoVoiceFor 自动选;不传时与之前一样。
218
+ * selected:看板里选的(VoiceCache.selection()):字符串 = 某个来源;null = 选了浏览器朗读;undefined = 没选过,这时用 fallback
219
+ * (调用方给:已登录为 'cloud',否则 null)。
220
+ */
221
+ export declare function resolveVoices(config: VoiceConfig | undefined, selected: string | null | undefined, store: ProfileStore, locale?: string | null, fallback?: string | null, pins?: VoicePins, officialCloud?: boolean): ResolvedVoices;
150
222
  export type ClipRecord = {
151
223
  file: string;
152
224
  stepId: string;
@@ -155,6 +227,7 @@ export type ClipRecord = {
155
227
  locale: string;
156
228
  bytes: number;
157
229
  at: string;
230
+ origin?: 'shared';
158
231
  };
159
232
  export type GeneratedClip = {
160
233
  key: string;
@@ -163,9 +236,16 @@ export type GeneratedClip = {
163
236
  };
164
237
  /** 正在生成的片段:片段键 → 结果(每个项目一张,见 VoiceCache.generateOne)。 */
165
238
  export type Inflight = Map<string, Promise<GeneratedClip>>;
239
+ /**
240
+ * profileId:看板里选的来源(null = 浏览器朗读);chosen:作者在看板里选过(D85:没选过时用默认来源,已登录为 cloud)。
241
+ * 旧版写下的文件没有 chosen:profileId 是字符串时算选过,null 时算没选过(旧版没选过时也写 null)。
242
+ */
166
243
  type IndexFile = {
167
244
  version: 1;
168
245
  profileId: string | null;
246
+ chosen?: boolean;
247
+ cloudSource?: 'official';
248
+ pins?: VoicePins;
169
249
  clips: Record<string, ClipRecord>;
170
250
  failures: Record<string, {
171
251
  stepId: string;
@@ -187,6 +267,47 @@ export type GenerateSummary = {
187
267
  message: string;
188
268
  }[];
189
269
  noProfile?: boolean;
270
+ /** 选用的来源不再支持(D85):没有生成,已有的音频照常用。 */
271
+ unsupported?: boolean;
272
+ /** cloud 额度不够(402):需要多少 / 还剩多少(云端给的)。生成在这里停下。 */
273
+ quota?: {
274
+ neededChars: number | null;
275
+ remainingChars: number | null;
276
+ };
277
+ /** 因为账号层面的错误(额度、登录、邮箱未验证…)停下时,没有尝试的段数。 */
278
+ stopped?: number;
279
+ /** 停下的原因(额度不够之外的账号错误,例如 AUTH_REQUIRED)。 */
280
+ error?: {
281
+ code: string;
282
+ message: string;
283
+ };
284
+ };
285
+ /** cloud 合成的回执(每段一次):扣了几个字、还剩多少(响应头)、是否命中云端缓存。 */
286
+ export type CloudReceipt = {
287
+ charged: number | null;
288
+ remaining: number | null;
289
+ cache: 'hit' | 'miss' | null;
290
+ };
291
+ export type GenerateOptions = {
292
+ fetch?: FetchLike;
293
+ signal?: AbortSignal;
294
+ inflight?: Inflight;
295
+ /** 托管朗读(D85)的 bridge;没有时 cloud 报 CLOUD_UNAVAILABLE。 */
296
+ cloud?: CloudVoiceBridge;
297
+ /** 项目名(cloud 请求的 project,控制台明细用)。 */
298
+ project?: string | null;
299
+ /** 内容语言(cloud 请求的 locale,D84);不知道时不带。 */
300
+ speechLocale?: string | null;
301
+ /** 每段 cloud 合成成功后(剩余字数来自响应头)。 */
302
+ onCloud?: (r: CloudReceipt) => void;
303
+ };
304
+ /**
305
+ * 这次要生成的段数与字数(D85):只算缺音频的段,同一段(同一个片段键)只算一次,字数按 spokenChars(Array.from)。
306
+ * 看板按钮“约 X 字”与 `joplo voice --dry-run` 用它;没有选用来源时都是 0。
307
+ */
308
+ export declare function estimateVoice(segments: Segment[], resolved: ResolvedVoices, cache: VoiceCache): {
309
+ steps: number;
310
+ chars: number;
190
311
  };
191
312
  /** `<项目>/.joplo/voice/`:index.json(选用的 profile、片段、失败)与 clips/。 */
192
313
  export declare class VoiceCache {
@@ -195,8 +316,16 @@ export declare class VoiceCache {
195
316
  constructor(projectDir: string);
196
317
  get clipsDir(): string;
197
318
  read(): IndexFile;
319
+ /** 看板里选的来源:字符串 = 某个来源;null = 选了浏览器朗读;undefined = 没选过(用默认来源,见 resolveVoices 的 fallback)。 */
320
+ selection(): string | null | undefined;
198
321
  write(idx: IndexFile): void;
199
322
  select(profileId: string | null): void;
323
+ /** 新版看板明确选过官方 cloud;旧选择没有此标记。 */
324
+ officialCloud(): boolean;
325
+ /** 记下的 cloud 自动音色(见 ResolvedVoices.autoPicks);build、share、播放、joplo voice 都传给 resolveVoices。 */
326
+ pins(): VoicePins;
327
+ /** 记下这种语言自动选的音色:已经记过的不改(只有从没生成过的组合才按推荐挑)。 */
328
+ pin(locale: string, map: Record<string, string>): void;
200
329
  /** 片段文件的绝对路径(文件名不合法或不存在时为 null)。 */
201
330
  fileOf(name: string): string | null;
202
331
  /** 当前声音下已有的片段:键 → 文件名;以及失败的键 → 原因。 */
@@ -223,25 +352,20 @@ export declare class VoiceCache {
223
352
  } | null;
224
353
  /** 已有的片段文件名(文件还在时)。 */
225
354
  clipOf(key: string): string | null;
355
+ /** 分享下载的片段不能被误认成本机新生成,进而覆盖另一语言的旧声音。旧缓存缺省为本机生成。 */
356
+ localClipOf(key: string): string | null;
226
357
  /** 收下一段别处来的音频(D84:从已发布的分享沿用):文件名必须是内容的 sha256,否则不收。 */
227
358
  adopt(key: string, file: string, bytes: Uint8Array, rec: Omit<ClipRecord, 'file' | 'bytes' | 'at'>): boolean;
228
359
  /**
229
360
  * 生成一段(已有就直接返回):返回文件名;失败记进 failures 并抛 VoiceError。
230
361
  * inflight:同一个项目共用的“正在生成”表(片段键 → 结果)。批量生成与边放边生成传同一张表,同一段同时只请求一次,后来的等先来的结果(generated 为 false)。
231
362
  */
232
- generateOne(seg: Segment, locale: string, resolved: ResolvedVoices, store: ProfileStore, opts?: {
233
- fetch?: FetchLike;
234
- signal?: AbortSignal;
235
- inflight?: Inflight;
236
- }): Promise<GeneratedClip>;
363
+ generateOne(seg: Segment, locale: string, resolved: ResolvedVoices, store: ProfileStore, opts?: GenerateOptions): Promise<GeneratedClip>;
237
364
  private synthesizeOne;
238
365
  /**
239
366
  * 生成缺的片段(已有的跳过),并发 2。每段完成后调 onProgress。失败记进 failures,成功时清掉这个键的失败。
240
367
  */
241
- generate(segments: Segment[], locale: string, resolved: ResolvedVoices, store: ProfileStore, opts?: {
242
- fetch?: FetchLike;
243
- signal?: AbortSignal;
244
- inflight?: Inflight;
368
+ generate(segments: Segment[], locale: string, resolved: ResolvedVoices, store: ProfileStore, opts?: GenerateOptions & {
245
369
  onProgress?: (done: number, total: number, failed: number) => void;
246
370
  }): Promise<GenerateSummary>;
247
371
  }
@@ -267,15 +391,17 @@ export type SharedVoice = {
267
391
  * 本机没有、分享里有的就下载到本机缓存(文件名必须是内容的 sha256),之后照常打包;上传时 Cloud 已有这些内容,不会重传。
268
392
  * 本机没有供应商时按分享里的声音指纹算键。自动字幕的步骤(文字由网页按语言生成)不在这里沿用。
269
393
  */
270
- export declare function reuseSharedVoice(projectDir: string, project: Project, shared: SharedVoice, store: ProfileStore, devConfig?: VoiceConfig): Promise<number>;
394
+ export declare function reuseSharedVoice(projectDir: string, project: Project, shared: SharedVoice, store: ProfileStore, devConfig?: VoiceConfig, defaultProfile?: string | null): Promise<number>;
271
395
  /**
272
396
  * 发布(joplo build / share):把发布 IR 里步骤用到的、当前声音的音频拷进 `<outDir>/voice/`,返回 IR 的 voiceIndex。
273
397
  * 同一步同一声音同一语言只留最新的一段(改过字之后旧的不再带上)。
274
398
  * 内容多语言(D84):每种内容语言按 resolveVoices(…, 语言) 选声音,voiceIndex.locales 记各语言的指纹;missing 按语言分别统计。
275
- * missing:还没有音频的步骤数(自动字幕的步骤只要有这种语言的任意音频就算有)。
399
+ * missing:还没有有效音频的步骤数(自动字幕必须匹配当前参数在片段语言下生成的文字)。
276
400
  * 没有选用 profile 时:给了 fallback(已发布分享的 voiceIndex)就按它的指纹带上本机已有的音频,否则不带(观众端用浏览器朗读)。
401
+ * defaultProfile:项目没选过来源时的默认(D85:已登录为 'cloud',与看板同一规则,见 resolveVoices)。
402
+ * 不再支持的旧 profile 照常按它的指纹打包(D85:已生成的音频照常随分享上传)。
277
403
  */
278
- export declare function bundleVoice(projectDir: string, project: Project, outDir: string, store: ProfileStore, devConfig?: VoiceConfig, fallback?: VoiceIndex): {
404
+ export declare function bundleVoice(projectDir: string, project: Project, outDir: string, store: ProfileStore, devConfig?: VoiceConfig, fallback?: VoiceIndex, defaultProfile?: string | null): {
279
405
  index: VoiceIndex | null;
280
406
  report: BundleReport;
281
407
  };