Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[project-s] 歌ボ形式で歌声合成する機能を追加 #1255

Merged
merged 8 commits into from
Apr 11, 2023
12 changes: 10 additions & 2 deletions src/infrastructures/AudioRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -674,7 +674,14 @@ export class AudioRenderer {
this.onlineContext = { audioContext, transport };
}

renderToBuffer(
async createAudioBuffer(blob: Blob) {
const audioContext = this.onlineContext.audioContext;
const arrayBuffer = await blob.arrayBuffer();
const audioBuffer = await audioContext.decodeAudioData(arrayBuffer);
return audioBuffer;
}

async renderToBuffer(
sampleRate: number,
startTime: number,
duration: number,
Expand All @@ -690,7 +697,8 @@ export class AudioRenderer {

callback({ audioContext, transport });
transport.scheduleEvents(startTime, duration);
return audioContext.startRendering();
const audioBuffer = await audioContext.startRendering();
return audioBuffer;
}

dispose() {
Expand Down
Loading