"""
Here comes the different AI engines that we
allow to be used in this library. They come
from the ones available in our other own
libraries so we can enable or disable some
engines as we wish/need.
"""
from yta_general_utils.programming.enum import YTAEnum as Enum
from yta_general_utils.programming.output import Output
from yta_general_utils.file.enums import FileTypeX
from yta_general_utils.programming.parameter_validator import PythonValidator
from yta_image.generation.ai.generator import ProdiaAIImageGenerator, PollinationsAIImageGenerator
from yta_audio.voice.generation import GoogleVoiceNarrator, MicrosoftVoiceNarrator
from typing import Union


class ImageEngine(Enum):
    """
    The engine that is enabled to generate AI
    images. These are the only engines officially
    available for AI image generation.
    """

    PRODIA = ProdiaAIImageGenerator
    #FLUX = 'flux'
    POLLINATIONS = PollinationsAIImageGenerator

    def generate_image(
        self,
        prompt: str,
        output_filename: Union[str, None] = None,
        kwargs: dict = {}
    ):
        """
        Generate an AI image with this engine.
        """
        if not PythonValidator.is_string(prompt):
            raise Exception('The provided "prompt" is not a valid string.')
        
        return self.value().generate_image(
            prompt,
            output_filename = Output.get_filename(output_filename, FileTypeX.IMAGE),
            **kwargs
        )

    @classmethod
    def get_default(cls):
        return cls.PRODIA

class VoiceEngine(Enum):
    """
    The engine that is enabled to generate audio
    voice narrations. These are the only engines
    officially available for voice narration.
    """

    GOOGLE = GoogleVoiceNarrator
    MICROSOFT = MicrosoftVoiceNarrator
    
    def narrate(
        self,
        text: str,
        output_filename: Union[str, None] = None,
        kwargs: dict = {}
    ):
        """
        Narrate the given 'text' with this voice
        narration engine.
        """
        if not PythonValidator.is_string(text):
            raise Exception('The provided "text" is not a valid string.')
        
        return self.value.narrate(
            text = text,
            output_filename = Output.get_filename(output_filename, FileTypeX.AUDIO),
            **kwargs
        )

    @classmethod
    def get_default(cls):
        return cls.GOOGLE