⭐ A TTS plugin based on Nonebot2 that calls online fish-audio or offline fish-speech APIs ⭐
⭐Text-to-speech tts
plugin⭐
简体中文 | English
With just a 5-second voice sample, you can perfectly excellently clone the original voice!
Simply prepare the voice of the character you wish to clone, label the voice file (see below), and you can quickly generate speech.
Alternatively, use the official online API -> fish-audio for fast cloud-based speech generation.
Note
This plugin is for learning and research purposes only. Users must assume all risks associated with using the plugin. The author is not responsible for any losses or issues arising from the use of the plugin. Please use the plugin responsibly and comply with relevant laws and regulations. Using this plugin indicates that you have read and agree to the above disclaimer. If you do not agree or cannot comply with the above statement, please do not use this plugin.
installation
Using pipx
:
pipx install nonebot-plugin-fishspeech-tts -U
[!note] Add this plugin to the
plugins = ["xxx"]
section inpyproject.toml
.
Using nb-cli
:
nb plugin install nonebot-plugin-fishspeech-tts -U
Using git clone
(not recommended):
- Run the following command in the command prompt:
git clone https://github.com/Cvandia/nonebot-plugin-fishspeech-tts
- Copy the
nonebot-plugin-fishspeech-tts
folder to thesrc/plugins
directory in the bot's root directory (or another name you used when creating the bot).
note
Recommended mirror sites for download:
- Tsinghua Source:
https://pypi.tuna.tsinghua.edu.cn/simple
- Alibaba Source:
https://mirrors.aliyun.com/pypi/simple/
Add the following configurations to .env
:
Basic Configuration | Type | Required | Default Value | Description |
---|---|---|---|---|
tts_is_online | bool | Yes | True | Whether to use the cloud API |
tts_chunk_length | literal | No | "normal" | Audio chunk length for requests, defaults to normal; options: short, normal, long |
tts_is_to_me | bool | No | True | Whether to respond only when mentioned |
tts_audio_path | str | No | "./data/reference_audio" | Path for voice samples, defaults to "./data/reference_audio" |
Note: The file name format for reference audio should be: [Character Name]Text Label.[Audio Extension]
! Supports different voices for the same character!
Currently supported audio extensions are detailed in files.py under AUDIO_FILE_SUFFIX
.
If you want to use the official API, set the configuration item tts_is_online
to True
and configure the following:
Configuration Item | Type | Required | Default Value | Description |
---|---|---|---|---|
online_authorization | str | Yes | "xxxxx" | API key for official authorization, see link |
online_model_first | bool | No | True | Set this to False if you want to call the official model with your reference audio to customize character voice; if you don't have reference audio, it will call existing voices from the official website. See link for details. |
If you want to use a self-hosted or other fish-speech project APIs, set the configuration item tts_is_online
to False
and configure the following:
Configuration Item | Type | Required | Default Value | Description |
---|---|---|---|---|
offline_api_url | str | Yes | "http://127.0.0.1:8080" | Your fish-speech API address |
Note
Please pay attention to your COMMAND_START
and the above configuration items.
Command | Requires @ | Scope | Description | Permissions |
---|---|---|---|---|
xxx says xxx | Based on configuration | all | TTS speech generation | all |
Voice list | Yes | all | Retrieve all character lists | all |
Voice balance | Yes | all | Check API balance | all |
- No plans at the moment. If you like it, remember to give it a star ⭐
- nonebot2: The foundation of this project, a very useful chatbot framework.
- fish-speech: Zero-shot & few-shot TTS: Generate high-quality TTS output with just 10 to 30 seconds of voice samples.
Prepare fish-speech
:
- Clone the
fish-speech
repository locally:
git clone https://github.com/fishaudio/fish-speech
- Run
install_env.bat
to set up the virtual environment and required dependencies. - Run
start.bat
for the initial startup. - Modify
API_FLAGS.txt
and restart.
Start API Service:
- Modify
API_FLAGS.txt
to uncomment (remove#
) in front ofapi
:
# --infer
--api
--listen 0.0.0.0:8080 \ # Listening interface
...
Add Additional Parameters in API_FLAGS.txt
:
--compile
-> Whether to start the compiled model (faster TTS generation but slower startup).--workers <number>
-> Start<number>
of concurrent processes (must set, as default one can easily block).- More details can be found in the official documentation.