class_docstr: Sample collection writer for creating a Sample DB (SDB) file
class_docstr_tok: ["Sample","collection","writer","for","creating","a","Sample","DB","(","SDB",")","file"]
docstr: Parameters
  ----------
  sdb_filename : str
      Path to the SDB file to write
  buffering : int
      Write-buffer size to use while writing the SDB file
  audio_type : str
      See util.audio.Sample.__init__ .
  bitrate : int
      Bitrate for sample-compression in case of lossy audio_type (e.g. AUDIO_TYPE_OPUS)
  id_prefix : str
      Prefix for IDs of written samples - defaults to sdb_filename
  labeled : bool or None
      If True: Writes labeled samples (util.sample_collections.LabeledSample) only.
      If False: Ignores transcripts (if available) and writes (unlabeled) util.audio.Sample instances.
code: def __init__(
      self,
      sdb_filename,
      buffering=BUFFER_SIZE,
      audio_type=AUDIO_TYPE_OPUS,
      bitrate=None,
      id_prefix=None,
      labeled=True,
  ):
      """
      Parameters
      ----------
      sdb_filename : str
          Path to the SDB file to write
      buffering : int
          Write-buffer size to use while writing the SDB file
      audio_type : str
          See util.audio.Sample.__init__ .
      bitrate : int
          Bitrate for sample-compression in case of lossy audio_type (e.g. AUDIO_TYPE_OPUS)
      id_prefix : str
          Prefix for IDs of written samples - defaults to sdb_filename
      labeled : bool or None
          If True: Writes labeled samples (util.sample_collections.LabeledSample) only.
          If False: Ignores transcripts (if available) and writes (unlabeled) util.audio.Sample instances.
      """
      self.sdb_filename = sdb_filename
      self.id_prefix = sdb_filename if id_prefix is None else id_prefix
      self.labeled = labeled
      if audio_type not in SERIALIZABLE_AUDIO_TYPES:
          raise ValueError(
              'Audio type "{}" not supported'.format(audio_type)
          )
      self.audio_type = audio_type
      self.bitrate = bitrate
      self.sdb_file = open_remote(
          sdb_filename, "wb", buffering=buffering
      )
      self.offsets = []
      self.num_samples = 0
  
      self.sdb_file.write(MAGIC)
  
      schema_entries = [
          {CONTENT_KEY: CONTENT_TYPE_SPEECH, MIME_TYPE_KEY: audio_type}
      ]
      if self.labeled:
          schema_entries.append(
              {
                  CONTENT_KEY: CONTENT_TYPE_TRANSCRIPT,
                  MIME_TYPE_KEY: MIME_TYPE_TEXT,
              }
          )
      meta_data = {SCHEMA_KEY: schema_entries}
      meta_data = json.dumps(meta_data).encode()
      self.write_big_int(len(meta_data))
      self.sdb_file.write(meta_data)
  
      self.offset_samples = self.sdb_file.tell()
      self.sdb_file.seek(2 * BIGINT_SIZE, 1)
  
imports: import os
  import io
  import csv
  import json
  import tarfile
  from pathlib import Path
  from functools import partial
  from .helpers import KILOBYTE, MEGABYTE, GIGABYTE, Interleaved, LenMap
  from .audio import Sample, AUDIO_TYPE_PCM, AUDIO_TYPE_OPUS, SERIALIZABLE_AUDIO_TYPES, get_loadable_audio_type_from_extension, write_wav
  from .io import open_remote, is_remote_path
label_desc: Use image node_id 1 to create a new DirectSDBWriter object  with example: obj = DirectSDBWriter(sdb_filename, buffering, audio_type, bitrate, id_prefix, labeled)