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了

相关推荐
problc2 小时前
肉包 Roubao:首款无需电脑的开源 AI 手机自动化助手
人工智能·智能手机·开源
说私域3 小时前
“智能名片链动2+1模式S2B2C商城小程序”在群运营中的应用与效果
人工智能·小程序·开源
OctShop大型商城源码18 小时前
OctIM多用户在线客服系统源码_开源、高效、可定制
开源·im在线客服·在线客服源码
梦帮科技1 天前
第二十二篇:AI驱动的工作流优化:性能瓶颈自动检测
数据结构·数据库·人工智能·python·开源·极限编程
程序员在囧途1 天前
Sora2 25 秒视频 API 国内直连!10 积分/次,稳定秒退任务,支持 avatar & Remix(附 PHP 接入教程)
后端·开源·php
今天也要学习吖1 天前
【开源客服系统推荐】AI-CS:一个开源的智能客服系统
人工智能·开源·客服系统·ai大模型·ai客服·开源客服系统
极限实验室1 天前
Easy-Es 2.1.0-easysearch 版本发布
开源
NocoBase1 天前
GitHub 上星星数量前 10 的 AI CRM 开源项目
人工智能·低代码·开源·github·无代码
GISHUB1 天前
地图矢量切片常用的几种开源方案
开源·mapbox