@@ -19,6 +19,7 @@ export const transcription = functions
19
19
const transcript = await assembly . transcripts . get (
20
20
req . body . transcript_id
21
21
)
22
+
22
23
if ( transcript && transcript . webhook_auth ) {
23
24
// If there is a transcript and the transcript has an auth property,
24
25
// look for an event (aka Hearing) in the DB with a matching ID.
@@ -67,6 +68,10 @@ export const transcription = functions
67
68
if ( authenticatedEventIds . length === 1 ) {
68
69
// If there is one authenticated event, pull out the parts we want to
69
70
// save and try to save them in the db.
71
+
72
+ const { paragraphs } = await assembly . transcripts . paragraphs (
73
+ transcript . id
74
+ )
70
75
const { id, text, audio_url, utterances } = transcript
71
76
try {
72
77
const transcriptionInDb = await db
@@ -102,6 +107,24 @@ export const transcription = functions
102
107
await writer . close ( )
103
108
}
104
109
110
+ if ( paragraphs ) {
111
+ const writer = db . bulkWriter ( )
112
+ for ( let paragraph of paragraphs ) {
113
+ const { confidence, start, end, text } = paragraph
114
+
115
+ writer . set (
116
+ db
117
+ . collection ( "transcriptions" )
118
+ . doc ( `${ transcript . id } ` )
119
+ . collection ( "paragraphs" )
120
+ . doc ( ) ,
121
+ { confidence, start, end, text }
122
+ )
123
+ }
124
+
125
+ await writer . close ( )
126
+ }
127
+
105
128
// Delete the hashed webhook auth token from our db now that
106
129
// we're done.
107
130
for ( const index in authenticatedEventIds ) {
0 commit comments