import torch from TTS.api import TTS class CoquiTTS: def __init__(self, speaker_wave_file): self.device = "cuda" if torch.cuda.is_available() else "cpu" self.tts = TTS("tts_models/multilingual/multi-dataset/xtts_v2").to(self.device) self.speaker_wave_file = speaker_wave_file def speech_text_and_save_it(self, text, output_path, language = "en"): return self.tts.tts_to_file(text = text, speaker_wav = self.speaker_wave_file, language = language, file_path = output_path)