w-okada / voice-changer

リアルタイムボイスチェンジャー Realtime Voice Changer
Other
15.92k stars 1.72k forks source link

[REQUEST]: Output to File #975

Closed spooknik closed 9 months ago

spooknik commented 10 months ago

In a few words, describe your idea

Output recording to file instead of audio device

More information

Thank you for the nice software, It works very well for me.

I would like to request an output to file feature. My usage is to take a prerecorded MP3 and re-record it into a difference voice. (For example, I have an audiobook with bad narrator, I want to change the voice).

gvmii commented 10 months ago

You could do this by using a virtual audio cable and just playing the sound from it. Time consuming but it'd work.

w-okada commented 10 months ago

you can record output to file.

image

w-okada commented 9 months ago

close

Venryx commented 8 months ago

Just wanted to mention a tip: If you want a "one click" way to:

Then you can use a JS script like the below: [EDIT: Apparently this approach was not reliable; see comments at bottom.]

function PlayInputAndRecordToFile() {
  const chunkSelectEl = [...document.querySelectorAll(".config-sub-area-control-title")].find(a=>a.innerText == "CHUNK:").nextSibling.childNodes[0];
  const chunkSelectInfo = chunkSelectEl.childNodes[chunkSelectEl.selectedIndex].innerText;
  const chunkDelay = Number(chunkSelectInfo.match(/([0-9.]+) ms/)[1]);
  console.log("ChunkDelay:", chunkDelay);

  const audioInputFileEl = document.querySelector("#audio-test-converted");
  const buttons = [...document.querySelectorAll(".config-sub-area-button, .config-sub-area-button-active")];
  const startRecordButton = buttons[1];
  const stopRecordButton = buttons[2];

  audioInputFileEl.currentTime = 0;
  audioInputFileEl.play();
  setTimeout(()=>startRecordButton.click(), chunkDelay);
  audioInputFileEl.onended = ()=>{
    audioInputFileEl.onended = null;
    setTimeout(()=>stopRecordButton.click(), chunkDelay);
  };
}
PlayInputAndRecordToFile();

EDIT: It turns out that the approach above is not reliable, because apparently the chunk size does not always end up being equal to the playback delay. (I was just lucky for the settings I initially tried)

EDIT: After several hours of tinkering, I found a way to reliably get crisp conversion of pre-recorded audio files, by "flushing" the conversion pipeline, and manually sending to the voice-converter backend just the data from the file.

I've put this together as a script that you can run, by copy-pasting it into the voice-changer app's dev-tools console. It then adds two new buttons to the UI, that let you convert pre-recorded audio files directly, without messing with starting/stopping recording manually, or worrying about the conversion delay causing lost audio or additional silence.

The repo for these scripts can be found here: https://github.com/Venryx/w-okada-voice-changer-scripts

If the project owners think this feature could be useful, I might be able to turn it into a proper pull request at some point. (although it would need significant cleanup, since a lot of hacks were needed to get it working entirely from the dev-tools console)