ryoooo
服务介绍
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 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
- Create a
.envfile and add the following content:
NIJIVOICE_API_KEY=Your API Key
DEFAULT_VOICE_ACTOR_ID=Default Voice Actor ID (optional)
LOG_LEVEL=INFO
- 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 filevoice/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:
- This project is under development, and features or specifications may change.
- Changes in the Nijivoice API specifications may cause it to stop working.
- There are parts where error handling is not sufficient.
- Timeouts may occur during the generation of long voice clips.
- It may not be compatible with some API response structures.
Troubleshooting
If you encounter any issues:
- Check the log file
nijivoice_mcp.log. - Ensure that the API key is correctly set.
- Verify your internet connection.
- Check the status of the Nijivoice API.
License
This project is provided under the MIT License.
Acknowledgments
This project uses FastMCP and Model Context Protocol. It utilizes the voice synthesis technology of Nijivoice.
“Voiced by NIJI Voice”