text_to_speech
Adapted from the Griptape AI Framework documentation.
__all__ = ['BaseTextToSpeechDriver']
module-attribute
Bases:
SerializableMixin
, ExponentialBackoffMixin
, ABC
Source Code in griptape/drivers/text_to_speech/base_text_to_speech_driver.py
@define class BaseTextToSpeechDriver(SerializableMixin, ExponentialBackoffMixin, ABC): model: str = field(kw_only=True, metadata={"serializable": True}) def before_run(self, prompts: list[str]) -> None: EventBus.publish_event(StartTextToSpeechEvent(prompts=prompts)) def after_run(self) -> None: EventBus.publish_event(FinishTextToSpeechEvent()) def run_text_to_audio(self, prompts: list[str]) -> AudioArtifact: for attempt in self.retrying(): with attempt: self.before_run(prompts) result = self.try_text_to_audio(prompts) self.after_run() return result raise Exception("Failed to run text to audio generation") @abstractmethod def try_text_to_audio(self, prompts: list[str]) -> AudioArtifact: ...
model = field(kw_only=True, metadata={'serializable': True})
class-attribute instance-attribute
after_run()
Source Code in griptape/drivers/text_to_speech/base_text_to_speech_driver.py
def after_run(self) -> None: EventBus.publish_event(FinishTextToSpeechEvent())
before_run(prompts)
Source Code in griptape/drivers/text_to_speech/base_text_to_speech_driver.py
def before_run(self, prompts: list[str]) -> None: EventBus.publish_event(StartTextToSpeechEvent(prompts=prompts))
run_text_to_audio(prompts)
Source Code in griptape/drivers/text_to_speech/base_text_to_speech_driver.py
def run_text_to_audio(self, prompts: list[str]) -> AudioArtifact: for attempt in self.retrying(): with attempt: self.before_run(prompts) result = self.try_text_to_audio(prompts) self.after_run() return result raise Exception("Failed to run text to audio generation")
try_text_to_audio(prompts)abstractmethod
Source Code in griptape/drivers/text_to_speech/base_text_to_speech_driver.py
@abstractmethod def try_text_to_audio(self, prompts: list[str]) -> AudioArtifact: ...
Could this page be better? Report a problem or suggest an addition!