podcastfy package

Submodules

podcastfy.text_to_speech module

Text-to-Speech Module

This module provides functionality to convert text into speech using various TTS models. It supports both ElevenLabs and OpenAI TTS services and handles the conversion process, including cleaning of input text and merging of audio files.

class podcastfy.text_to_speech.TextToSpeech(model: str = 'openai', api_key: str | None = None)[source]

Bases: object

clean_tss_markup(input_text: str, additional_tags: List[str] = ['Person1', 'Person2']) str[source]

Remove unsupported TSS markup tags from the input text while preserving supported SSML tags.

Parameters:
  • input_text (str) – The input text containing TSS markup tags.

  • additional_tags (List[str]) – Optional list of additional tags to preserve. Defaults to [“Person1”, “Person2”].

Returns:

Cleaned text with unsupported TSS markup tags removed.

Return type:

str

convert_to_speech(text: str, output_file: str) None[source]

Convert input text to speech and save as an audio file.

Parameters:
  • text (str) – Input text to convert to speech.

  • output_file (str) – Path to save the output audio file.

Raises:

Exception – If there’s an error in converting text to speech.

split_qa(input_text: str) List[Tuple[str, str]][source]

Split the input text into question-answer pairs.

Parameters:

input_text (str) – The input text containing Person1 and Person2 dialogues.

Returns:

A list of tuples containing (Person1, Person2) dialogues.

Return type:

List[Tuple[str, str]]

podcastfy.text_to_speech.main(seed: int = 42) None[source]

Main function to test the TextToSpeech class.

Parameters:

seed (int) – Random seed for reproducibility. Defaults to 42.

podcastfy.content_generator module

Content Generator Module

This module is responsible for generating Q&A content based on input texts using LangChain and Google’s Generative AI (Gemini). It handles the interaction with the AI model and provides methods to generate and save the generated content.

class podcastfy.content_generator.ContentGenerator(api_key: str, conversation_config: Dict[str, Any] | None = None)[source]

Bases: object

generate_qa_content(input_texts: str = '', image_file_paths: List[str] = [], output_filepath: str | None = None) str[source]

Generate Q&A content based on input texts.

Parameters:
  • input_texts (str) – Input texts to generate content from.

  • output_filepath (Optional[str]) – Filepath to save the response content. Defaults to None.

Returns:

Formatted Q&A content.

Return type:

str

Raises:

Exception – If there’s an error in generating content.

podcastfy.content_generator.main(seed: int = 42) None[source]

Generate Q&A content based on input text from input_text.txt using the Gemini API.

Parameters:

seed (int) – Random seed for reproducibility. Defaults to 42.

Returns:

None

podcastfy.content_parser.content_extractor module

Content Extractor Module

This module provides functionality to extract content from various sources including websites, YouTube videos, and PDF files. It serves as a central hub for content extraction, delegating to specialized extractors based on the source type.

class podcastfy.content_parser.content_extractor.ContentExtractor(jina_api_key: str)[source]

Bases: object

extract_content(source: str) str[source]

Extract content from various sources.

Parameters:

source (str) – URL or file path of the content source.

Returns:

Extracted text content.

Return type:

str

Raises:

ValueError – If the source type is unsupported.

is_url(source: str) bool[source]

Check if the given source is a valid URL.

Parameters:

source (str) – The source to check.

Returns:

True if the source is a valid URL, False otherwise.

Return type:

bool

Module contents