docstr: Can change sample rate and channels on-the-fly
docstr_tok: ["Can","change","sample","rate","and","channels","on-the-fly"]
code: def test_change_audio_encoder_spec(
      self,
      ext,
      encoder,
      src_sr,
      enc_sr,
      src_num_channels,
      enc_num_channels,
  ):
      """Can change sample rate and channels on-the-fly"""
      filename = f"test.{ext}"
  
      original = get_sinusoid(
          sample_rate=src_sr,
          n_channels=src_num_channels,
          channels_first=False,
          duration=0.1,
      )
  
      dst = self.get_temp_path(filename)
      w = StreamWriter(dst, format=ext)
      w.add_audio_stream(
          sample_rate=src_sr,
          format="flt",
          num_channels=src_num_channels,
          encoder=encoder,
          encoder_sample_rate=enc_sr,
          encoder_num_channels=enc_num_channels,
      )
  
      with w.open():
          w.write_audio_chunk(0, original)
  
      # check
      reader = torchaudio.io.StreamReader(
          src=self.get_temp_path(filename)
      )
      i = reader.get_src_stream_info(0)
      self.assertEqual(i.sample_rate, enc_sr)
      self.assertEqual(i.num_channels, enc_num_channels)
  
imports: import io
  import math
  import torch
  import torchaudio
  from parameterized import parameterized, parameterized_class
  from torchaudio.io import CodecConfig, StreamReader, StreamWriter
  from torchaudio_unittest.common_utils import get_asset_path, get_sinusoid, nested_params, rgb_to_yuv_ccir, skipIfNoFFmpeg, skipIfNoModule, TempDirMixin, TorchaudioTestCase
  from .common import lt42
label_desc: Use image node_id 16 for calling the StreamWriterCorrectnessTest obj's underlying member method code with example usage: obj.test_change_audio_encoder_spec(ext, encoder, src_sr, enc_sr, src_num_channels, enc_num_channels) without return types