Get transcript summaries of Web videos.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
1.0 KiB

  1. import { constants } from 'http2';
  2. import { SummaryService, SummaryServiceImpl } from './SummaryService';
  3. import { Controller } from '../../packages/fastify-controller';
  4. export interface SummaryController extends Controller<'summarizeVideoTranscript'> {}
  5. export class SummaryControllerImpl implements SummaryController {
  6. constructor(
  7. private readonly summaryService: SummaryService = new SummaryServiceImpl(),
  8. ) {
  9. // noop
  10. }
  11. readonly summarizeVideoTranscript: SummaryController['summarizeVideoTranscript'] = async (request, reply) => {
  12. try {
  13. const stream = this.summaryService.createSummaryStream(request.body as string);
  14. reply.header('Content-Type', 'application/octet-stream');
  15. reply.raw.statusMessage = 'Summary Generated';
  16. return reply.send(stream);
  17. } catch (errRaw) {
  18. const err = errRaw as Error;
  19. request.server.log.error(err);
  20. reply.code(constants.HTTP_STATUS_INTERNAL_SERVER_ERROR)
  21. reply.raw.statusMessage = 'Summary Failed';
  22. reply.send();
  23. }
  24. };
  25. }