|
|
@ -4,9 +4,9 @@ from typing import Tuple
|
|
|
|
import re
|
|
|
|
import re
|
|
|
|
from os import getenv
|
|
|
|
from os import getenv
|
|
|
|
|
|
|
|
|
|
|
|
import sox
|
|
|
|
# import sox
|
|
|
|
from mutagen import MutagenError
|
|
|
|
# from mutagen import MutagenError
|
|
|
|
from mutagen.mp3 import MP3, HeaderNotFoundError
|
|
|
|
# from mutagen.mp3 import MP3, HeaderNotFoundError
|
|
|
|
import translators as ts
|
|
|
|
import translators as ts
|
|
|
|
from rich.progress import track
|
|
|
|
from rich.progress import track
|
|
|
|
from moviepy.editor import AudioFileClip, CompositeAudioClip, concatenate_audioclips
|
|
|
|
from moviepy.editor import AudioFileClip, CompositeAudioClip, concatenate_audioclips
|
|
|
@ -94,12 +94,10 @@ class TTSEngine:
|
|
|
|
|
|
|
|
|
|
|
|
def call_tts(self, filename: str, text: str):
|
|
|
|
def call_tts(self, filename: str, text: str):
|
|
|
|
self.tts_module.run(text=process_text(text), filepath=f"{self.path}/{filename}.mp3")
|
|
|
|
self.tts_module.run(text=process_text(text), filepath=f"{self.path}/{filename}.mp3")
|
|
|
|
try:
|
|
|
|
# try:
|
|
|
|
try:
|
|
|
|
# self.length += MP3(f"{self.path}/{filename}.mp3").info.length
|
|
|
|
self.length += MP3(f"{self.path}/{filename}.mp3").info.length
|
|
|
|
# except (MutagenError, HeaderNotFoundError):
|
|
|
|
except (MutagenError, HeaderNotFoundError):
|
|
|
|
# self.length += sox.file_info.duration(f"{self.path}/{filename}.mp3")
|
|
|
|
self.length += sox.file_info.duration(f"{self.path}/{filename}.mp3")
|
|
|
|
|
|
|
|
except Exception: # last resort backup
|
|
|
|
|
|
|
|
clip = AudioFileClip(f"{self.path}/{filename}.mp3")
|
|
|
|
clip = AudioFileClip(f"{self.path}/{filename}.mp3")
|
|
|
|
self.length += clip.duration
|
|
|
|
self.length += clip.duration
|
|
|
|
|
|
|
|
|
|
|
|