---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
Cell In[10], line 3
1 print(response.results.channels[0].alternatives[0].transcript)
----> 3 print(response.results.channels[0].alternatives[0]["transcript"])
File ~/.../.venv/lib/python3.10/site-packages/deepgram/clients/prerecorded/v1/response.py:351, in Alternative.__getitem__(self, key)
348 _dict = self.to_dict()
349 if _dict["words"] is not None:
350 _dict["words"] = [
--> 351 Word.from_dict(words) for _, words in _dict["words"].items()
352 ]
353 if _dict["summaries"] is not None:
354 _dict["summaries"] = [
355 SummaryV1.from_dict(summaries)
356 for _, summaries in _dict["summaries"].items()
357 ]
AttributeError: 'list' object has no attribute 'items'
This crash happens on ["alternatives"], ["channels"] and so on
Expected behavior
Not crashing
Please tell us about your environment
python 3.10.4
linux
deepgram-sdk 3.1.3
Other information
We are migrating a lot of code from v2 to v3 so we still use a lot of the legacy syntax. Upgrading to the new syntax is unfortunately not easy as everything is now Optional, which is a big pain. Inlcuding word on the Word dataclass, how that could ever be None im not sure.
What is the current behavior?
There seams to be something wrong with the
__getitem__
method on the response objects, it tries it iterate over lists as if they are dicts.Steps to reproduce
Using this response dataclass we can get the transcript:
Which works, but if we use the legacy v2 syntax at any point in the chain
We get a crash
This crash happens on ["alternatives"], ["channels"] and so on
Expected behavior
Not crashing
Please tell us about your environment
python 3.10.4 linux deepgram-sdk 3.1.3
Other information
We are migrating a lot of code from v2 to v3 so we still use a lot of the legacy syntax. Upgrading to the new syntax is unfortunately not easy as everything is now Optional, which is a big pain. Inlcuding
word
on theWord
dataclass, how that could ever be None im not sure.