-
Notifications
You must be signed in to change notification settings - Fork 2
/
summarise.ts
executable file
·34 lines (27 loc) · 994 Bytes
/
summarise.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
#!/usr/bin/env ./node_modules/.bin/ts-node
import { readFileSync } from 'fs'
import { createSummary } from '../lib/summarisation'
import yargs from 'yargs'
import { Transcript } from '../lib/types'
interface Argv {
transcriptFilePath: string
bedrockRegion: string
}
const argv: Argv = yargs
.usage('Usage: $0 <transcriptFilePath>')
.command('$0 <transcriptFilePath>', 'path to the transcript JSON file')
.options('bedrock-region', {
default: 'us-east-1'
})
.alias('h', 'help')
.help('help')
.demandCommand(1, 'You need to provide a filename argument.')
.argv as unknown as Argv
const filename: string = argv.transcriptFilePath
const transcriptContents = readFileSync(filename, 'utf8')
const transcript = JSON.parse(transcriptContents)
summarise(transcript)
async function summarise (transcript: Transcript): Promise<void> {
const summary = await createSummary(transcript, { bedrockRegion: argv.bedrockRegion })
console.log(JSON.stringify(summary, null, 4))
}