# ryoooo
## 基本信息
- Slug: `ryoooo-nijivoice-mcp`
- Source: modelscope
- Publisher: @ryoooo/nijivoice-mcp
- Categories: text-to-speech / speech-processing
- Hosted: No
- License: MIT License
- Source URL: https://www.modelscope.cn/mcp/servers/@ryoooo/nijivoice-mcp
## 简介
暂无描述。
## MCP Server 详情

# NijiVoice-MCP

**⚠️ Notice: This project is under development and has not been fully tested. It is not recommended for use in a production environment. ⚠️**

NijiVoice-MCP is an implementation of the Model Context Protocol (MCP) for the [Nijivoice](https://www.nijivoice.com/) API. It enables access to the Nijivoice API from LLMs (Large Language Models), making it easy to perform text-to-speech synthesis.

## Overview of Features

- Text-to-speech synthesis using the Nijivoice API
- Retrieval of available voice actors
- Checking credit balance
- Integration with LLMs through the MCP interface

## Prerequisites

- Python 3.12 or higher
- Nijivoice API key
- Internet connection

## Installation

bash
# Clone the repository
git clone https://github.com/YOUR_USERNAME/nijivoice-mcp.git
cd nijivoice-mcp

# Install dependencies
pip install -e .


## Environment Setup

1. Create a `.env` file and add the following content:


NIJIVOICE_API_KEY=Your API Key
DEFAULT_VOICE_ACTOR_ID=Default Voice Actor ID (optional)
LOG_LEVEL=INFO


2. You can obtain the API key from the official Nijivoice website.

## Usage

### Starting the MCP Server

bash
python main.py


This will start the MCP server, ready to accept requests from LLM clients.

### Example of Speech Synthesis

Call the tools from an LLM client that utilizes the MCP server as follows:

python
# Retrieve available voice actors
actors = await tools.call("actor/get_voice_actors")

# Generate speech
voice_result = await tools.call("voice/generate_voice", {
    "script": "こんにちは、にじボイスのテストです。",
    "voice_actor_id": "90031163-c497-44f3-a8a6-e45e4d0cb8f6",  # Voice Actor ID
    "speed": 1.0,
    "emotional_level": 0.5,
    "sound_duration": 0.1,
    "format": "mp3"
})

# Check credit balance
balance = await tools.call("credit/get_credit_balance")


## Available MCP Tools

### Voice Actor Related

- `actor/get_voice_actors()`: Retrieves a list of available voice actors

### Voice Generation

- `voice/generate_voice(script, voice_actor_id, speed, emotional_level, sound_duration, format)`: Generates a URL for the audio file
- `voice/generate_encoded_voice(script, voice_actor_id, speed, emotional_level, sound_duration, format)`: Generates Base64 encoded audio data

### Credit Management

- `credit/get_credit_balance()`: Retrieves the credit balance

## Support for Special Tags

The following special tags can be used within scripts:

- `<sp 1.0>xxx</sp>`: Changes the speed of the text within the tag
- `<wait 0.3>`: Inserts a pause for the specified number of seconds

## Information for Developers

### Project Structure


nijivoice-mcp/
├── config.py                # Configuration file
├── debug_api.py             # Script for API debugging
├── lib/                     # Libraries
├── logger.py                # Logging configuration
├── main.py                  # Main entry point
├── mcp/                     # MCP implementation
│   ├── __init__.py          # MCP server initialization
│   ├── actors.py            # Voice actor related tools
│   ├── credits.py           # Credit related tools
│   ├── prompts.py           # Prompt definitions
│   └── voice.py             # Voice generation tools
├── nijivoice/               # Nijivoice API client
│   ├── __init__.py
│   ├── api.py               # API client implementation
│   ├── exceptions.py        # Exception definitions
│   └── models.py            # Data models
├── pyproject.toml           # Project definition
├── server.py                # Server implementation
└── utils/                   # Utilities
    ├── __init__.py
    ├── audio.py             # Audio processing utilities
    ├── error_handling.py    # Error handling
    └── retry.py             # Retry logic### Test

bash
# Run the test
pytest


## Limitations and Known Issues

⚠️ **Important Limitations**:

1. This project is **under development**, and features or specifications may change.
2. Changes in the Nijivoice API specifications may cause it to stop working.
3. There are parts where error handling is not sufficient.
4. Timeouts may occur during the generation of long voice clips.
5. It may not be compatible with some API response structures.

## Troubleshooting

If you encounter any issues:

1. Check the log file `nijivoice_mcp.log`.
2. Ensure that the API key is correctly set.
3. Verify your internet connection.
4. Check the status of the Nijivoice API.

## License

This project is provided under the [MIT License](LICENSE).

## Acknowledgments

This project uses [FastMCP](https://github.com/fastmcp/fastmcp) and [Model Context Protocol](https://modelcontextprotocol.io/). It utilizes the voice synthesis technology of Nijivoice.

---

*“Voiced by NIJI Voice”*

