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许可获得许可。有关详细信息,请参见许可证文件。