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