Overview
The TTS class provides text-to-speech functionality using the KittenTTS model. It converts text into natural-sounding speech audio files.
Constructor
Initializes the TTS class with the KittenTTS model.
Returns: None
Example:
from classes.Tts import TTS
tts = TTS()
Model Configuration
The TTS class uses the following default configuration:
- Model:
KittenML/kitten-tts-mini-0.8
- Sample Rate: 24000 Hz
- Voice: Configured via
get_tts_voice() from config
Methods
synthesize
def synthesize(
text: str,
output_file: str = os.path.join(ROOT_DIR, ".mp", "audio.wav")
) -> str
Synthesizes speech from text and saves it to a WAV file.
The text to convert to speech
Path where the audio file will be saved (default: .mp/audio.wav in project root)
Returns: str - Path to the generated audio file
Example:
from classes.Tts import TTS
tts = TTS()
# Generate speech with default output path
audio_path = tts.synthesize("Hello, this is a test of the text to speech system.")
print(f"Audio saved to: {audio_path}")
# Generate speech with custom output path
custom_path = tts.synthesize(
"Welcome to MoneyPrinter V2!",
output_file="/path/to/custom/output.wav"
)
Usage with YouTube Class
The TTS class is commonly used with the YouTube class for video generation:
from classes.YouTube import YouTube
from classes.Tts import TTS
# Initialize TTS
tts = TTS()
# Initialize YouTube automation
youtube = YouTube(
account_uuid="uuid-123",
account_nickname="My Channel",
fp_profile_path="/path/to/profile",
niche="Technology",
language="English"
)
# Generate video with TTS
video_path = youtube.generate_video(tts)
Technical Details
- Format: WAV (Waveform Audio File Format)
- Sample Rate: 24,000 Hz
- Channels: Mono
Voice Configuration
The voice used for synthesis is configured in your config.json file:
{
"tts_voice": "your_preferred_voice"
}
Refer to the KittenTTS documentation for available voice options.