Name | rvc-python JSON |
Version |
0.1.5
JSON |
| download |
home_page | None |
Summary | Use RVC via console or python scripts |
upload_time | 2024-11-04 11:41:50 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.9 |
license | None |
keywords |
|
VCS |
 |
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# RVC Python
A Python implementation for using RVC (Retrieval-based Voice Conversion) via console, Python scripts, or API.
## Table of Contents
- [Features](#features)
- [Installation](#installation)
- [Usage](#usage)
- [Command Line Interface](#command-line-interface)
- [Python Module](#python-module)
- [API](#api)
- [Model Management](#model-management)
- [Options](#options)
- [Advanced Setup (GPU Acceleration)](#advanced-setup-gpu-acceleration)
- [Changelog](#changelog)
- [Contributing](#contributing)
## Demo
https://github.com/daswer123/rvc-python/assets/22278673/6ecb590e-8a71-46aa-8ade-ba3fcfd75009
## Features
- Console interface for single file or batch processing
- Python module for integration into other projects
- API server for remote processing
- Support for both CPU and GPU acceleration
- Dynamic model loading and unloading
- Flexible model directory management
## Installation
### Basic Installation (CPU only)
```bash
pip install rvc-python
```
### Recommended Installation (with GPU support)
Recommended python version: 3.10
For Windows:
```bash
py -3.10 -m venv venv
venv\Scripts\activate
pip install rvc-python
pip install torch==2.1.1+cu118 torchaudio==2.1.1+cu118 --index-url https://download.pytorch.org/whl/cu118
```
For Linux:
```bash
python3.10 -m venv venv
source venv/bin/activate
pip install rvc-python
pip install torch==2.1.1+cu118 torchaudio==2.1.1+cu118 --index-url https://download.pytorch.org/whl/cu118
```
## Usage
### Command Line Interface
The CLI supports two modes: `cli` for direct file processing and `api` for starting an API server.
```bash
python -m rvc_python [-h] {cli,api} ...
```
#### CLI Mode
Process a single file or batch of files:
```bash
python -m rvc_python cli -i INPUT -o OUTPUT -mp MODEL [options]
```
Example:
```bash
python -m rvc_python cli -i input.wav -o output.wav -mp path/to/model.pth -de cuda:0
```
#### API Mode
Start the API server:
```bash
python -m rvc_python api [-p PORT] [-l] [options]
```
Example:
```bash
python -m rvc_python api -p 5050 -l
```
### Python Module
```python
from rvc_python.infer import RVCInference
rvc = RVCInference(device="cuda:0")
rvc.load_model("path/to/model.pth")
rvc.infer_file("input.wav", "output.wav")
```
### API
The API server provides several endpoints for voice conversion and model management. Here's a detailed breakdown of each endpoint:
#### 1. Convert Audio
- **Endpoint**: `POST /convert`
- **Description**: Converts an audio file using the currently loaded model.
- **Request Body**:
```json
{
"audio_data": "base64_encoded_audio"
}
```
- **Response**: The converted audio file (WAV format)
- **Example**:
```python
import requests
import base64
url = "http://localhost:5050/convert"
with open("input.wav", "rb") as audio_file:
audio_data = base64.b64encode(audio_file.read()).decode()
response = requests.post(url, json={"audio_data": audio_data})
with open("output.wav", "wb") as output_file:
output_file.write(response.content)
```
#### 2. List Available Models
- **Endpoint**: `GET /models`
- **Description**: Returns a list of all available models.
- **Response**: JSON array of model names
- **Example**:
```python
response = requests.get("http://localhost:5050/models")
models = response.json()
print("Available models:", models)
```
#### 3. Load a Model
- **Endpoint**: `POST /models/{model_name}`
- **Description**: Loads a specific model for use in conversions.
- **Response**: Confirmation message
- **Example**:
```python
response = requests.post("http://localhost:5050/models/my_model")
print(response.json())
```
#### 4. Get Current Parameters
- **Endpoint**: `GET /params`
- **Description**: Retrieves the current parameter settings.
- **Response**: JSON object with current parameters
- **Example**:
```python
response = requests.get("http://localhost:5050/params")
print("Current parameters:", response.json())
```
#### 5. Set Parameters
- **Endpoint**: `POST /params`
- **Description**: Updates the parameters for voice conversion.
- **Request Body**:
```json
{
"params": {
"f0method": "harvest",
"f0up_key": 0,
"index_rate": 0.5,
"filter_radius": 3,
"resample_sr": 0,
"rms_mix_rate": 0.25,
"protect": 0.33
}
}
```
- **Response**: Confirmation message
- **Example**:
```python
params = {
"f0method": "harvest",
"f0up_key": 2,
"protect": 0.5
}
response = requests.post("http://localhost:5050/params", json={"params": params})
print(response.json())
```
#### 6. Upload a New Model
- **Endpoint**: `POST /upload_model`
- **Description**: Uploads a new model (as a zip file) to the server.
- **Request**: Multipart form data with a zip file
- **Response**: Confirmation message
- **Example**:
```python
with open("new_model.zip", "rb") as zip_file:
files = {"file": ("new_model.zip", zip_file)}
response = requests.post("http://localhost:5050/upload_model", files=files)
print(response.json())
```
#### 7. Set Computation Device
- **Endpoint**: `POST /set_device`
- **Description**: Sets the device (CPU/GPU) for computations.
- **Request Body**:
```json
{
"device": "cuda:0"
}
```
- **Response**: Confirmation message
- **Example**:
```python
response = requests.post("http://localhost:5050/set_device", json={"device": "cuda:0"})
print(response.json())
```
## Model Management
Models are stored in the `rvc_models` directory by default. Each model should be in its own subdirectory and contain:
- A `.pth` file (required): The main model file.
- An `.index` file (optional): For improved voice conversion quality.
Example structure:
```
rvc_models/
├── model1/
│ ├── model1.pth
│ └── model1.index
└── model2/
└── model2.pth
```
You can add new models by:
1. Manually placing them in the `rvc_models` directory.
2. Using the `/upload_model` API endpoint to upload a zip file containing the model files.
3. Using the `/set_models_dir` API endpoint to change the models directory dynamically.
## Options
### Input/Output Options
- `-i`, `--input`: Input audio file (CLI mode)
- `-d`, `--dir`: Input directory for batch processing (CLI mode)
- `-o`, `--output`: Output file or directory
### Model Options
- `-mp`, `--model`: Path to the RVC model file (required for CLI, optional for API)
- `-md`, `--models_dir`: Directory containing RVC models (default: `rvc_models` in the current directory)
- `-ip`, `--index`: Path to the index file (optional)
- `-v`, `--version`: Model version (v1 or v2)
### Processing Options
- `-de`, `--device`: Computation device (e.g., "cpu", "cuda:0")
- `-me`, `--method`: Pitch extraction method (harvest, crepe, rmvpe, pm)
- `-pi`, `--pitch`: Pitch adjustment in semitones
- `-ir`, `--index_rate`: Feature search ratio
- `-fr`, `--filter_radius`: Median filtering radius for pitch
- `-rsr`, `--resample_sr`: Output resampling rate
- `-rmr`, `--rms_mix_rate`: Volume envelope mix rate
- `-pr`, `--protect`: Protection for voiceless consonants
### API Server Options
- `-p`, `--port`: API server port (default: 5050)
- `-l`, `--listen`: Allow external connections to API server
- `-pm`, `--preload-model`: Preload a model when starting the API server (optional)
## Changelog
For a detailed list of changes and updates, please see the [Releases page](https://github.com/daswer123/rvc-python/releases).
## Contributing
Contributions are welcome! Feel free to submit pull requests or open issues for bugs and feature requests.
Raw data
{
"_id": null,
"home_page": null,
"name": "rvc-python",
"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/da/79/7037285a5b6c883310bf1969023fddfea01d3c7a2d30a375b93561f21ff7/rvc_python-0.1.5.tar.gz",
"platform": null,
"description": "# RVC Python\n\nA Python implementation for using RVC (Retrieval-based Voice Conversion) via console, Python scripts, or API.\n\n## Table of Contents\n- [Features](#features)\n- [Installation](#installation)\n- [Usage](#usage)\n - [Command Line Interface](#command-line-interface)\n - [Python Module](#python-module)\n - [API](#api)\n- [Model Management](#model-management)\n- [Options](#options)\n- [Advanced Setup (GPU Acceleration)](#advanced-setup-gpu-acceleration)\n- [Changelog](#changelog)\n- [Contributing](#contributing)\n\n## Demo\n\nhttps://github.com/daswer123/rvc-python/assets/22278673/6ecb590e-8a71-46aa-8ade-ba3fcfd75009\n\n## Features\n\n- Console interface for single file or batch processing\n- Python module for integration into other projects\n- API server for remote processing\n- Support for both CPU and GPU acceleration\n- Dynamic model loading and unloading\n- Flexible model directory management\n\n## Installation\n\n### Basic Installation (CPU only)\n\n```bash\npip install rvc-python\n```\n\n### Recommended Installation (with GPU support)\n\nRecommended python version: 3.10\n\nFor Windows:\n```bash\npy -3.10 -m venv venv\nvenv\\Scripts\\activate\npip install rvc-python\npip install torch==2.1.1+cu118 torchaudio==2.1.1+cu118 --index-url https://download.pytorch.org/whl/cu118\n```\n\nFor Linux:\n```bash\npython3.10 -m venv venv\nsource venv/bin/activate\npip install rvc-python\npip install torch==2.1.1+cu118 torchaudio==2.1.1+cu118 --index-url https://download.pytorch.org/whl/cu118\n```\n\n## Usage\n\n### Command Line Interface\n\nThe CLI supports two modes: `cli` for direct file processing and `api` for starting an API server.\n\n```bash\npython -m rvc_python [-h] {cli,api} ...\n```\n\n#### CLI Mode\nProcess a single file or batch of files:\n\n```bash\npython -m rvc_python cli -i INPUT -o OUTPUT -mp MODEL [options]\n```\n\nExample:\n```bash\npython -m rvc_python cli -i input.wav -o output.wav -mp path/to/model.pth -de cuda:0\n```\n\n#### API Mode\nStart the API server:\n\n```bash\npython -m rvc_python api [-p PORT] [-l] [options]\n```\n\nExample:\n```bash\npython -m rvc_python api -p 5050 -l\n```\n\n### Python Module\n\n```python\nfrom rvc_python.infer import RVCInference\n\nrvc = RVCInference(device=\"cuda:0\")\nrvc.load_model(\"path/to/model.pth\")\nrvc.infer_file(\"input.wav\", \"output.wav\")\n```\n\n### API\n\nThe API server provides several endpoints for voice conversion and model management. Here's a detailed breakdown of each endpoint:\n\n#### 1. Convert Audio\n- **Endpoint**: `POST /convert`\n- **Description**: Converts an audio file using the currently loaded model.\n- **Request Body**:\n ```json\n {\n \"audio_data\": \"base64_encoded_audio\"\n }\n ```\n- **Response**: The converted audio file (WAV format)\n- **Example**:\n ```python\n import requests\n import base64\n\n url = \"http://localhost:5050/convert\"\n with open(\"input.wav\", \"rb\") as audio_file:\n audio_data = base64.b64encode(audio_file.read()).decode()\n\n response = requests.post(url, json={\"audio_data\": audio_data})\n\n with open(\"output.wav\", \"wb\") as output_file:\n output_file.write(response.content)\n ```\n\n#### 2. List Available Models\n- **Endpoint**: `GET /models`\n- **Description**: Returns a list of all available models.\n- **Response**: JSON array of model names\n- **Example**:\n ```python\n response = requests.get(\"http://localhost:5050/models\")\n models = response.json()\n print(\"Available models:\", models)\n ```\n\n#### 3. Load a Model\n- **Endpoint**: `POST /models/{model_name}`\n- **Description**: Loads a specific model for use in conversions.\n- **Response**: Confirmation message\n- **Example**:\n ```python\n response = requests.post(\"http://localhost:5050/models/my_model\")\n print(response.json())\n ```\n\n#### 4. Get Current Parameters\n- **Endpoint**: `GET /params`\n- **Description**: Retrieves the current parameter settings.\n- **Response**: JSON object with current parameters\n- **Example**:\n ```python\n response = requests.get(\"http://localhost:5050/params\")\n print(\"Current parameters:\", response.json())\n ```\n\n#### 5. Set Parameters\n- **Endpoint**: `POST /params`\n- **Description**: Updates the parameters for voice conversion.\n- **Request Body**:\n ```json\n {\n \"params\": {\n \"f0method\": \"harvest\",\n \"f0up_key\": 0,\n \"index_rate\": 0.5,\n \"filter_radius\": 3,\n \"resample_sr\": 0,\n \"rms_mix_rate\": 0.25,\n \"protect\": 0.33\n }\n }\n ```\n- **Response**: Confirmation message\n- **Example**:\n ```python\n params = {\n \"f0method\": \"harvest\",\n \"f0up_key\": 2,\n \"protect\": 0.5\n }\n response = requests.post(\"http://localhost:5050/params\", json={\"params\": params})\n print(response.json())\n ```\n\n#### 6. Upload a New Model\n- **Endpoint**: `POST /upload_model`\n- **Description**: Uploads a new model (as a zip file) to the server.\n- **Request**: Multipart form data with a zip file\n- **Response**: Confirmation message\n- **Example**:\n ```python\n with open(\"new_model.zip\", \"rb\") as zip_file:\n files = {\"file\": (\"new_model.zip\", zip_file)}\n response = requests.post(\"http://localhost:5050/upload_model\", files=files)\n print(response.json())\n ```\n\n#### 7. Set Computation Device\n- **Endpoint**: `POST /set_device`\n- **Description**: Sets the device (CPU/GPU) for computations.\n- **Request Body**:\n ```json\n {\n \"device\": \"cuda:0\"\n }\n ```\n- **Response**: Confirmation message\n- **Example**:\n ```python\n response = requests.post(\"http://localhost:5050/set_device\", json={\"device\": \"cuda:0\"})\n print(response.json())\n ```\n\n## Model Management\n\nModels are stored in the `rvc_models` directory by default. Each model should be in its own subdirectory and contain:\n\n- A `.pth` file (required): The main model file.\n- An `.index` file (optional): For improved voice conversion quality.\n\nExample structure:\n```\nrvc_models/\n\u251c\u2500\u2500 model1/\n\u2502 \u251c\u2500\u2500 model1.pth\n\u2502 \u2514\u2500\u2500 model1.index\n\u2514\u2500\u2500 model2/\n \u2514\u2500\u2500 model2.pth\n```\n\nYou can add new models by:\n1. Manually placing them in the `rvc_models` directory.\n2. Using the `/upload_model` API endpoint to upload a zip file containing the model files.\n3. Using the `/set_models_dir` API endpoint to change the models directory dynamically.\n\n## Options\n\n### Input/Output Options\n- `-i`, `--input`: Input audio file (CLI mode)\n- `-d`, `--dir`: Input directory for batch processing (CLI mode)\n- `-o`, `--output`: Output file or directory\n\n### Model Options\n- `-mp`, `--model`: Path to the RVC model file (required for CLI, optional for API)\n- `-md`, `--models_dir`: Directory containing RVC models (default: `rvc_models` in the current directory)\n- `-ip`, `--index`: Path to the index file (optional)\n- `-v`, `--version`: Model version (v1 or v2)\n\n### Processing Options\n- `-de`, `--device`: Computation device (e.g., \"cpu\", \"cuda:0\")\n- `-me`, `--method`: Pitch extraction method (harvest, crepe, rmvpe, pm)\n- `-pi`, `--pitch`: Pitch adjustment in semitones\n- `-ir`, `--index_rate`: Feature search ratio\n- `-fr`, `--filter_radius`: Median filtering radius for pitch\n- `-rsr`, `--resample_sr`: Output resampling rate\n- `-rmr`, `--rms_mix_rate`: Volume envelope mix rate\n- `-pr`, `--protect`: Protection for voiceless consonants\n\n### API Server Options\n- `-p`, `--port`: API server port (default: 5050)\n- `-l`, `--listen`: Allow external connections to API server\n- `-pm`, `--preload-model`: Preload a model when starting the API server (optional)\n\n## Changelog\n\nFor a detailed list of changes and updates, please see the [Releases page](https://github.com/daswer123/rvc-python/releases).\n\n## Contributing\n\nContributions are welcome! Feel free to submit pull requests or open issues for bugs and feature requests.\n",
"bugtrack_url": null,
"license": null,
"summary": "Use RVC via console or python scripts",
"version": "0.1.5",
"project_urls": {
"Bug Tracker": "https://github.com/daswer123/rvc-python/issues",
"Homepage": "https://github.com/daswer123/rvc-python"
},
"split_keywords": [],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "ab3f51045f6ea89ceda7026b89c1cfcac8f0128b1de00bfeb98ff29fba1def33",
"md5": "daaa51fc2b5d3c6becc6e39ac2b1fd0c",
"sha256": "d2dfd7e20e32062952382b0846979f5cde5f319266dee0599136349f5b521ab0"
},
"downloads": -1,
"filename": "rvc_python-0.1.5-py3-none-any.whl",
"has_sig": false,
"md5_digest": "daaa51fc2b5d3c6becc6e39ac2b1fd0c",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 85316,
"upload_time": "2024-11-04T11:41:48",
"upload_time_iso_8601": "2024-11-04T11:41:48.455977Z",
"url": "https://files.pythonhosted.org/packages/ab/3f/51045f6ea89ceda7026b89c1cfcac8f0128b1de00bfeb98ff29fba1def33/rvc_python-0.1.5-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "da797037285a5b6c883310bf1969023fddfea01d3c7a2d30a375b93561f21ff7",
"md5": "7bb886868ab08e3099c2e0d09d5bb316",
"sha256": "486da646e4813b0d7d2ad8ac31eff728e7ecb8adfc05c545f2768b11542f6857"
},
"downloads": -1,
"filename": "rvc_python-0.1.5.tar.gz",
"has_sig": false,
"md5_digest": "7bb886868ab08e3099c2e0d09d5bb316",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 65362,
"upload_time": "2024-11-04T11:41:50",
"upload_time_iso_8601": "2024-11-04T11:41:50.051488Z",
"url": "https://files.pythonhosted.org/packages/da/79/7037285a5b6c883310bf1969023fddfea01d3c7a2d30a375b93561f21ff7/rvc_python-0.1.5.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-11-04 11:41:50",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "daswer123",
"github_project": "rvc-python",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [],
"lcname": "rvc-python"
}