r

ryoooo

@ryoooo/nijivoice-mcp
0 Stars 11 次浏览 ryoooo 更新于 2026-08-23
该服务暂未提供标准配置,请参考 README 手动接入

服务介绍

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

  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

  1. 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

  • 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.

Acknowledgments

This project uses FastMCP and Model Context Protocol. It utilizes the voice synthesis technology of Nijivoice.


“Voiced by NIJI Voice”

相关 MCP 服务