VideoDubber / texttospeech.py
Suparnpreet's picture
Update texttospeech.py
e0277c8 verified
raw
history blame contribute delete
518 Bytes
import torch
from TTS.api import TTS
from TTS.utils.manage import ModelManager
# Override the ask_tos method
def always_accept_tos(self, output_path):
return True
# Apply the override
ModelManager.ask_tos = always_accept_tos
# Proceed with the rest of your code
print(TTS().list_models())
# Init TTS
tts = TTS("tts_models/multilingual/multi-dataset/xtts_v2").to('cpu')
print(tts.languages)
def speak(text, lang):
tts.tts_to_file(text=text, speaker_wav="speech.wav", language=lang, file_path="output.wav")