SOGA TTS - 固定时长语音合成
生成指定时长的语音文件,支持智能文本优化和精确时长控制。
安装
pip install soga-tts
基本使用
命令行(最简单)
soga_tts "Hello world" --duration 5.0 # 生成5秒语音,默认使用本地ollma的gemma3:4b模型,请事先安装
soga_tts "Hello world" --duration 5.0 --no-llm # 不使用LLM,直接生成语音,通过强制拉伸的方式来控制时长
Python API
from soga_tts import soga_tts
# 最简单的用法
text, audio_path, duration = soga_tts("Hello world", 5.0)
print(f"音频文件: {audio_path}")
高级用法
异常处理
from soga_tts import soga_tts
from soga_tts.fixed_duration_tts import TTSPrecisionError
try:
text, audio_path, duration = soga_tts("Hello", 10.0, tolerance_pct=5.0)
except TTSPrecisionError as e:
print(f"精度不够: {e.error_pct:.1f}% (要求: 5.0%)")
from soga_tts import soga_tts
from soga_tts.fixed_duration_tts import TTSPrecisionError
try:
text, audio_path, duration = soga_tts("Hello", 10.0, tolerance_pct=5.0)
except TTSPrecisionError as e:
print(f"精度不够: {e.error_pct:.1f}% (要求: 5.0%)")
自定义LLM服务
# 使用OpenAI
soga_tts "Hello" --duration 5.0 \
--llm-url "https://api.openai.com/v1" \
--llm-key "your-key" \
--llm-model "gpt-3.5-turbo"
# 使用Ollama(默认)
soga_tts "Hello" --duration 5.0
参数调整
soga_tts(
text="Hello world",
target_duration=10.0,
tolerance_pct=3.0, # 误差容忍度
max_rounds=5, # 最大优化回合
force_exact_duration=True # 音频缩放
)
常见问题
1. Ollama连接失败
# 启动Ollama服务
ollama serve
# 检查服务状态
curl http://localhost:11434/api/tags
2. 精度不够怎么办?
- 使用更宽松的容差:
--tolerance 10.0 - 增加优化回合数:
--max-rounds 20 - 启用音频缩放(默认开启)
3. 速度太慢?
- 使用
--no-llm跳过文本优化 - 减少回合数:
--max-rounds 3 - 使用本地Ollama而不是远程API
Metadata
Release files for soga-tts 0.1.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| soga_tts-0.1.5.tar.gz | 14.5 kB | Without provenance | Details for soga_tts-0.1.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| soga_tts-0.1.5-py3-none-any.whl | Python 3 | none | any | Details for soga_tts-0.1.5-py3-none-any.whl |
Total release size: 23.9 kB
Release files / soga_tts-0.1.5.tar.gz
| Download URL | soga_tts-0.1.5.tar.gz |
|---|---|
| Size | 14.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8abfafc849a7978222336e44fc7f8ed3368ad432d0518d921eab79a5e70ce36e
|
|
BLAKE2b-256 checksum How to use checksums |
0c536b609302eaf2385f5a30a99a8f9689771a0c45e2e3eb344921b0b35dbdfa
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.7.7
|
Release files / soga_tts-0.1.5-py3-none-any.whl
| Download URL | soga_tts-0.1.5-py3-none-any.whl |
|---|---|
| Size | 9.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
97632e7459ed9d559b3e4ef5f5e35a198e0c0b75379b35addbf6157f9866a166
|
|
BLAKE2b-256 checksum How to use checksums |
4a87ee8b57be5d63d5221bc4bae66c4193444f582d649d21df9cc2e2005d458e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.7.7
|
Security for soga-tts 0.1.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.