Skip to main content

A Nonebot Use Version for MockingBird

Project description

Nonebot MockingBird Support

如果需要直接使用本插件,请将训练好的模型放在机器人根目录下命名为 Mocking_model.pt , 将音频放置同样的目录下命名 recoder.wav

Mocking Bird

mockingbird

MIT License

DEMO VIDEO | Wiki教程训练教程

开始

1. 安装要求

按照原始存储库测试您是否已准备好所有环境。 Python 3.7 或更高版本 需要运行工具箱。

如果在用 pip 方式安装的时候出现 ERROR: Could not find a version that satisfies the requirement torch==1.9.0+cu102 (from versions: 0.1.2, 0.1.2.post1, 0.1.2.post2) 这个错误可能是 python 版本过低,3.9 可以安装成功

2. 训练模型

此部分请参考原仓库,本仓库精简了部分关于训练模型的代码

2.3使用社区预先训练好的合成器(与2.2二选一)

当实在没有设备或者不想慢慢调试,可以使用社区贡献的模型(欢迎持续分享):

作者 下载链接 效果预览 信息
作者 https://pan.baidu.com/s/1iONvRxmkI-t1nHqxKytY3g 百度盘链接 4j5d 75k steps 用3个开源数据集混合训练
作者 https://pan.baidu.com/s/1fMh9IlgKJlL2PIiRTYDUvw 百度盘链接 提取码:om7f 25k steps 用3个开源数据集混合训练, 切换到tag v0.0.1使用
@FawenYo https://drive.google.com/file/d/1H-YGOUHpmqKxJ9FRc6vAjPuqQki24UbC/view?usp=sharing 百度盘链接 提取码:1024 input output 200k steps 台湾口音需切换到tag v0.0.1使用
@miven https://pan.baidu.com/s/1PI-hM3sn5wbeChRryX-RCQ 提取码:2021 https://www.bilibili.com/video/BV1uh411B7AD/ 150k steps 注意:根据issue修复 并切换到tag v0.0.1使用

2.4 训练声码器 (可选)

预置默认使用HifiGan

3 使用插件

主要是使用MockingBirdOnlyForUse库的MockingBird, Params

```python
使用MockingBird时自定义的参数

    Args:
        text (str): 生成语音的目标文字
        recoder_path (Path): 目标录音目录
        synthesizer_path (Path, optional): Synthesizer模型位置. 为None时使用已缓存的模型,如果没有,将会报错。 Defaults to None.
        accuracy (int, optional): Accuracy(精度) 范围3~9. Defaults to 4.
        steps (int, optional): MaxLength(最大句长) 范围1~10. Defaults to 4.
        style_idx (int, optional): Style 范围 -1~9. Defaults to -1.
        save_path (Path, optional): 生成后保存到文件的路径,不填会返回ByteIO类型,填上返回的是Path类型. Defaults to None.
        vocoder (str, optional): 选择Vocoder模型,影响不大,默认使用HifiGan,可选WaveRNN. Defaults to "HifiGan".
        seed (int, optional): 种子,不建议修改. Defaults to None.
        trim_silences (bool): Defaults to False.
```
from Nonebot_MockingBird_Plugin import MockingBird, Params, part

part.keywords["synthesizer_path"] = Path("azusa_200k.pt")
part.keywords["recoder_path"] = Path("temp3.wav")
# 样例
import os.path

from MockingBirdOnlyForUse import MockingBird, Params
from MockingBirdOnlyForUse import logger as mocking_logger
from pathlib import Path
from nonebot import export, on_command
from functools import partial

from nonebot.adapters.onebot.v11 import Message, MessageSegment
from nonebot.params import CommandArg
from nonebot.rule import to_me
from nonebot.log import logger as nonebot_logger


root = os.path.abspath(os.path.join(__file__, "..", "resources"))
mocking_logger.logger = nonebot_logger  # 覆盖使用nonebot的logger

MockingBird.init(
    Path(os.path.join(root, "encoder.pt")),
    Path(os.path.join(root, "g_hifigan.pt")),
    "HifiGan",
)


part = partial(
    Params,
    recoder_path=Path("recoder.wav"),
    synthesizer_path=Path("mocking_model.pt"),
    vocoder="HifiGan",
)

export = export()
export.MockingBird = MockingBird
export.Params = Params
export.part = part

voice = on_command("讲话", aliases={"语音"}, block=True, rule=to_me(), priority=1)


@voice.handle()
async def _(args: Message = CommandArg()):
    params = part(args)
    params.text = args.extract_plain_text()
    await voice.finish(MessageSegment.record(MockingBird.genrator_voice(params)))

4. 其他模型

电梓播放器

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nonebot_mockingbird_plugin-0.0.2.tar.gz (64.1 MB view details)

Uploaded Source

Built Distribution

nonebot_mockingbird_plugin-0.0.2-py3-none-any.whl (64.1 MB view details)

Uploaded Python 3

File details

Details for the file nonebot_mockingbird_plugin-0.0.2.tar.gz.

File metadata

  • Download URL: nonebot_mockingbird_plugin-0.0.2.tar.gz
  • Upload date:
  • Size: 64.1 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/1.5.0 colorama/0.4.4 CPython/3.9.9

File hashes

Hashes for nonebot_mockingbird_plugin-0.0.2.tar.gz
Algorithm Hash digest
SHA256 2f16f614640b8a644c632cb7f99385aa0f7794cfbd3b3adfff07fd2a41e67110
MD5 e514f73e1472beb3869c762dedaf487b
BLAKE2b-256 b7c4b693b6f337f2963456124049f55f4a5f279b08f0b6b79b044d804fbcdd85

See more details on using hashes here.

File details

Details for the file nonebot_mockingbird_plugin-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: nonebot_mockingbird_plugin-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 64.1 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/1.5.0 colorama/0.4.4 CPython/3.9.9

File hashes

Hashes for nonebot_mockingbird_plugin-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 e7d8d9b7f7a26c18143b2f1fedfdaf8341e69328d4bfd4c6e76a39e900f44b70
MD5 6e8360be3de987a12d8b8665b1a2a752
BLAKE2b-256 8151ac7f4797ee6093f44bdc67d2007d1511730948c7c76ddc22181b1942e71d

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page