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了

相关推荐
DisonTangor16 小时前
DeepSeek-OCR 2: 视觉因果流
人工智能·开源·aigc·ocr·deepseek
数智联AI团队17 小时前
AI搜索引领开源大模型新浪潮,技术创新重塑信息检索未来格局
人工智能·开源
朝风工作室20 小时前
开源一款轻量级跨网段 IPC 设备发现与网络配置工具
网络·开源
LitchiCheng1 天前
Mujoco 开源机械臂 RL 强化学习避障、绕障
人工智能·python·开源
我送炭你添花1 天前
开源TR-069 ACS(自动配置服务器)GenieACS 的四个主要模块详细介绍
运维·服务器·开源
冬奇Lab1 天前
一天一个开源项目(第9篇):NexaSDK - 跨平台设备端 AI 运行时,让前沿模型在本地运行
人工智能·开源
FIT2CLOUD飞致云1 天前
飞致云开源社区月度动态报告(2026年1月)
开源·飞致云·月度报告·开源日报
江湖有缘1 天前
基于华为openEuler部署EspoCRM开源客户关系管理平台
开源
zhangfeng11331 天前
大模型微调主要框架 Firefly vs LLaMA Factory 全方位对比表
人工智能·语言模型·开源·llama
向哆哆1 天前
Flutter × OpenHarmony 跨端实战:打造健身俱乐部「数据可视化仪表盘」模块
flutter·信息可视化·开源·鸿蒙·openharmony·开源鸿蒙