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了

相关推荐
IvorySQL10 小时前
IvorySQL v5 发布后,我们想听听大家的使用体验
数据库·postgresql·开源
IvorySQL10 小时前
PostgreSQL 技术日报 (3月20日)|PGConf.dev 2026 日程公布
数据库·postgresql·开源
橙序员小站11 小时前
当所有人都在做 Agent,我想聊聊被遗忘的基础设施
后端·开源·aigc
Are_You_Okkk_12 小时前
多场景适配视角下AI开源知识库的部署实践与应用反思
人工智能·开源
白鲸开源16 小时前
SeaTunnel × Gravitino:Schema URL 驱动的表结构自动感知方案
大数据·人工智能·开源
老星*17 小时前
Playwright:微软开源的现代化浏览器自动化测试框架
开源·figma
dehuisun17 小时前
移动端智能体开源项目清单
开源
wdfk_prog18 小时前
MAX14830 可移植 C 驱动实现分析:一个适合多串口扩展场景的开源基础版本
c语言·开发语言·开源
计算机魔术师18 小时前
一键沉浸式体验:清华开源OpenMAIC,重塑多智能体学习新范式
学习·typescript·开源·多智能体·openmaic