Commit ec0038d
authored
elevenlabs-say: fix convert_realtime crash on default voice_settings (#341)
## Problem
`echo hi | nix run .#elevenlabs-say` crashed on the streaming path:
```
File ".../elevenlabs/realtime_tts.py", line 115, in convert_realtime
voice_settings=voice_settings.dict() if voice_settings else None,
AttributeError: 'ellipsis' object has no attribute 'dict'
```
This is a bug in the `elevenlabs` SDK. `convert_realtime` defaults
`voice_settings` to its `OMIT` sentinel, which is the Ellipsis `...`.
The init-frame builder does `voice_settings.dict() if voice_settings
else None`, and `...` is truthy, so the default value calls `.dict()` on
the ellipsis and crashes. We did not pass `voice_settings`, so every
`--stream` invocation hit it.
## Fix
Pass `voice_settings=None` explicitly. `None` is falsy, so the SDK takes
the `else None` branch, and `None` already means "use the voice's stored
settings", so this is also the right value going forward, not just a
workaround.
## Tests
Added `test_stream_init_does_not_crash_on_omit_voice_settings`: it
monkeypatches the SDK's `connect` with a fake socket, drives
`stream_synthesize` far enough to build and send the init frame, and
asserts the frame carries a null `voice_settings`. This reproduces the
crash offline (it errors with the AttributeError if the explicit `None`
is removed), so the streaming path now has a no-network guard against
this class of SDK-integration break.
## Validation
- ✅ `nix build .#elevenlabs-say` (runs `ty`)
- ✅ `nix build .#elevenlabs-say.tests.streaming` and `.tests.printsHelp`
- ✅ `nix run .#lint`
- Not run against the live API: no `ELEVENLABS_API_KEY` here. This
clears the AttributeError that aborted streaming before any frame was
sent; confirm end to end with `echo hi | nix run .#elevenlabs-say`.
Filing the upstream bug at elevenlabs/elevenlabs-python separately.
---
Made with AI (Claude Opus 4.8).1 parent 891143a commit ec0038d
2 files changed
Lines changed: 60 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
274 | 274 | | |
275 | 275 | | |
276 | 276 | | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
277 | 282 | | |
278 | 283 | | |
279 | 284 | | |
280 | 285 | | |
281 | 286 | | |
| 287 | + | |
282 | 288 | | |
283 | 289 | | |
284 | 290 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
| 17 | + | |
| 18 | + | |
16 | 19 | | |
17 | 20 | | |
18 | 21 | | |
| |||
121 | 124 | | |
122 | 125 | | |
123 | 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 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
124 | 177 | | |
125 | 178 | | |
126 | 179 | | |
127 | 180 | | |
128 | 181 | | |
129 | 182 | | |
| 183 | + | |
130 | 184 | | |
0 commit comments