Skip to main content

funtalk

语音相关的小工具库,封装了 TTS(文字转语音)和 ASR(语音转文字)两部分,主要配合 funvideo 项目使用,用来给自动生成的视频配音、生成对齐的字幕文件。

安装

pip install funtalk

注意:仓库的 pyproject.toml 目前没有声明任何运行依赖(dependencies = []),实际使用时需要自行安装 edge-tts、openai-whisper、funutil、moviepy,如果要用 Azure TTS 还需要 azure-cognitiveservices-speech。TTS 模块还直接 import 了 funvideo.app.utils / funvideo.app.config(属于对 funvideo 内部模块的紧耦合),脱离 funvideo 项目单独使用会因为缺依赖而报错。

TTS:文字转语音

from funtalk.tts import tts_generate  # 包一级导出的默认是 edge-tts 实现

tts_generate(
    text="你好,世界",
    voice_name="zh-CN-XiaoxiaoNeural",
    voice_rate=1.0,
    voice_file="out.mp3",
    subtitle_file="out.srt",
)

BaseTTS(funtalk/tts/base.py)定义了统一接口:create_tts() 生成音频,并能根据引擎返回的时间戳,把文本按标点切分对齐后生成 SRT 字幕(create_subtitle)。目前有两个实现:

  • funtalk.tts._edge.EdgeTTS:基于 edge-tts,包一级导出的 tts_generate / edge_tts_generate 就是它。
  • funtalk.tts._azure.AzureTTS:基于 Azure 认知服务语音合成,需要从 funtalk.tts._azure 单独导入,依赖 azure-cognitiveservices-speech 以及 funvideo 配置里的 speech_key/speech_region。

ASR:语音转文字

from funtalk.asr import WhisperASR

asr = WhisperASR(name="turbo")  # 基于 openai-whisper
result = asr.transcribe("audio.mp3", language="ZH")

BaseASR(funtalk/asr/base.py)定义了 load() / transcribe() 接口,目前只有 WhisperASR 一个实现。

Metadata

Release files for funtalk 1.0.31

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for funtalk 1.0.31
File Interpreter ABI Platform
funtalk-1.0.31-py3-none-any.whl Python 3 none any Details

Release files / funtalk-1.0.31-py3-none-any.whl

Download URL funtalk-1.0.31-py3-none-any.whl
Size 13.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3e647b7191c1b327c0b3ea0b822c342f9b4fbb9347732ad0b219fc1499f241d7
BLAKE2b-256 checksum
How to use checksums
f06ec06ab3031df07e082732076104a0805e71c70a72404653e5dd5045898a95
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.17 {"installer":{"name":"uv","version":"0.11.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release history Release notifications | RSS feed

This release

1.0.31 This release

1 release file

1.0.30

1 release file

1.0.29

1 release file

1.0.26

2 release files

1.0.25

2 release files

1.0.24

2 release files

1.0.23

2 release files

1.0.22

2 release files

1.0.21

2 release files

1.0.20

2 release files

1.0.19

2 release files

1.0.17

2 release files

1.0.9

2 release files

1.0.8

2 release files

1.0.7

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page