Commit c3e5841
Replace callback-based audio streaming with iterator pattern (#597)
`AudioClient.transcribe_streaming` required a callback argument,
inconsistent with `ChatClient.complete_streaming_chat` which returns a
`Generator`. Align the audio client to the same iterator pattern used
across the SDK.
### Changes
- **`audio_client.py`**: Replace `transcribe_streaming(path, callback)
-> None` with `transcribe_streaming(path) ->
Generator[AudioTranscriptionResponse]` using the same `threading.Thread`
+ `queue.Queue` + sentinel pattern from `ChatClient._stream_chunks`
- **`test_audio_client.py`**: Update streaming tests to `for chunk in`
consumption; remove `test_should_raise_for_streaming_invalid_callback`
(no longer applicable)
- **`test/README.md`**: Update test counts (7→6 audio, 32→31 total)
### Usage
```python
# Before
def on_chunk(chunk):
print(chunk.text)
audio_client.transcribe_streaming("recording.mp3", on_chunk)
# After
for chunk in audio_client.transcribe_streaming("recording.mp3"):
print(chunk.text)
```
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: baijumeswani <12852605+baijumeswani@users.noreply.github.com>
Co-authored-by: Prathik Rao <prathikrao@microsoft.com>1 parent 7ad2ef0 commit c3e5841
File tree
3 files changed
+51
-43
lines changed- sdk/python
- src/openai
- test
- openai
3 files changed
+51
-43
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
| 11 | + | |
10 | 12 | | |
11 | | - | |
| 13 | + | |
12 | 14 | | |
13 | 15 | | |
14 | 16 | | |
| |||
114 | 116 | | |
115 | 117 | | |
116 | 118 | | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
117 | 153 | | |
118 | 154 | | |
119 | 155 | | |
120 | | - | |
121 | | - | |
| 156 | + | |
122 | 157 | | |
123 | 158 | | |
124 | | - | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
125 | 163 | | |
126 | 164 | | |
127 | 165 | | |
128 | | - | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
129 | 169 | | |
130 | 170 | | |
131 | 171 | | |
132 | 172 | | |
133 | 173 | | |
134 | 174 | | |
135 | 175 | | |
136 | | - | |
137 | | - | |
138 | | - | |
139 | 176 | | |
140 | | - | |
141 | | - | |
142 | | - | |
143 | | - | |
144 | | - | |
145 | | - | |
146 | | - | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | | - | |
151 | | - | |
152 | | - | |
153 | | - | |
| 177 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
53 | | - | |
| 53 | + | |
54 | 54 | | |
55 | 55 | | |
56 | | - | |
| 56 | + | |
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
88 | 88 | | |
89 | 89 | | |
90 | 90 | | |
91 | | - | |
92 | | - | |
| 91 | + | |
93 | 92 | | |
94 | 93 | | |
95 | 94 | | |
96 | 95 | | |
97 | 96 | | |
98 | 97 | | |
99 | | - | |
100 | | - | |
101 | 98 | | |
102 | 99 | | |
103 | 100 | | |
| |||
114 | 111 | | |
115 | 112 | | |
116 | 113 | | |
117 | | - | |
118 | | - | |
| 114 | + | |
119 | 115 | | |
120 | 116 | | |
121 | 117 | | |
122 | 118 | | |
123 | | - | |
124 | | - | |
125 | 119 | | |
126 | 120 | | |
127 | 121 | | |
| |||
143 | 137 | | |
144 | 138 | | |
145 | 139 | | |
146 | | - | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | | - | |
151 | | - | |
152 | | - | |
153 | | - | |
154 | | - | |
155 | | - | |
156 | | - | |
| 140 | + | |
0 commit comments