TTS-Joinery es una biblioteca de Python y una herramienta CLI para trabajar alrededor de las limitaciones de longitud en las API de texto a voz.
Dado que actualmente las API populares están limitadas a 4096 caracteres, esta biblioteca:
Actualmente, solo se admite la API de Operai, con la intención de agregar más en el futuro.
pip install tts-joinery O use pipx para instalar como una herramienta independiente.
Requiere FFMPEG para el procesamiento de archivos de audio.
La instalación puede variar según su sistema. En Linux puede usar el Administrador de paquetes de su sistema. En Mac brew install ffmpeg debería funcionar.
La CLI espera encontrar una tecla API de OpenAI en una variable de entorno OPENAI_API_KEY , o en un archivo .env.
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 clearTambién puede usar TTS-Joinery como parte de su proyecto 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' )Las contribuciones son bienvenidas, particularmente otras API de TTS, verifique los problemas de antemano y no dude en abrir un PR. El código está formateado con negro.
La prueba se puede ejecutar manualmente. Suite incluye pruebas de extremo a extremo con llamadas de API en vivo, asegúrese de tener un set OpenAI_API_Key en .env.test y ejecute pytest . Puede instalar dependencias de desarrollo con pip install -e .[test]
Un agradecimiento especial a:
Este proyecto tiene licencia bajo la licencia MIT.
Copyright 2024, Adrien DeLessert