-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
otter.ts
45 lines (38 loc) · 1.28 KB
/
otter.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// @ts-ignore
import * as alfy from 'alfy'
import { createClient, SearchResult, SpeechSummary } from 'otter.ai-api'
function validateEnv() {
if (!process.env.email?.trim() || !process.env.password?.trim()) {
alfy.error("Please specify your email and password in workflow variables")
process.exit()
}
}
export const otterClient = async () => {
validateEnv()
return await createClient({
email: process.env.email!!,
password: process.env.password!!,
})
}
export interface SpeechViewSummary {
startTime: number
id: string
displayId: string
}
export function getExportTemplate(): string {
let exportTemplateConfigVar = process.env.exportTemplate?.trim()
return exportTemplateConfigVar || [
"${fullTranscript}",
" - Recorded at::${new Date(speech.end_time * 1000).toLocaleString()}",
" - https://otter.ai/u/${speech.otid}",
" - {{audio: ${speech.audio_url} }}"
].join("\n")
}
export const isSearchResult = (speech: SpeechSummary | SearchResult): speech is SearchResult =>
(speech as SearchResult).speech_otid !== undefined
export const getOtid = (speech: SpeechSummary | SearchResult): string => {
if (isSearchResult(speech)) {
return speech.speech_otid
}
return speech.otid
}