## 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](https://arxiv.org/abs/2312.01479) |
[Website](https://research.myshell.ai/open-voice)
## 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](https://github.com/daswer123/OpenVoice-cli/releases)
## TODO
- [x] Batch generation via console
- [x] Possibility to use inference import through code
## Installation
Simple installation :
```bash
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
```bash
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
```bash
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
```bash
python -m openvoice_cli single -i INPUT -r REF [-o OUTPUT] [-d DEVICE]
```
### Batch Processing
```bash
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**
```bash
python -m openvoice_cli single -i ./test/test.wav -r ./test/ref.wav -o ./test/ready.wav
```
**Batch processing**
```bash
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**
```python
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**
```python
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.
Raw data
{
"_id": null,
"home_page": null,
"name": "openvoice-cli",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": null,
"keywords": null,
"author": null,
"author_email": "daswer123 <daswerq123@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/a3/c1/2e3e8ebb1206b73d9b2eba99517792deed05cfc447e60338dfa1c5436f0c/openvoice_cli-0.0.5.tar.gz",
"platform": null,
"description": "## OpenVoice-cli\n\n**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**\n\n[Paper](https://arxiv.org/abs/2312.01479) |\n[Website](https://research.myshell.ai/open-voice) \n\n## About\n\nThe second stage of OpenVoice \"Tone color extractor\" is used, via console or python scripts.\n\nFeel free to make PRs or use the code for your own needs\n\n## Demo\n\nhttps://github.com/daswer123/OpenVoice-cli/assets/22278673/7b4255eb-7797-4370-825a-81f2c67c8f90\n\n## Changelog\n\nYou can keep track of all changes on the [release page](https://github.com/daswer123/OpenVoice-cli/releases)\n\n## TODO\n- [x] Batch generation via console\n- [x] Possibility to use inference import through code\n\n## Installation\n\nSimple installation :\n\n```bash\npip install openvoice-cli\n```\n\nThis will install all the necessary dependencies, including a **CPU support only** version of PyTorch\n\nI recommend that you install the **GPU version** to improve processing speed ( up to 3 times faster )\n\nRead the end of the README to learn how to install.\n\n### Windows\n```bash\npython -m venv venv\nvenv\\Scripts\\activate\npip install openvoice-cli\npip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118\n```\n\n### Linux\n```bash\npython -m venv venv\nsource venv\\bin\\activate\npip install openvoice-cli\npip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118\n```\n\n## Usage\n\nThis 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:\n\n### Single File Processing\n\n```bash\npython -m openvoice_cli single -i INPUT -r REF [-o OUTPUT] [-d DEVICE]\n```\n\n### Batch Processing\n\n```bash\npython -m openvoice_cli batch -id INPUT_DIR -rf REF_FILE [-od OUTPUT_DIR] [-d DEVICE] [-of OUTPUT_FORMAT]\n```\n\n### Options\n\n#### Common Options\n\n- `-h`, `--help`: \n Show this help message and exit.\n\n#### Single File Processing Options\n\n- `-i INPUT`, `--input INPUT` (mandatory): \n Path to the input audio file.\n\n- `-r REF`, `--ref REF` (mandatory): \n Path to the reference audio file for tone color extraction.\n\n- `-o OUTPUT`, `--output OUTPUT`: \n Designate the output path for the converted audio file. By default, the output will be saved as \"out.wav\" in the current directory.\n\n- `-d DEVICE`, `--device DEVICE`: \n Specify the device to use for processing; defaults to 'cpu'. Can be set to a CUDA device with 'cuda:0' if supported and desired.\n\n#### Batch Processing Options\n\n- `-id INPUT_DIR`, `--input_dir INPUT_DIR` (mandatory): \n Input directory containing audio files to process.\n\n- `-rf REF_FILE`, `--ref_file REF_FILE` (mandatory): \n Reference audio file path.\n\n- `-od OUTPUT_DIR`, `--output_dir OUTPUT_DIR`: \n Output directory for converted audio files. Defaults to \"outputs\".\n\n- `-d DEVICE`, `--device DEVICE`: \n Specify the processing device. Defaults to 'cuda' if available.\n\n- `-of OUTPUT_FORMAT`, `--output_format OUTPUT_FORMAT`: \n Output file format (e.g., \".wav\"). Defaults to \".wav\".\n\n### Example Commands via console\n\n**Single file processing**\n\n```bash\npython -m openvoice_cli single -i ./test/test.wav -r ./test/ref.wav -o ./test/ready.wav\n```\n\n**Batch processing**\n\n```bash\npython -m openvoice_cli batch -id ./test/input_folder -rf ./test/ref.wav -od ./test/output_folder -of .mp3\n```\n\n### Example via Python Code\n\nFor 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:\n\n**Single File Conversion**\n\n```python\nfrom openvoice_cli import tune_one\n\n# Set parameters for single file processing\ninput_file = 'path_to_input.wav'\nref_file = 'path_to_reference.wav'\noutput_file = 'path_to_output.wav'\ndevice = 'cpu' # or 'cuda:0' for GPU processing\n\n# Convert the tone color of a single audio file\ntune_one(input_file=input_file, ref_file=ref_file, output_file=output_file, device=device)\n```\n\n**Batch Processing**\n\n```python\nfrom openvoice_cli import tune_batch\n\n# Set parameters for batch processing\ninput_dir = 'path_to_input_directory'\nref_file = 'path_to_reference.wav'\noutput_dir = 'path_to_output_directory'\ndevice = 'cuda' # or 'cpu' for CPU processing\noutput_format = '.wav' # could be .mp3 or other formats\n\n# Convert the tone color of multiple audio files in a directory\noutput = tune_batch(input_dir=input_dir, ref_file=ref_file, output_dir=output_dir, device=device, output_format=output_format)\n```\n\nIn these examples:\n- 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.\n- 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.\n- 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.\n\n## License\nThis repository is licensed under MIT License\n\nOriginal 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.\n",
"bugtrack_url": null,
"license": null,
"summary": "Use OpenVoice 2 stage via console or python scripts",
"version": "0.0.5",
"project_urls": {
"Bug Tracker": "https://github.com/daswer123/OpenVoice-cli/issues",
"Homepage": "https://github.com/daswer123/OpenVoice-cli"
},
"split_keywords": [],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "42bfc74b9b8365c42ec8a55aef07c209259c1023c183fecdb97e2372ded6b41e",
"md5": "ff34866112105200d30dcaa0f8bbf673",
"sha256": "b04af2a8a944c44ba128375df3bca04a125057cb247617957607cec32828acb5"
},
"downloads": -1,
"filename": "openvoice_cli-0.0.5-py3-none-any.whl",
"has_sig": false,
"md5_digest": "ff34866112105200d30dcaa0f8bbf673",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 44801,
"upload_time": "2024-06-02T22:40:27",
"upload_time_iso_8601": "2024-06-02T22:40:27.972326Z",
"url": "https://files.pythonhosted.org/packages/42/bf/c74b9b8365c42ec8a55aef07c209259c1023c183fecdb97e2372ded6b41e/openvoice_cli-0.0.5-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "a3c12e3e8ebb1206b73d9b2eba99517792deed05cfc447e60338dfa1c5436f0c",
"md5": "d8311fa3592d36cb32492db35aacc761",
"sha256": "3090c827267013e81476f06aabd162286d3ab90b59a32489cf00a6f907d38310"
},
"downloads": -1,
"filename": "openvoice_cli-0.0.5.tar.gz",
"has_sig": false,
"md5_digest": "d8311fa3592d36cb32492db35aacc761",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 1845876,
"upload_time": "2024-06-02T22:40:30",
"upload_time_iso_8601": "2024-06-02T22:40:30.488584Z",
"url": "https://files.pythonhosted.org/packages/a3/c1/2e3e8ebb1206b73d9b2eba99517792deed05cfc447e60338dfa1c5436f0c/openvoice_cli-0.0.5.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-06-02 22:40:30",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "daswer123",
"github_project": "OpenVoice-cli",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [
{
"name": "librosa",
"specs": [
[
"==",
"0.9.1"
]
]
},
{
"name": "pydub",
"specs": [
[
"==",
"0.25.1"
]
]
},
{
"name": "wavmark",
"specs": [
[
"==",
"0.0.3"
]
]
},
{
"name": "faster-whisper",
"specs": [
[
">=",
"0.9.0"
]
]
},
{
"name": "whisper-timestamped",
"specs": [
[
">=",
"1.14.2"
]
]
},
{
"name": "torch",
"specs": [
[
">=",
"1.13.1"
]
]
},
{
"name": "torchaudio",
"specs": [
[
">=",
"0.13.1"
]
]
},
{
"name": "typing-extensions",
"specs": [
[
">=",
"4.6.1"
]
]
},
{
"name": "numpy",
"specs": [
[
">",
"1.24.2"
]
]
}
],
"lcname": "openvoice-cli"
}