baml.media.Audio
An audio clip value.
Signature
class baml.media.AudioAn audio clip value.
Backed by a URL or by base64-encoded content. A file is read when the value is built from it: the value holds its content, never its path.
Source:<builtin>/baml/ns_media/media.bamlbytes 2983–5653
Fields
_data
$rust_typeStatic methods
from_base64
(base64: string, mime_type: string | null) -> audio throws neverCreates an Audio value from a base64-encoded string. Optionally specify mime_type.
from_file
(Creates an Audio value from the content of a local file, which is
read now. The value is named by the file's base name. Optionally
specify mime_type; otherwise it is inferred from the file's name.
Throws
Ioif the file cannot be opened or read.InvalidArgumentonly asbaml.fs.opendeclares it: a path that cannot be opened isIo.
from_file_content
(file: string, base64: string, mime_type: string | null) -> audio throws neverCreates an Audio value from base64-encoded content that was read
from file. The value is named by the file's base name. Optionally
specify mime_type; otherwise it is inferred from the file's name.
from_url
(url: string, mime_type: string | null) -> audio throws neverCreates an Audio value from a URL. Optionally specify mime_type.
infer_mime_type
(source: string) -> string throws neverReturns the MIME type that source, a file name or URL, implies for
an audio clip: by its extension, or the usual type for an audio clip when the
extension says nothing. A URL's query and fragment are not part of
its extension.
Instance methods
base64
(self) -> string throws neverReturns the base64-encoded content of this audio clip.
mime_type
(self) -> string | null throws neverReturns the MIME type of this audio clip, or null if not set.
name
(self) -> string | null throws neverReturns the name of this audio clip, or null if it has none. An audio clip built from a
file is named by the file's base name.
url
(self) -> string | null throws neverReturns the URL of this audio clip, or null if it was not constructed from a URL.
Implementations
baml.Concrete for T
Source:<builtin>/baml/core.bamlbytes 763–795