class_docstr: Encode and write audio/video streams chunk by chunk
  
  Args:
      dst (str, path-like or file-like object): The destination where the encoded data are written.
          If string-type, it must be a resource indicator that FFmpeg can
          handle. The supported value depends on the FFmpeg found in the system.
  
          If file-like object, it must support `write` method with the signature
          `write(data: bytes) -> int`.
  
          Please refer to the following for the expected signature and behavior of
          `write` method.
  
          - https://docs.python.org/3/library/io.html#io.BufferedIOBase.write
  
      format (str or None, optional):
          Override the output format, or specify the output media device.
          Default: ``None`` (no override nor device output).
  
          This argument serves two different use cases.
  
          1) Override the output format.
             This is useful when writing raw data or in a format different from the extension.
  
          2) Specify the output device.
             This allows to output media streams to hardware devices,
             such as speaker and video screen.
  
          .. note::
  
             This option roughly corresponds to ``-f`` option of ``ffmpeg`` command.
             Please refer to the ffmpeg documentations for possible values.
  
             https://ffmpeg.org/ffmpeg-formats.html#Muxers
  
             Please use :py:func:`~torio.utils.ffmpeg_utils.get_muxers` to list the
             multiplexers available in the current environment.
  
             For device access, the available values vary based on hardware (AV device) and
             software configuration (ffmpeg build).
             Please refer to the ffmpeg documentations for possible values.
  
             https://ffmpeg.org/ffmpeg-devices.html#Output-Devices
  
             Please use :py:func:`~torio.utils.ffmpeg_utils.get_output_devices` to list
             the output devices available in the current environment.
  
      buffer_size (int):
          The internal buffer size in byte. Used only when `dst` is a file-like object.
  
          Default: `4096`.
class_docstr_tok: ["Encode","and","write","audio\/video","streams","chunk","by","chunk","Args",":","dst","(","str",",","path-like","or","file-like","object",")",":","The","destination","where","the","encoded","data","are","written",".","If","string-type",",","it","must","be","a","resource","indicator","that","FFmpeg","can","handle",".","The","supported","value","depends","on","the","FFmpeg","found","in","the","system",".","If","file-like","object",",","it","must","support","`","write","`","method","with","the","signature","`","write","(","data",":","bytes",")","-",">","int","`",".","Please","refer","to","the","following","for","the","expected","signature","and","behavior","of","`","write","`","method",".","-","https",":","\/\/docs.python.org\/3\/library\/io.html","#","io.BufferedIOBase.write","format","(","str","or","None",",","optional",")",":","Override","the","output","format",",","or","specify","the","output","media","device",".","Default",":","``","None","``","(","no","override","nor","device","output",")",".","This","argument","serves","two","different","use","cases",".","1",")","Override","the","output","format",".","This","is","useful","when","writing","raw","data","or","in","a","format","different","from","the","extension",".","2",")","Specify","the","output","device",".","This","allows","to","output","media","streams","to","hardware","devices",",","such","as","speaker","and","video","screen",".","..","note",":",":","This","option","roughly","corresponds","to","``","-f","``","option","of","``","ffmpeg","``","command",".","Please","refer","to","the","ffmpeg","documentations","for","possible","values",".","https",":","\/\/ffmpeg.org\/ffmpeg-formats.html","#","Muxers","Please","use",":","py",":","func",":","`","~torio.utils.ffmpeg_utils.get_muxers","`","to","list","the","multiplexers","available","in","the","current","environment",".","For","device","access",",","the","available","values","vary","based","on","hardware","(","AV","device",")","and","software","configuration","(","ffmpeg","build",")",".","Please","refer","to","the","ffmpeg","documentations","for","possible","values",".","https",":","\/\/ffmpeg.org\/ffmpeg-devices.html","#","Output-Devices","Please","use",":","py",":","func",":","`","~torio.utils.ffmpeg_utils.get_output_devices","`","to","list","the","output","devices","available","in","the","current","environment",".","buffer_size","(","int",")",":","The","internal","buffer","size","in","byte",".","Used","only","when","`","dst","`","is","a","file-like","object",".","Default",":","`","4096","`","."]
docstr: Add an output audio stream.
  
  Args:
      sample_rate (int): The sample rate.
  
      num_channels (int): The number of channels.
  
      format (str, optional): Input sample format, which determines the dtype
          of the input tensor.
  
          - ``"u8"``: The input tensor must be ``torch.uint8`` type.
          - ``"s16"``: The input tensor must be ``torch.int16`` type.
          - ``"s32"``: The input tensor must be ``torch.int32`` type.
          - ``"s64"``: The input tensor must be ``torch.int64`` type.
          - ``"flt"``: The input tensor must be ``torch.float32`` type.
          - ``"dbl"``: The input tensor must be ``torch.float64`` type.
  
          Default: ``"flt"``.
  
      encoder (str or None, optional): {encoder}
  
      encoder_option (dict or None, optional): {encoder_option}
  
      encoder_sample_rate (int or None, optional): Override the sample rate used for encoding time.
          Some encoders pose restriction on the sample rate used for encoding.
          If the source sample rate is not supported by the encoder, the source sample rate is used,
          otherwise a default one is picked.
  
          For example, ``"opus"`` encoder only supports 48k Hz, so, when encoding a
          waveform with ``"opus"`` encoder, it is always encoded as 48k Hz.
          Meanwhile ``"mp3"`` (``"libmp3lame"``) supports 44.1k, 48k, 32k, 22.05k,
          24k, 16k, 11.025k, 12k and 8k Hz.
          If the original sample rate is one of these, then the original sample rate
          is used, otherwise it will be resampled to a default one (44.1k).
          When encoding into WAV format, there is no restriction on sample rate,
          so the original sample rate will be used.
  
          Providing ``encoder_sample_rate`` will override this behavior and
          make encoder attempt to use the provided sample rate.
          The provided value must be one support by the encoder.
  
      encoder_num_channels (int or None, optional): Override the number of channels used for encoding.
  
          Similar to sample rate, some encoders (such as ``"opus"``,
          ``"vorbis"`` and ``"g722"``) pose restriction on
          the numbe of channels that can be used for encoding.
  
          If the original number of channels is supported by encoder,
          then it will be used, otherwise, the encoder attempts to
          remix the channel to one of the supported ones.
  
          Providing ``encoder_num_channels`` will override this behavior and
          make encoder attempt to use the provided number of channels.
          The provided value must be one support by the encoder.
  
      encoder_format (str or None, optional): {encoder_format}
  
      codec_config (CodecConfig or None, optional): {codec_config}
  
      filter_desc (str or None, optional): {filter_desc}
