@@ -124,6 +124,20 @@ class MediaJsonTest : ShouldSpec() {
124124 (parsed == = event) shouldBe false
125125 }
126126 }
127+ context(" TranscriptionResultEvent" ) {
128+ val event = TranscriptionResultEvent ()
129+
130+ context(" Serializing" ) {
131+ val parsed = parser.parse(event.toJson())
132+ parsed.shouldBeInstanceOf<JSONObject >()
133+ parsed[" event" ] shouldBe " transcription-result"
134+ }
135+ context(" Parsing" ) {
136+ val parsed = Event .parse(event.toJson())
137+ parsed.shouldBeInstanceOf<TranscriptionResultEvent >()
138+ parsed.event shouldBe " transcription-result"
139+ }
140+ }
127141 context(" Parsing valid samples" ) {
128142 context(" Start" ) {
129143 val parsed = Event .parse(
@@ -260,6 +274,53 @@ class MediaJsonTest : ShouldSpec() {
260274 parsed.event shouldBe " pong"
261275 parsed.id shouldBe 123
262276 }
277+ context(" TranscriptionResult " ) {
278+ val originalJson = """
279+ {
280+ "transcript": [
281+ {
282+ "confidence": 0.999666973709317,
283+ "text": "blah blah blah"
284+ }
285+ ],
286+ "is_interim": false,
287+ "message_id": "item_CnopdEudFcwXCkZfCIHrC",
288+ "type": "transcription-result",
289+ "event": "transcription-result",
290+ "participant": {
291+ "id": "08847b00",
292+ "ssrc": "1776301157"
293+ },
294+ "timestamp": 1765989508172
295+ }
296+ """ .trimIndent()
297+
298+ val parsed = Event .parse(originalJson)
299+ parsed.shouldBeInstanceOf<TranscriptionResultEvent >()
300+
301+ val serialized = parsed.toJson()
302+ val reparsed = parser.parse(serialized)
303+ reparsed.shouldBeInstanceOf<JSONObject >()
304+
305+ reparsed[" event" ] shouldBe " transcription-result"
306+ reparsed[" type" ] shouldBe " transcription-result"
307+ reparsed[" message_id" ] shouldBe " item_CnopdEudFcwXCkZfCIHrC"
308+ reparsed[" is_interim" ] shouldBe false
309+ reparsed[" timestamp" ] shouldBe 1765989508172L
310+
311+ val transcript = reparsed[" transcript" ]
312+ transcript.shouldBeInstanceOf<List <* >>()
313+ transcript.size shouldBe 1
314+ val transcriptItem = transcript[0 ] as Map <* , * >
315+ transcriptItem.shouldBeInstanceOf<Map <* , * >>()
316+ transcriptItem[" confidence" ] shouldBe 0.999666973709317
317+ transcriptItem[" text" ] shouldBe " blah blah blah"
318+
319+ val participant = reparsed[" participant" ]
320+ participant.shouldBeInstanceOf<Map <* , * >>()
321+ participant[" id" ] shouldBe " 08847b00"
322+ participant[" ssrc" ] shouldBe " 1776301157"
323+ }
263324 }
264325 context(" Parsing invalid samples" ) {
265326 context(" Invalid sequence number" ) {
0 commit comments