elevenlabslib
1.0.0
完整的Elevenlabs API的Python包装纸。
主要原因是播放的不同方法。通过纯粹在python中进行播放,而不是将管道播放到外部过程中,可以做一些重要的额外工作,例如:
只需运行pip install elevenlabslib ,就在PYPI上。
注意:在Linux上,您可能需要安装Portaudio。在Debian和衍生产品上,它是sudo apt-get install libportaudio2 ,也可能是sudo apt-get install python3-pyaudio 。
重要的是:图书馆需要libsndfile v1.1.0或更新的库,就像引入MP3支持时一样。这在Windows上不会是一个问题,但可能在其他平台上有意义。检查源头存储库以获取更多信息。
对于一个更全面的示例,请检查示例或文档。
这是一个非常简单的用法样本。
from elevenlabslib import *
user = User ( "API_KEY" )
voice = user . get_voices_by_name_v2 ( "Rachel" )[ 0 ] # This is a list because multiple voices can have the same name
voice . generate_play_audio_v2 ( "Test." , playbackOptions = PlaybackOptions ( runInBackground = False ))
for historyItem in user . get_history_items_paginated ():
if historyItem . text == "Test." :
# The first items are the newest, so we can stop as soon as we find one.
historyItem . delete ()
break