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 ของแพ็คเกจและสามารถใช้งานได้โดยไม่ต้องตั้งค่าเพิ่มเติม
เมื่อระบุโปรไฟล์ลำโพง แต่ไม่มีอยู่ไลบรารีจะสร้างโปรไฟล์ลำโพงใหม่โดยอัตโนมัติและบันทึกไว้ในโฟลเดอร์ย่อยของเสียง สิ่งนี้ทำให้มั่นใจได้ว่าบทบาทเสียงที่สอดคล้องกันในการเปิดที่แตกต่างกันในบทสนทนา ตัวอย่างเช่น:
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.โปรไฟล์จะถูกบันทึกไว้ในไดเรกทอรีเสียงของสคริปต์และนำกลับมาใช้ใหม่โดยอัตโนมัติหากมีการใช้ลำโพงเดียวกันในอนาคตเพื่อความสอดคล้อง
คุณสามารถโหลดโปรไฟล์ลำโพงใด ๆ ได้โดยระบุชื่อไฟล์ (โดยไม่ต้องขยาย. txt) โปรไฟล์จะถูกเก็บไว้ในโฟลเดอร์ย่อยเสียงดังนั้นคุณไม่จำเป็นต้องระบุเส้นทางอย่างชัดเจน
# 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 ดูไฟล์ใบอนุญาตสำหรับรายละเอียด