Kitten TTS是一个开源的现实文本到语音模型,只有1500万个参数,专为轻量级部署和高质量语音合成而设计(截止0.2未发布版,不支持中文)

官网:KittenML/KittenTTS: State-of-the-art TTS model under 25MB 😻

对了,这个模型最大的问题是不会中文。

Kitten TTS介绍

Kitten TTS是一个开源的现实文本到语音模型,只有1500万个参数,专为轻量级部署和高质量语音合成而设计。目前处于开发者预览阶段

✨ 特性

超轻:型号大小小于25MB

CPU优化:在任何设备上无需GPU即可运行

高品质语音:提供多种高级语音选项

快速推理:针对实时语音合成进行了优化

安装Kitten TTS

直接使用pip安装即可。

复制代码
pip install https://github.com/KittenML/KittenTTS/releases/download/0.1/kittentts-0.1.0-py3-none-any.whl

使用Kitten TTS

直接在python里调用即可

复制代码
from kittentts import KittenTTS
m = KittenTTS("KittenML/kitten-tts-nano-0.2")

audio = m.generate("This high quality TTS model works without a GPU", voice='expr-voice-2-f' )

# available_voices : [  'expr-voice-2-m', 'expr-voice-2-f', 'expr-voice-3-m', 'expr-voice-3-f',  'expr-voice-4-m', 'expr-voice-4-f', 'expr-voice-5-m', 'expr-voice-5-f' ]

# Save the audio
import soundfile as sf
sf.write('output.wav', audio, 24000)

整体输出

