主题
文件变声
文件变声(voice-to-voice)把整段音频走模型转换。Convbased.convertFile 内部开会话、跑转换、再拆会话,转换结果以预签名下载地址返回。
一步式调用
ts
import { Convbased } from "@convbased/sdk";
const { url } = await Convbased.convertFile({
auth,
modelId: "model_xxx",
file: fileInput.files[0], // File/Blob
preferences: { pitch: 2, f0_method: "rmvpe" },
onProgress: (progress) => console.log(`${(progress * 100).toFixed(0)}%`),
});
console.log("converted audio:", url);参数:
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
auth | SdkAuthentication | 必填。SDK 鉴权配置,见鉴权。 | |
modelId | string | 必填。加载的模型 ID。 | |
file | Blob | 待转换的源音频。 | |
preferences | FileInferencePreferences | 每任务转换参数。 | |
onProgress | (progress) => void | 进度回调,progress 取值 [0, 1]。 | |
timeoutMs | number | 300000 | 转换任务等待超时。 |
signal | AbortSignal | 中止本地等待,并尝试停止转换任务。 |
成功 resolve 为 { url, key? };转换失败、超时或中止则 reject。
任务参数
FileInferencePreferences 比实时调音多暴露 f0_method、use_pv 等:
pitch、f0_method("rmvpe" | "fcpe")、f0_threshold、index_rate、protect、f0_autotune、f0_autotune_strength、proposed_pitch、proposed_pitch_threshold、sample_rate、formant、block_time、crossfade_time、extra_time、use_pv、rms_mix_rate、threshold、enable_limiter、limiter_threshold、enable_lookahead、lookahead_time。
上传限制
源音频由服务端按文件名后缀校验,须为 mp3、wav、ogg、flac、m4a、aac 之一,单文件最大 100 MB。高层接口会把无文件名的 Blob 按 audio.wav 申请上传;需要保留实际后缀时应传入 File。