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了

相关推荐
笔画人生4 小时前
深度解析 CANN 项目:以 `ops-transformer` 为例探索高性能 AI 算子库
学习·开源
鸽芷咕4 小时前
让 AI 写算子:基于 pyasc 语言的 AIGC 算子开发初探
开源·cann
深鱼~4 小时前
数学计算加速利器:ops-math在昇腾平台的应用详解
ai·开源·cann
一只大侠的侠6 小时前
Flutter开源鸿蒙跨平台训练营 Day 3
flutter·开源·harmonyos
芷栀夏6 小时前
CANN开源实战:基于DrissionPage构建企业级网页自动化与数据采集系统
运维·人工智能·开源·自动化·cann
一只大侠的侠7 小时前
【Harmonyos】Flutter开源鸿蒙跨平台训练营 Day 2 鸿蒙跨平台开发环境搭建与工程实践
flutter·开源·harmonyos
酷酷的崽7988 小时前
CANN 开源生态特别篇:通过 ONNX 实现跨框架高性能推理
开源
晚霞的不甘10 小时前
CANN × ROS 2:为智能机器人打造实时 AI 推理底座
人工智能·神经网络·架构·机器人·开源
芷栀夏10 小时前
从 CANN 开源项目看现代爬虫架构的演进:轻量、智能与统一
人工智能·爬虫·架构·开源·cann
芷栀夏11 小时前
深度解析 CANN 异构计算架构:基于 ACL API 的算子调用实战
运维·人工智能·开源·cann