podcast_tts
1.0.0
podcast_tts是一個Python庫,用於使用文本到語音(TTS)生成播客和對話。它支持多個揚聲器,背景音樂和精確的音頻混合,以獲得專業質量的結果。
您可以收聽下面的示例播客:
voices文件夾中的配置文件以備將來使用。 # ensure to have sox, or ffmpeg installed
brew install sox
# install the package
pip install podcast_tts import asyncio
from podcast_tts import PodcastTTS
async def main ():
tts = PodcastTTS ( speed = 5 )
await tts . generate_tts (
text = "Hello! Welcome to our podcast." ,
speaker = "male1" ,
filename = "output_audio.wav" ,
channel = "both"
)
if __name__ == "__main__" :
asyncio . run ( main ())Generate_podcast方法結合了對話和背景音樂,以進行無縫的播客製作。
import asyncio
from podcast_tts import PodcastTTS
async def main ():
tts = PodcastTTS ( speed = 5 )
# Define speakers and text
texts = [
{ "male1" : [ "Welcome to the podcast!" , "both" ]},
{ "female2" : [ "Today, we discuss AI advancements." , "left" ]},
{ "male2" : [ "Don't miss our exciting updates." , "right" ]},
]
# Define background music (local file or URL)
music_config = [ "https://example.com/background_music.mp3" , 10 , 3 , 0.3 ]
# Generate the podcast
output_file = await tts . generate_podcast (
texts = texts ,
music = music_config ,
filename = "podcast_with_music.mp3" ,
pause_duration = 0.5 ,
normalize = True
)
print ( f"Podcast saved to: { output_file } " )
if __name__ == "__main__" :
asyncio . run ( main ())Podcasttts包括以下預製演講者資料:
這些配置文件包含在軟件包的Default_voices目錄中,並且可以在沒有其他設置的情況下使用。
當指定說話者配置文件但不存在時,庫將自動生成新的揚聲器配置文件並將其保存在Voices子文件夾中。這確保了對話中不同轉彎的一致語音角色。例如:
texts = [
{ "Narrator" : [ "Welcome to this exciting episode." , "left" ]},
{ "Expert" : [ "Today, we'll explore AI's impact on healthcare." , "right" ]},
]
# If "Narrator" or "Expert" profiles do not exist, they will be generated dynamically.配置文件保存在腳本的Voices目錄中,並自動重複使用,如果將來使用相同的說話者以保持一致性。
您可以通過指定其文件名來加載任何揚聲器配置文件(沒有.txt擴展名)。配置文件存儲在Voices子文件夾中,因此您無需明確指定路徑。
# Assuming a speaker profile "Host.txt" exists in the voices subfolder
await tts . generate_tts ( "This is a test for an existing speaker." , "Host" , "existing_speaker.wav" )歡迎捐款!隨時提交問題或在GitHub存儲庫上提取請求。
該項目已根據MIT許可獲得許可。有關詳細信息,請參見許可證文件。