Package: topcast
Topcast: Turn Text into Podcasts with TTS and ChatGPTTopcast is a Python package that allows you to transform text into a podcast using Text-to-Speech (TTS) and language models. With Topcast, you can provide a text, and the package will create a podcast with an introduction, interview, conclusion, sound effects, and more. Topcast supports various TTS providers and language models.ExampleGenerated using ChatGPT themes: Introduction with the ElevenLabs TTS Provider, Interview with the GCP TTS Provider and Summary also with the ElevenLabs TTS Provider.https://user-images.githubusercontent.com/53308156/234994155-2921b28a-9caa-46fc-9608-5ef01881713e.mp4Example ImplementationfromtopcastimportTopcaster,set_openai_api_keyfromtopcast.chatgpt_themesimportIntroductionset_openai_api_key("XXX-XXX-XXX-XXX-XXX")topcast=Topcaster()topcast.add_chapter(audio_layers=[{"audio":"sounds/jingle.wav"}])topcast.add_chapter(audio_layers=[{"audio":{"content":"Topcast is a Python package that allows you to transform text into a podcast using Text-to-Speech (TTS) and language models. With Topcast, you can provide a text, and the package will create a podcast with an introduction, interview, conclusion, sound effects, and more. Topcast supports various TTS providers and language models.","theme":Introduction,},},],crossfade=2400,)topcast.generate()topcast.export("podcast.wav",format="wav")InstallationInstall the package using pip:pipinstalltopcastUsageImport the necessary modules and set the API keys:fromtopcastimport(set_elevenlab_api_key,set_google_credentials,set_openai_api_key,Topcaster,)fromtopcast.tts_providersimportGCPfromtopcast.chatgpt_themesimportSummaryset_elevenlab_api_key("XXX-XXX-XXX")# if you want to use elvenlabs for ttsset_google_credentials("gcp-keyfile.json")# if you want google cloud platform for ttsset_openai_api_key("XXX-XXX-XXX")# if you want to use a ChatGPT themeCreate a Topcaster object and add chapters with the desired podcast structure:topcast=Topcaster()topcast.add_chapter(audio_layers=[{"audio":"sounds/jingle.wav",# use a audio file"sets_length":True,}])topcast.add_chapter(audio_layers=[{"audio":{"content":"Portugal...","tts_provider":GCP,# use google cloud platform for tts"theme":Summary,# generate a summary of the text using ChatGPT},"sets_length":True,# this audio_layer sets the length of the chapter, only one audio_layer can set the length per chapter"fade_in":1200,# fade in 1200 ms"fade_out":1200,# fade out 1200 ms},{"audio":"sounds/background.mp3","sets_length":False,"volume":0.5},# overlay audio],crossfade=2400,# crossfade last chapter)Generate and export the podcast:topcast.generate()topcast.export("podcast.wav",format="wav")This will create a podcast using the given chapters and save it as a WAV file named podcast_output.wav.ChatGPT ThemesChatGPT Themes allow you to transform your text into various structures by leveraging ChatGPT, a large language model. With the available themes, you can transform your text into an interview, introduction, summary, or conclusion. You can also choose to leave the text as it is by using the NoneTheme, which is the default theme.The available ChatGPT Themes are:InterviewIntroductionSummaryConclusionNoneTheme (default)UsageTo use a specific ChatGPT theme, first import the desired theme:fromtopcast.chatgpt_themesimportInterview,Introduction,Summary,ConclusionThen, set your OpenAI API key using the set_openai_api_key function:fromtopcastimportset_openai_api_keyset_openai_api_key("your-openai-api-key")Finally, set thethemeproperty in the audio layer of the desired chapter:{"audio":{"content":"Text content...","theme":Introduction,# Replace with the desired theme},}To keep the original text without any transformation, set NoneTheme or don't setthemeat allfromtopcast.chatgpt_themesimportNoneTheme{"audio":{"content":"Text content...","theme":NoneTheme,# Keeps the text as it is},}TTS ProvidersTopcast allows you to use various Text-to-Speech (TTS) providers to convert your text into speech. The currently implemented TTS providers are:GCP (Google Cloud Platform) - Requires a Google Cloud Platform accountElevenlabs - Requires an Elevenlabs accountGTTS (Google Translate) - No account required (default)ComparisonElevenlabs: Offers the best voices but is expensive and has API limits.GCP (Google Cloud Platform): Relatively cheap but requires a Google Cloud Platform account with the Text-to-Speech API enabled.GTTS (Google Translate): Free and does not require an account, but the voice quality is not as good as the other options.UsageFirst, import the desired TTS provider:fromtopcast.tts_providersimportGCP,Elevenlabs,GTTSNext, set the API key or credentials for the provider, if required:fromtopcastimportset_elevenlab_api_key,set_google_credentialsset_elevenlab_api_key("your-elevenlabs-api-key")set_google_credentials("path-to-gcp-keyfile.json")Finally, specify the tts_provider property in the audio layer of the desired chapter:{"audio":{"content":"Text content...","tts_provider":GCP,# Replace with the desired TTS provider},}For example, to create a chapter using the GCP TTS provider:topcast.add_chapter(audio_layers=[{"audio":{"content":"Text content...","tts_provider":GCP,"theme":Summary,},"sets_length":True,"fade_in":1200,"fade_out":1200,},],crossfade=2400,)To use the default GTTS provider, you can simply omit the tts_provider property:{"audio":{"content":"Text content...",},}