Skip to content

文件变声

文件变声(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);

参数:

参数类型默认说明
authSdkAuthentication必填。SDK 鉴权配置,见鉴权
modelIdstring必填。加载的模型 ID。
fileBlob待转换的源音频。
preferencesFileInferencePreferences每任务转换参数。
onProgress(progress) => void进度回调,progress 取值 [0, 1]
timeoutMsnumber300000转换任务等待超时。
signalAbortSignal中止本地等待,并尝试停止转换任务。

成功 resolve 为 { url, key? };转换失败、超时或中止则 reject。

任务参数

FileInferencePreferences 比实时调音多暴露 f0_methoduse_pv 等:

pitchf0_method"rmvpe" | "fcpe")、f0_thresholdindex_rateprotectf0_autotunef0_autotune_strengthproposed_pitchproposed_pitch_thresholdsample_rateformantblock_timecrossfade_timeextra_timeuse_pvrms_mix_ratethresholdenable_limiterlimiter_thresholdenable_lookaheadlookahead_time

上传限制

源音频由服务端按文件名后缀校验,须为 mp3wavoggflacm4aaac 之一,单文件最大 100 MB。高层接口会把无文件名的 Blobaudio.wav 申请上传;需要保留实际后缀时应传入 File