Quick Start with the GUI
mainThe recommended way to use KVoiceWalk is via the built-in GUI. This allows you to queue multiple tasks and run them sequentially with live logs.
Launch the GUI using:
uv run gui.pyrepository·main·Indexed 42 days ago
https://github.com/robviren/kvoicewalkA tool that uses a random walk algorithm and a hybrid scoring method—including Resemblyzer similarity, feature extraction, and self-similarity—to evolve Kokoro voice style tensors for audio cloning. It features a CLI and GUI for performing random walks, testing voice tensors, batch transcribing audio via Faster-Whisper, and exporting voice binaries.
The recommended way to use KVoiceWalk is via the built-in GUI. This allows you to queue multiple tasks and run them sequentially with live logs.
Launch the GUI using:
uv run gui.pyKVoiceWalk can use Faster-Whisper to transcribe your target audio, which automatically updates the --target_text argument.
Transcribe a single file:
Use --transcribe_start. This saves the transcription as a .txt file in the ./texts folder.
uv run main.py --target_text "This text will be replaced!" --target_audio /path/to/target.wav --transcribe_startTranscribe many files:
Use --transcribe_many to process a single WAV file or an entire folder of WAV files. Transcriptions are saved as individual files in ./texts.
uv run main.py --target_audio /path/to/audio/Folder/ --transcribe_manyUsing transcriptions as input:
You can pass the path to a generated .txt file directly to --target_text:
uv run main.py --target_text /path/to/your/transcribed.txt --target_audio /path/to/target.wavThe --interpolate_start flag performs an interpolation search across existing trained voices to find the best possible starting population of tensors. This acts as a guide for the random walk, often leading to significantly higher similarity scores.
Running this will:
interpolated.Example:
uv run main.py --target_text "The words the speaker says in the audio clip" --target_audio /path/to/target.wav --interpolate_startTo install KVoiceWalk, clone the repository, set up a Python 3.10-3.12 environment using uv, and sync the dependencies.
Prerequisites:
3.10 to 3.12uv installed (pip install uv)tkinter)ffmpeg for audio preprocessingVerification:
After running uv sync, verify CUDA availability with:
uv run python -c "import torch; print(torch.__version__, torch.cuda.is_available(), torch.version.cuda)"git clone https://github.com/RobViren/kvoicewalk.git
cd kvoicewalk
uv venv --python 3.10
source .venv/bin/activate # '.venv\Scripts\activate' if Windows
uv syncTo evolve a new voice tensor to match a target audio file using the random walk algorithm, use main.py with the --target_audio and --target_text arguments.
Important Audio Requirement:
Target audio files must be Mono 24000 Hz WAV (approximately 20-30 seconds of a single speaker). If your file is not in this format, convert it using ffmpeg:
ffmpeg -i input_file.wav -ar 24000 target.wavExample Command:
uv run main.py --target_text "Your target text here" --target_audio ./example/target.wav --device cuda --log_interval 100uv run main.py --target_text "The old lighthouse keeper never imagined that one day he'd be guiding ships from the comfort of his living room, but with modern technology and an array of cameras, he did just that, sipping tea while the storm raged outside and gulls shrieked overhead." --target_audio ./example/target.wav --device cuda --log_interval 100To package all .pt voices in a specific directory into a single voices.bin file, use the --voices_folder and --export_bin arguments.
uv run main.py --voices_folder ./voices --export_binTo verify how a specific .pt voice tensor sounds, use the --test_voice argument. This will generate an audio file named out.wav using the provided tensor and the text specified in --target_text.
uv run main.py --test_voice /path/to/voice.pt --target_text "Your really awesome text you want spoken"--target_text (str): The words in the target audio (100-200 tokens). Can be a path to a .txt file.--other_text (str): Text used to compare self-similarity. Default: "If you mix vinegar, baking soda, and a bit of dish soap..."--voice_folder (str): Path to voices used in the random walk. Default: ./voices--transcribe_start: Transcribes target WAV and replaces --target_text.--interpolate_start: Performs interpolation search before random walking.--population_limit (int): Limits voices used in random walk. Default: 10--step_limit (int): Limits random walk steps. Default: 10000--output_name (str): Filename for generated audio. Default: out.wav--target_audio (str): Path to target 24000 Hz mono WAV file.--starting_voice (str): Path to the starting voice tensor.--test_voice (str): Path to the voice tensor to test.--export_bin: Exports voices in --voices_folder to voices.bin.--transcribe_many: Transcribes a WAV file or folder to ./texts.--device (str): Selection for Kokoro, Resemblyzer, and Faster-Whisper. Options: auto (default), cpu, cuda. Falls back to CPU if CUDA is requested but unavailable.The core functionality of the project is the KVoiceWalk class, which implements the random walk algorithm to find a voice tensor that matches a target audio's characteristics.
KVoiceWalk:target_audio: Path to the target audio file.target_text: The transcription of the target audio.other_text: Text used for similarity comparison.voice_folder: Directory containing available voice tensors.interpolate_start: Boolean; if true, performs interpolation before walking.population_limit: Integer; limits the number of voices used.starting_voice: Path to an initial voice tensor.output_name: Filename for the resulting audio.device: Execution device (auto, cpu, or cuda).To execute the walk, call the .random_walk(step_limit, log_interval) method.
from utilities.kvoicewalk import KVoiceWalk
ktb = KVoiceWalk(
target_audio="path/to/audio.wav",
target_text="The transcription text",
other_text="Similarity comparison text",
voice_folder="./voices",
interpolate_start=True,
population_limit=10,
starting_voice="path/to/start.pt",
output_name="output.wav",
device="cuda"
)
ktb.random_walk(step_limit=1000, log_interval=100)The following arguments are available for the KVoiceWalk CLI. Note that some arguments are grouped by mode.
### Common required arguments
--target_text [str]: The words contained in the target audio file (100-200 tokens). Can be a path to a .txt file.
### Optional arguments
--other_text [str]: Text used to compare self-similarity (default: provided volcanic activity text).
--voice_folder [str]: Path to the voices used in the random walk (default: ./voices).
--transcribe_start: Transcribes a target wav/folder and replaces --target_text.
--interpolate_start: Performs an interpolation search step before random walking.
--population_limit [int]: Limits voices used in the walk (default: 10).
--step_limit [int]: Limits steps in the walk (default: 10000).
--log_interval [int]: Frequency of progress logs (default: 100).
--output_name [str]: Filename for generated audio (default: my_new_voice).
--device [auto|cpu|cuda]: Execution device (default: auto).
### Random Walk Mode
--target_audio [str]: Path to target 24000 Hz mono wav file.
--starting_voice [str]: Path to the starting voice tensor.
### Test Mode
--test_voice [str]: Path to the voice tensor to test.
### Utility Mode
--export_bin: Exports target voices in --voice_folder to voices.bin.
--transcribe_many: Transcribes a wav file or folder to the ./texts folder.KVoiceWalk can be executed from the command line to perform voice cloning using a random walk algorithm. The CLI supports several modes: Random Walk Mode (the primary use case), Test Mode (to test a specific voice tensor), and Utility Mode (for exporting voice binaries or batch transcribing audio).
To perform a random walk to clone a voice, you must provide a target audio file and the corresponding transcription text.
python main.py --target_audio path/to/target.wav --target_text "The transcription of the audio" --voice_folder ./my_voicesUse this mode to verify a specific voice tensor by generating speech from a text string.
python main.py --test_voice path/to/voice.pt --target_text "Text to speak" --output_name result.wav.pt files in a folder into a single voices.bin file..wav file or an entire directory of .wav files into text files in the ./texts folder.python main.py --target_audio path/to/target.wav --target_text "The transcription of the audio" --voice_folder ./my_voices