复制代码
>>> from kittentts import KittenTTS
>>> m = KittenTTS("KittenML/kitten-tts-nano-0.2")
config.json: 177B [00:00, 34.1kB/s]
kitten_tts_nano_v0_2.onnx: 100%|████████████████████████████████████████████████████| 23.8M/23.8M [01:20<00:00, 295kB/s]
voices.npz: 100%|██████████████████████████████████████████████████████████████████| 10.3k/10.3k [00:00<00:00, 13.6MB/s]
>>> import soundfile as sf
>>> audio = m.generate("This high quality TTS model works without a GPU", voice='expr-voice-2-f' )
>>> sf.write('output.wav', audio, 24000)
>>> m = KittenTTS("KittenML/kitten-tts-nano-0.2")
KeyboardInterrupt
>>> audio = m.generate("现在,当用户在创建生字本时,输入的汉字会自动从3500个常用汉字数据库中获取信息", voice='expr-voice
-2-f' )
2025-12-21 00:13:30.158456312 [E:onnxruntime:, sequential_executor.cc:572 ExecuteKernel] Non-zero status code returned while running Expand node. Name:'/bert/Expand' Status Message: invalid expand shape
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/skywalk/.local/lib/python3.10/site-packages/kittentts/get_model.py", line 37, in generate
    return self.model.generate(text, voice=voice, speed=speed)
  File "/home/skywalk/.local/lib/python3.10/site-packages/kittentts/onnx_model.py", line 102, in generate
    outputs = self.session.run(None, onnx_inputs)
  File "/home/skywalk/.local/lib/python3.10/site-packages/onnxruntime/capi/onnxruntime_inference_collection.py", line 287, in run
    return self._sess.run(output_names, input_feed, run_options)
onnxruntime.capi.onnxruntime_pybind11_state.InvalidArgument: [ONNXRuntimeError] : 2 : INVALID_ARGUMENT : Non-zero status code returned while running Expand node. Name:'/bert/Expand' Status Message: invalid expand shape
>>> audio = m.generate("常用汉字数据库中获取信息", voice='expr-voice-2-f' )
>>> sf.write('output1.wav', audio, 24000)

如果是汉字信息,它会一直用英文说:chinese letter chinese letter 。所以它是不会说中文的。

总结

使用效果很不错,唯一遗憾就是目前不支持中文!

所以现在国内应该用不着。

调试

import kittentts报错

复制代码
  File "E:\py312\Lib\site-packages\pydantic\v1\typing.py", line 529, in update_field_forward_refs
    update_field_forward_refs(sub_f, globalns=globalns, localns=localns)
  File "E:\py312\Lib\site-packages\pydantic\v1\typing.py", line 520, in update_field_forward_refs
    field.type_ = evaluate_forwardref(field.type_, globalns, localns or None)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "E:\py312\Lib\site-packages\pydantic\v1\typing.py", line 66, in evaluate_forwardref
    return cast(Any, type_)._evaluate(globalns, localns, set())
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: ForwardRef._evaluate() missing 1 required keyword-only argument: 'recursive_guard'

根据报错信息和相关库的特性,问题核心在于 pydantic 库在处理类型引用时缺少关键参数 recursive_guard。以下是具体分析和解决方案:

核心问题分析

  1. 库依赖冲突‌:

    • KittenTTS 依赖 spacy,而 spacy 依赖 pydantic
    • pydantic 版本 2.7.1 在 Python 3.13.4 中触发了 ForwardRef._evaluate() 参数缺失错误()。
  2. 关键库版本‌:

    • pydantic 2.7.1:存在 recursive_guard 参数缺失的 bug。
    • spacy 3.5.0+:依赖 pydantic 2.x,但未修复该 bug。

解决方案

1. 降级 pydantic 版本
复制代码
pip install pydantic==1.10.12
升级 spacy 到最新版
复制代码
pip install spacy --upgrade

做了这两步,还是没解决。

换一台ubuntu22.04 解决了。

报错huggingface_hub.errors.LocalEntryNotFoundError: An error happened while trying to locate the file on the Hub and we cannot find the requested files in the local cache

复制代码
  File "/home/skywalk/.local/lib/python3.10/site-packages/httpx/_transports/default.py", line 118, in map_httpcore_exceptions
    raise mapped_exc(message) from exc
httpx.ConnectError: [Errno 93] Protocol not supported

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/skywalk/.local/lib/python3.10/site-packages/kittentts/get_model.py", line 24, in __init__
    self.model = download_from_huggingface(repo_id=repo_id, cache_dir=cache_dir)
  File "/home/skywalk/.local/lib/python3.10/site-packages/kittentts/get_model.py", line 68, in download_from_huggingface
    config_path = hf_hub_download(
  File "/home/skywalk/.local/lib/python3.10/site-packages/huggingface_hub/utils/_validators.py", line 89, in _inner_fn
    return fn(*args, **kwargs)
  File "/home/skywalk/.local/lib/python3.10/site-packages/huggingface_hub/file_download.py", line 1007, in hf_hub_download
    return _hf_hub_download_to_cache_dir(
  File "/home/skywalk/.local/lib/python3.10/site-packages/huggingface_hub/file_download.py", line 1135, in _hf_hub_download_to_cache_dir
    _raise_on_head_call_error(head_call_error, force_download, local_files_only)
  File "/home/skywalk/.local/lib/python3.10/site-packages/huggingface_hub/file_download.py", line 1734, in _raise_on_head_call_error
    raise LocalEntryNotFoundError(
huggingface_hub.errors.LocalEntryNotFoundError: An error happened while trying to locate the file on the Hub and we cannot find the requested files in the local cache. Please check your connection and try again or make sure your Internet connection is on.

设定hf镜像加速

复制代码
export HF_ENDPOINT=https://hf-mirror.com

ok了

相关推荐
猫头虎2 小时前
如何在浏览器里体验 Windows在线模拟器:2026最新在线windows模拟器资源合集与技术揭秘
运维·网络·windows·系统架构·开源·运维开发·开源软件
修己xj4 小时前
从“死了么”到“活着记”:用Gmeek在数字世界留下思想印记
开源
鼎道开发者联盟6 小时前
2025中国AI开源生态报告发布,鼎道智联助力产业高质量发展
人工智能·开源·gui
大厂技术总监下海6 小时前
Rust的“一发逆转弹”:Dioxus 如何用一套代码横扫 Web、桌面、移动与后端?
前端·rust·开源
DisonTangor10 小时前
阿里Qwen开源Qwen3-VL-Embedding 和 Qwen3-VL-Reranker
人工智能·搜索引擎·开源·aigc·embedding
搬砖的kk11 小时前
Cordova 适配鸿蒙系统(OpenHarmony) 全解析:技术方案、环境搭建与实战开发
华为·开源·harmonyos
猫头虎11 小时前
2026最新|GitHub 启用双因素身份验证 2FA 教程:TOTP.app 一键生成动态验证码(新手小白图文实操)
git·开源·gitlab·github·开源软件·开源协议·gitcode
REDcker11 小时前
Mach3、Mach4与开源数控软件对比分析
开源·加工·数控·机床·mach3·mach4·数控加工
java_logo11 小时前
Dify 开源 LLM 应用开发平台企业级 Docker Compose 部署手册
docker·容器·开源·dify部署·dify部署文档·dify部署方案·dify部署教程
_小苔藓_11 小时前
混合Token与LoRA结合Qwen3-VL高效微调(代码开源)
深度学习·开源·大模型·微调·多模态