@@ -41,8 +41,10 @@ class AudioFormat(str, Enum):
4141 >>> from getstream.video.rtc.track_util import AudioFormat, PcmData
4242 >>> import numpy as np
4343 >>> pcm = PcmData(samples=np.array([1, 2], np.int16), sample_rate=16000, format=AudioFormat.S16)
44- >>> pcm.format
45- 's16'
44+ >>> pcm.format == AudioFormat.S16
45+ True
46+ >>> pcm.format == "s16" # Can compare with string directly
47+ True
4648 """
4749
4850 S16 = "s16" # Signed 16-bit integer
@@ -65,10 +67,10 @@ def validate(fmt: str) -> str:
6567 Example:
6668 >>> AudioFormat.validate("s16")
6769 's16'
68- >>> AudioFormat.validate("invalid")
70+ >>> AudioFormat.validate("invalid") # doctest: +ELLIPSIS
6971 Traceback (most recent call last):
7072 ...
71- ValueError: Invalid audio format: 'invalid'. Must be one of: s16, f32
73+ ValueError: Invalid audio format: 'invalid'. Must be one of: ...
7274 """
7375 valid_formats = {f .value for f in AudioFormat }
7476 if fmt not in valid_formats :
@@ -682,7 +684,7 @@ def append(self, other: "PcmData") -> "PcmData":
682684 >>> import numpy as np
683685 >>> a = PcmData(sample_rate=16000, format="s16", samples=np.array([1, 2], np.int16), channels=1)
684686 >>> b = PcmData(sample_rate=16000, format="s16", samples=np.array([3, 4], np.int16), channels=1)
685- >>> a.append(b) # modifies a in-place
687+ >>> _ = a.append(b) # modifies a in-place
686688 >>> a.samples.tolist()
687689 [1, 2, 3, 4]
688690 """
@@ -832,7 +834,7 @@ def copy(self) -> "PcmData":
832834 >>> import numpy as np
833835 >>> a = PcmData(sample_rate=16000, format="s16", samples=np.array([1, 2], np.int16), channels=1)
834836 >>> b = a.copy()
835- >>> b.append(PcmData(sample_rate=16000, format="s16", samples=np.array([3, 4], np.int16), channels=1))
837+ >>> _ = b.append(PcmData(sample_rate=16000, format="s16", samples=np.array([3, 4], np.int16), channels=1))
836838 >>> a.samples.tolist() # original unchanged
837839 [1, 2]
838840 >>> b.samples.tolist() # copy was modified
@@ -1025,8 +1027,8 @@ def chunks(
10251027 Example:
10261028 >>> pcm = PcmData(samples=np.arange(10, dtype=np.int16), sample_rate=16000, format="s16")
10271029 >>> chunks = list(pcm.chunks(4, overlap=2))
1028- >>> len(chunks) # [0:4], [2:6], [4:8], [6:10]
1029- 4
1030+ >>> len(chunks) # [0:4], [2:6], [4:8], [6:10], [8:10]
1031+ 5
10301032 """
10311033 # Ensure we have a 1D array for simpler chunking
10321034 if isinstance (self .samples , np .ndarray ):
@@ -1148,7 +1150,7 @@ def sliding_window(
11481150 >>> pcm = PcmData(samples=np.arange(800, dtype=np.int16), sample_rate=16000, format="s16")
11491151 >>> windows = list(pcm.sliding_window(25.0, 10.0)) # 25ms window, 10ms hop
11501152 >>> len(windows) # 400 samples per window, 160 sample hop
1151- 4
1153+ 5
11521154 """
11531155 window_samples = int (self .sample_rate * window_size_ms / 1000 )
11541156 hop_samples = int (self .sample_rate * hop_ms / 1000 )
0 commit comments