Skip to main content

Use OpenVoice 2 stage via console or python scripts

Project description

OpenVoice-cli

This fork, does not generate voice from text, it only uses the 2nd stage of voice2voice. Therefore, you need to have a sample and a voice already prepared

Paper | Website

About

The second stage of OpenVoice "Tone color extractor" is used, via console or python scripts.

Feel free to make PRs or use the code for your own needs

Demo

https://github.com/daswer123/OpenVoice-cli/assets/22278673/7b4255eb-7797-4370-825a-81f2c67c8f90

Changelog

You can keep track of all changes on the release page

TODO

  • Batch generation via console
  • Possibility to use inference import through code

Installation

Simple installation :

pip install openvoice-cli

This will install all the necessary dependencies, including a CPU support only version of PyTorch

I recommend that you install the GPU version to improve processing speed ( up to 3 times faster )

Read the end of the README to learn how to install.

Windows

python -m venv venv
venv\Scripts\activate
pip install openvoice-cli
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118

Linux

python -m venv venv
source venv\bin\activate
pip install openvoice-cli
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118

Usage

This tool supports both single file and batch processing for audio tone color conversion using a reference audio file. Below are the commands for each mode of operation:

Single File Processing

python -m openvoice_cli single -i INPUT -r REF [-o OUTPUT] [-d DEVICE]

Batch Processing

python -m openvoice_cli batch -id INPUT_DIR -rf REF_FILE [-od OUTPUT_DIR] [-d DEVICE] [-of OUTPUT_FORMAT]

Options

Common Options

  • -h, --help:
    Show this help message and exit.

Single File Processing Options

  • -i INPUT, --input INPUT (mandatory):
    Path to the input audio file.

  • -r REF, --ref REF (mandatory):
    Path to the reference audio file for tone color extraction.

  • -o OUTPUT, --output OUTPUT:
    Designate the output path for the converted audio file. By default, the output will be saved as "out.wav" in the current directory.

  • -d DEVICE, --device DEVICE:
    Specify the device to use for processing; defaults to 'cpu'. Can be set to a CUDA device with 'cuda:0' if supported and desired.

Batch Processing Options

  • -id INPUT_DIR, --input_dir INPUT_DIR (mandatory):
    Input directory containing audio files to process.

  • -rf REF_FILE, --ref_file REF_FILE (mandatory):
    Reference audio file path.

  • -od OUTPUT_DIR, --output_dir OUTPUT_DIR:
    Output directory for converted audio files. Defaults to "outputs".

  • -d DEVICE, --device DEVICE:
    Specify the processing device. Defaults to 'cuda' if available.

  • -of OUTPUT_FORMAT, --output_format OUTPUT_FORMAT:
    Output file format (e.g., ".wav"). Defaults to ".wav".

Example Commands via console

Single file processing

python -m openvoice_cli single -i ./test/test.wav -r ./test/ref.wav -o ./test/ready.wav

Batch processing

python -m openvoice_cli batch -id ./test/input_folder -rf ./test/ref.wav -od ./test/output_folder -of .mp3

Example via Python Code

For integrating the audio tone color conversion capabilities into your Python code, you can import and use the tune_one and tune_batch functions provided by the openvoice_cli. Here are some examples on how to invoke these functions in a Python script:

Single File Conversion

from openvoice_cli import tune_one

# Set parameters for single file processing
input_file = 'path_to_input.wav'
ref_file = 'path_to_reference.wav'
output_file = 'path_to_output.wav'
device = 'cpu'  # or 'cuda:0' for GPU processing

# Convert the tone color of a single audio file
tune_one(input_file=input_file, ref_file=ref_file, output_file=output_file, device=device)

Batch Processing

from openvoice_cli import tune_batch

# Set parameters for batch processing
input_dir = 'path_to_input_directory'
ref_file = 'path_to_reference.wav'
output_dir = 'path_to_output_directory'
device = 'cuda'  # or 'cpu' for CPU processing
output_format = '.wav'  # could be .mp3 or other formats

# Convert the tone color of multiple audio files in a directory
output = tune_batch(input_dir=input_dir, ref_file=ref_file, output_dir=output_dir, device=device, output_format=output_format)

In these examples:

  • Replace 'path_to_input.wav', 'path_to_reference.wav', and 'path_to_output.wav' with the actual file paths for your input, reference, and output audio files respectively.
  • Replace 'path_to_input_directory' and 'path_to_output_directory' with the actual directories containing your input audio files and where you want the converted files to be saved.
  • The device parameter allows you to specify whether to perform processing using the CPU ('cpu') or GPU ('cuda:0'). Ensure that your environment supports CUDA before attempting to use GPU acceleration.

License

This repository is licensed under MIT License

Original repository is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License, which prohibits commercial usage. MyShell reserves the ability to detect whether an audio is generated by OpenVoice, no matter whether the watermark is added or not.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

openvoice_cli-0.0.5.tar.gz (1.8 MB view details)

Uploaded Source

Built Distribution

openvoice_cli-0.0.5-py3-none-any.whl (44.8 kB view details)

Uploaded Python 3

File details

Details for the file openvoice_cli-0.0.5.tar.gz.

File metadata

  • Download URL: openvoice_cli-0.0.5.tar.gz
  • Upload date:
  • Size: 1.8 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.23.0

File hashes

Hashes for openvoice_cli-0.0.5.tar.gz
Algorithm Hash digest
SHA256 3090c827267013e81476f06aabd162286d3ab90b59a32489cf00a6f907d38310
MD5 d8311fa3592d36cb32492db35aacc761
BLAKE2b-256 a3c12e3e8ebb1206b73d9b2eba99517792deed05cfc447e60338dfa1c5436f0c

See more details on using hashes here.

File details

Details for the file openvoice_cli-0.0.5-py3-none-any.whl.

File metadata

File hashes

Hashes for openvoice_cli-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 b04af2a8a944c44ba128375df3bca04a125057cb247617957607cec32828acb5
MD5 ff34866112105200d30dcaa0f8bbf673
BLAKE2b-256 42bfc74b9b8365c42ec8a55aef07c209259c1023c183fecdb97e2372ded6b41e

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page