pyrit.models.AudioPathDataTypeSerializer#
- class AudioPathDataTypeSerializer(*, category: str, prompt_text: str | None = None, extension: str | None = None)[source]#
Bases:
DataTypeSerializerSerializer for audio path values stored on disk.
- __init__(*, category: str, prompt_text: str | None = None, extension: str | None = None)[source]#
Initialize an audio-path serializer.
Methods
__init__(*, category[, prompt_text, extension])Initialize an audio-path serializer.
Indicate whether this serializer persists data on disk.
get_data_filename([file_name])Generate or retrieve a unique filename for the data file.
get_extension(file_path)Get the file extension from the file path.
get_mime_type(file_path)Get the MIME type of the file path.
get_sha256()Compute SHA256 hash for this serializer's current value.
read_data()Read data from storage.
read_data_base64()Read data from storage and return it as a base64 string.
save_b64_image(data[, output_filename])Save a base64-encoded image to storage.
save_data(data[, output_filename])Save data to storage.
save_formatted_audio(data[, num_channels, ...])Save PCM16 or similarly formatted audio data to storage.
Attributes
- data_on_disk() bool[source]#
Indicate whether this serializer persists data on disk.
- Returns:
Always True for audio path serializers.
- Return type: