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.29
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| funtalk-1.0.29-py3-none-any.whl | Python 3 | none | any | Details |
Release files / funtalk-1.0.29-py3-none-any.whl
| Download URL | funtalk-1.0.29-py3-none-any.whl |
|---|---|
| Size | 12.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0f15eb8772d73febed843cc80cef3ecdd30d5530ca3a21933faf1d4f0fe6fce0
|
|
BLAKE2b-256 checksum How to use checksums |
58eff8d0e540bff1016e92a508798eef1dc197d9c04df05ac6dfcea7a7e3b653
|
| 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}
|