docstr_tok: ["Add","an","output","audio","stream",".","Args",":","sample_rate","(","int",")",":","The","sample","rate",".","num_channels","(","int",")",":","The","number","of","channels",".","format","(","str",",","optional",")",":","Input","sample","format",",","which","determines","the","dtype","of","the","input","tensor",".","-","``","``","u8","''","``",":","The","input","tensor","must","be","``","torch.uint8","``","type",".","-","``","``","s16","''","``",":","The","input","tensor","must","be","``","torch.int16","``","type",".","-","``","``","s32","''","``",":","The","input","tensor","must","be","``","torch.int32","``","type",".","-","``","``","s64","''","``",":","The","input","tensor","must","be","``","torch.int64","``","type",".","-","``","``","flt","''","``",":","The","input","tensor","must","be","``","torch.float32","``","type",".","-","``","``","dbl","''","``",":","The","input","tensor","must","be","``","torch.float64","``","type",".","Default",":","``","``","flt","''","``",".","encoder","(","str","or","None",",","optional",")",":","{","encoder","}","encoder_option","(","dict","or","None",",","optional",")",":","{","encoder_option","}","encoder_sample_rate","(","int","or","None",",","optional",")",":","Override","the","sample","rate","used","for","encoding","time",".","Some","encoders","pose","restriction","on","the","sample","rate","used","for","encoding",".","If","the","source","sample","rate","is","not","supported","by","the","encoder",",","the","source","sample","rate","is","used",",","otherwise","a","default","one","is","picked",".","For","example",",","``","``","opus","''","``","encoder","only","supports","48k","Hz",",","so",",","when","encoding","a","waveform","with","``","``","opus","''","``","encoder",",","it","is","always","encoded","as","48k","Hz",".","Meanwhile","``","``","mp3","''","``","(","``","``","libmp3lame","''","``",")","supports","44.1k",",","48k",",","32k",",","22.05k",",","24k",",","16k",",","11.025k",",","12k","and","8k","Hz",".","If","the","original","sample","rate","is","one","of","these",",","then","the","original","sample","rate","is","used",",","otherwise","it","will","be","resampled","to","a","default","one","(","44.1k",")",".","When","encoding","into","WAV","format",",","there","is","no","restriction","on","sample","rate",",","so","the","original","sample","rate","will","be","used",".","Providing","``","encoder_sample_rate","``","will","override","this","behavior","and","make","encoder","attempt","to","use","the","provided","sample","rate",".","The","provided","value","must","be","one","support","by","the","encoder",".","encoder_num_channels","(","int","or","None",",","optional",")",":","Override","the","number","of","channels","used","for","encoding",".","Similar","to","sample","rate",",","some","encoders","(","such","as","``","``","opus","''","``",",","``","``","vorbis","''","``","and","``","``","g722","''","``",")","pose","restriction","on","the","numbe","of","channels","that","can","be","used","for","encoding",".","If","the","original","number","of","channels","is","supported","by","encoder",",","then","it","will","be","used",",","otherwise",",","the","encoder","attempts","to","remix","the","channel","to","one","of","the","supported","ones",".","Providing","``","encoder_num_channels","``","will","override","this","behavior","and","make","encoder","attempt","to","use","the","provided","number","of","channels",".","The","provided","value","must","be","one","support","by","the","encoder",".","encoder_format","(","str","or","None",",","optional",")",":","{","encoder_format","}","codec_config","(","CodecConfig","or","None",",","optional",")",":","{","codec_config","}","filter_desc","(","str","or","None",",","optional",")",":","{","filter_desc","}"]
code: def add_audio_stream(
      self,
      sample_rate: int,
      num_channels: int,
      format: str = "flt",
      *,
      encoder: Optional[str] = None,
      encoder_option: Optional[Dict[str, str]] = None,
      encoder_sample_rate: Optional[int] = None,
      encoder_num_channels: Optional[int] = None,
      encoder_format: Optional[str] = None,
      codec_config: Optional[CodecConfig] = None,
      filter_desc: Optional[str] = None,
  ):
      """Add an output audio stream.
  
      Args:
          sample_rate (int): The sample rate.
  
          num_channels (int): The number of channels.
  
          format (str, optional): Input sample format, which determines the dtype
              of the input tensor.
  
              - ``"u8"``: The input tensor must be ``torch.uint8`` type.
              - ``"s16"``: The input tensor must be ``torch.int16`` type.
              - ``"s32"``: The input tensor must be ``torch.int32`` type.
              - ``"s64"``: The input tensor must be ``torch.int64`` type.
              - ``"flt"``: The input tensor must be ``torch.float32`` type.
              - ``"dbl"``: The input tensor must be ``torch.float64`` type.
  
              Default: ``"flt"``.
  
          encoder (str or None, optional): {encoder}
  
          encoder_option (dict or None, optional): {encoder_option}
  
          encoder_sample_rate (int or None, optional): Override the sample rate used for encoding time.
              Some encoders pose restriction on the sample rate used for encoding.
              If the source sample rate is not supported by the encoder, the source sample rate is used,
              otherwise a default one is picked.
  
              For example, ``"opus"`` encoder only supports 48k Hz, so, when encoding a
              waveform with ``"opus"`` encoder, it is always encoded as 48k Hz.
              Meanwhile ``"mp3"`` (``"libmp3lame"``) supports 44.1k, 48k, 32k, 22.05k,
              24k, 16k, 11.025k, 12k and 8k Hz.
              If the original sample rate is one of these, then the original sample rate
              is used, otherwise it will be resampled to a default one (44.1k).
              When encoding into WAV format, there is no restriction on sample rate,
              so the original sample rate will be used.
  
              Providing ``encoder_sample_rate`` will override this behavior and
              make encoder attempt to use the provided sample rate.
              The provided value must be one support by the encoder.
  
          encoder_num_channels (int or None, optional): Override the number of channels used for encoding.
  
              Similar to sample rate, some encoders (such as ``"opus"``,
              ``"vorbis"`` and ``"g722"``) pose restriction on
              the numbe of channels that can be used for encoding.
  
              If the original number of channels is supported by encoder,
              then it will be used, otherwise, the encoder attempts to
              remix the channel to one of the supported ones.
  
              Providing ``encoder_num_channels`` will override this behavior and
              make encoder attempt to use the provided number of channels.
              The provided value must be one support by the encoder.
  
          encoder_format (str or None, optional): {encoder_format}
  
          codec_config (CodecConfig or None, optional): {codec_config}
  
          filter_desc (str or None, optional): {filter_desc}
      """
      self._s.add_audio_stream(
          sample_rate,
          num_channels,
          format,
          encoder,
          encoder_option,
          encoder_format,
          encoder_sample_rate,
          encoder_num_channels,
          _convert_config(codec_config),
          filter_desc,
      )
  
imports: from dataclasses import dataclass
  from pathlib import Path
  from typing import BinaryIO, Dict, Optional, Union
  import torch
  import torio
label_desc: Use image node_id 2 for calling the StreamingMediaEncoder obj's underlying member method code with example usage: obj.add_audio_stream(sample_rate, num_channels, format) without return types