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