podcast_tts
1.0.0
podcast_tts 、テキストツーチック(TTS)を使用してポッドキャストと対話を生成するためのPythonライブラリです。複数のスピーカー、バックグラウンドミュージック、および専門的な品質の結果を得るための正確なオーディオミキシングをサポートしています。
以下のサンプルポッドキャストを聞くことができます。
voices Subfolderのプロファイルを保存します。 # 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 Subfolderに保存します。これにより、対話で異なるターンにわたる一貫した音声役割が保証されます。例えば:
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 Subfolderに保存されるため、パスを明示的に指定する必要はありません。
# 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ライセンスの下でライセンスされています。詳細については、ライセンスファイルを参照してください。