tts joinery
v1.0.4
TTS-Joinery是一个Python库和CLI工具,可在文本到语音API中围绕长度限制。
由于当前受欢迎的API仅限于4096个字符,因此该库将:
目前,仅支持OpenAI API,未来有意添加更多。
pip install tts-joinery或使用pipx作为独立工具安装。
需要FFMPEG进行音频文件处理。
安装可能会因系统而异。在Linux上,您可以使用您的系统软件包管理器。在Mac brew install ffmpeg应该有效。
CLI希望在OPENAI_API_KEY环境变量或.env文件中找到OpenAI API密钥。
ttsjoin [OPTIONS] [COMMAND]
Options:
--input-file FILENAME Plaintext file to process into speech, otherwise stdin
--output-file FILENAME MP3 result, otherwise stdout
--model TEXT Slug of the text-to-speech model to be used
--service TEXT API service (currently only supports openai)
--voice TEXT Slug of the voice to be used
--no-cache BOOLEAN Disable caching
--help Show this message and exit.
Commands:
cache [clear, show]
ttsjoin --input-file input.txt --output-file output.mp3 --model tts-1 --service openai --voice onyx echo " Your text to be processed " | ttsjoin > output.mp3ttsjoin --input-file input.txt --output-file output.mp3 --no-cachettsjoin cache clear您也可以将TTS-Joinery用作Python项目的一部分:
import nltk
from joinery . op import JoinOp
from joinery . api . openai import OpenAIApi
# Only need to download once, handled for you automatically in the CLI
nltk . download ( 'punkt_tab' , quiet = True )
tts = JoinOp (
text = 'This is only a test!' ,
api = OpenAIApi (
model = 'tts-1-hd' ,
voice = 'onyx' ,
api_key = OPENAI_API_KEY ,
),
)
tts . process_to_file ( 'output.mp3' )欢迎贡献,尤其是其他TTS API,事先检查了问题,并可以随时开设PR。代码格式使用黑色。
测试可以手动进行。套件包括带有实时API调用的端到端测试,确保您在.env.test中设置了OpenAI_API_KEY,并运行pytest 。您可以使用pip install -e .[test]
特别感谢:
该项目已根据MIT许可获得许可。
版权所有2024,Adrien DeLessert