Skip to content

audio_artifact

AudioArtifact

Bases: BlobArtifact

Stores audio data.

Attributes:

Name Type Description
format str

The audio format, e.g. "wav" or "mp3".

Source code in griptape/artifacts/audio_artifact.py
@define
class AudioArtifact(BlobArtifact):
    """Stores audio data.

    Attributes:
        format: The audio format, e.g. "wav" or "mp3".
    """

    format: str = field(kw_only=True, metadata={"serializable": True})

    @property
    def mime_type(self) -> str:
        return f"audio/{self.format}"

    def to_bytes(self) -> bytes:
        return self.value

    def to_text(self) -> str:
        return f"Audio, format: {self.format}, size: {len(self.value)} bytes"

format: str = field(kw_only=True, metadata={'serializable': True}) class-attribute instance-attribute

mime_type: str property

to_bytes()

Source code in griptape/artifacts/audio_artifact.py
def to_bytes(self) -> bytes:
    return self.value

to_text()

Source code in griptape/artifacts/audio_artifact.py
def to_text(self) -> str:
    return f"Audio, format: {self.format}, size: {len(self.value)} bytes"