Skip to content

Commit 66b8e4a

Browse files
Merge pull request #244 from dvonthenen/fix-missing-values-after-audit
Fix Missing Values After Audit
2 parents 38b57b5 + 8363a5c commit 66b8e4a

File tree

4 files changed

+18
-29
lines changed

4 files changed

+18
-29
lines changed

deepgram/clients/prerecorded/v1/response.py

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def __getitem__(self, key):
8080

8181
@dataclass_json
8282
@dataclass
83-
class SummaryV2:
83+
class SummaryV1:
8484
summary: Optional[str] = ""
8585
start_word: Optional[float] = 0
8686
end_word: Optional[float] = 0
@@ -92,19 +92,13 @@ def __getitem__(self, key):
9292

9393
@dataclass_json
9494
@dataclass
95-
class Summaries(SummaryV2): # internal reference to old name
96-
summary: Optional[str] = ""
97-
start_word: Optional[float] = 0
98-
end_word: Optional[float] = 0
99-
100-
def __getitem__(self, key):
101-
_dict = self.to_dict()
102-
return _dict[key]
95+
class Summaries(SummaryV1): # internal reference to old name
96+
pass
10397

10498

10599
@dataclass_json
106100
@dataclass
107-
class Summary:
101+
class SummaryV2:
108102
result: Optional[str] = ""
109103
short: Optional[str] = ""
110104

@@ -115,13 +109,8 @@ def __getitem__(self, key):
115109

116110
@dataclass_json
117111
@dataclass
118-
class Summary(Summary): # internal reference to old name
119-
result: Optional[str] = ""
120-
short: Optional[str] = ""
121-
122-
def __getitem__(self, key):
123-
_dict = self.to_dict()
124-
return _dict[key]
112+
class Summary(SummaryV2): # internal reference to old name
113+
pass
125114

126115

127116
@dataclass_json
@@ -305,7 +294,7 @@ class Alternative:
305294
transcript: Optional[str] = ""
306295
confidence: Optional[float] = 0
307296
words: Optional[List[Word]] = None
308-
summaries: Optional[List[SummaryV2]] = None
297+
summaries: Optional[List[SummaryV1]] = None
309298
paragraphs: Optional[Paragraphs] = None
310299
entities: Optional[List[Entity]] = None
311300
translations: Optional[List[Translation]] = None
@@ -319,7 +308,7 @@ def __getitem__(self, key):
319308
]
320309
if _dict["summaries"] is not None:
321310
_dict["summaries"] = [
322-
SummaryV2.from_dict(summaries)
311+
SummaryV1.from_dict(summaries)
323312
for _, summaries in _dict["summaries"].items()
324313
]
325314
if _dict["paragraphs"] is not None:
@@ -346,6 +335,7 @@ class Channel:
346335
search: Optional[List[Search]] = None
347336
alternatives: Optional[List[Alternative]] = None
348337
detected_language: Optional[str] = ""
338+
language_confidence: Optional[float] = 0
349339

350340
def __getitem__(self, key):
351341
_dict = self.to_dict()
@@ -366,7 +356,7 @@ def __getitem__(self, key):
366356
class Result:
367357
channels: Optional[List[Channel]] = None
368358
utterances: Optional[List[Utterance]] = None
369-
summary: Optional[Summary] = None
359+
summary: Optional[SummaryV2] = None
370360

371361
def __getitem__(self, key):
372362
_dict = self.to_dict()
@@ -380,7 +370,7 @@ def __getitem__(self, key):
380370
for _, utterances in _dict["utterances"].items()
381371
]
382372
if _dict["summary"] is not None:
383-
_dict["summary"] = Summary.from_dict(_dict["summary"])
373+
_dict["summary"] = SummaryV2.from_dict(_dict["summary"])
384374
return _dict[key]
385375

386376

examples/prerecorded/async_url/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ async def transcribe_url():
3636
async def main():
3737
try:
3838
response = await transcribe_url()
39-
print(response)
39+
print(response.to_json(indent=4))
4040
except Exception as e:
4141
print(f"Exception: {e}")
4242

examples/prerecorded/file/main.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
AUDIO_FILE = "preamble.wav"
1919

20+
2021
def main():
2122
try:
2223
# STEP 1 Create a Deepgram client using the API key in the environment variables
@@ -41,11 +42,8 @@ def main():
4142
punctuate=True,
4243
diarize=True,
4344
)
44-
file_response = deepgram.listen.prerecorded.v("1").transcribe_file(payload, options)
45-
46-
print(f"\n\n{file_response}\n\n")
47-
json = file_response.to_json()
48-
print(f"{json}\n")
45+
response = deepgram.listen.prerecorded.v("1").transcribe_file(payload, options)
46+
print(response.to_json(indent=4))
4947

5048
except Exception as e:
5149
print(f"Exception: {e}")

examples/prerecorded/url/main.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"url": "https://static.deepgram.com/examples/Bueller-Life-moves-pretty-fast.wav"
1515
}
1616

17+
1718
def main():
1819
try:
1920
# STEP 1 Create a Deepgram client using the API key from environment variables
@@ -25,8 +26,8 @@ def main():
2526
smart_format=True,
2627
summarize="v2",
2728
)
28-
url_response = deepgram.listen.prerecorded.v("1").transcribe_url(AUDIO_URL, options)
29-
print(url_response)
29+
response = deepgram.listen.prerecorded.v("1").transcribe_url(AUDIO_URL, options)
30+
print(response.to_json(indent=4))
3031

3132
except Exception as e:
3233
print(f"Exception: {e}")

0 commit comments

Comments
 (0)