Skip to content

Commit f4f97ec

Browse files
committed
Use newer transcription format + switch example transcription to a better example
1 parent ad229e7 commit f4f97ec

File tree

1 file changed

+28
-9
lines changed

1 file changed

+28
-9
lines changed

pages/video-transcription.jsx

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,16 @@ import { useEffect, useRef, useState } from "react"
22
import Head from "next/head"
33
import styles from "../styles/VideoTranscription.module.css"
44
import { firestore } from "../components/firebase"
5-
import { doc, getDoc } from "firebase/firestore"
5+
import {
6+
collection,
7+
doc,
8+
getDoc,
9+
getDocs,
10+
orderBy,
11+
query
12+
} from "firebase/firestore"
13+
import { useQuery } from "react-query"
14+
import { useRouter } from "next/router"
615

716
export default function VideoTranscription({ videoUrl, utterances }) {
817
const [currentTime, setCurrentTime] = useState(0)
@@ -102,19 +111,29 @@ function formatTime(ms) {
102111
}
103112

104113
export async function getServerSideProps() {
105-
const exampleTranscriptionId = "17c91397-c023-4f28-a621-4cef45c70749"
114+
const hearingId = "hearing-5180"
115+
const hearing = await getDoc(doc(firestore, `events/${hearingId}`))
116+
const { videoTranscriptionId, videoURL } = hearing.data()
117+
118+
// should be
119+
// const exampleTranscriptionId = "639e73ff-bd01-4902-bba7-88faaf39afa9"
106120
const transcription = await getDoc(
107-
doc(firestore, `transcriptions/${exampleTranscriptionId}`)
121+
doc(firestore, `transcriptions/${videoTranscriptionId}`)
122+
)
123+
const utterances = await getDocs(
124+
query(
125+
collection(
126+
firestore,
127+
`transcriptions/${videoTranscriptionId}/utterances`
128+
),
129+
orderBy("start", "asc")
130+
)
108131
)
109-
console.log(transcription.data())
110-
111-
const videoUrl = transcription.data().audio_url
112-
const utterances = transcription.data().utterances
113132

114133
return {
115134
props: {
116-
videoUrl,
117-
utterances
135+
videoUrl: videoURL,
136+
utterances: utterances.docs.map(doc => doc.data())
118137
}
119138
}
120139
}

0 commit comments

Comments
 (0)