From 149668a67321016833eb93deb614d98e741539a3 Mon Sep 17 00:00:00 2001 From: Chip Wasson Date: Thu, 24 Apr 2025 13:17:41 -0600 Subject: [PATCH] Add assembly ai conversion --- src/app.module.ts | 2 ++ src/assembly-ai/assembly-ai.controller.ts | 37 +++++++++++++++++++++++ src/assembly-ai/assembly-ai.module.ts | 7 +++++ src/hoarding/hoarding.service.ts | 7 ++++- 4 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 src/assembly-ai/assembly-ai.controller.ts create mode 100644 src/assembly-ai/assembly-ai.module.ts diff --git a/src/app.module.ts b/src/app.module.ts index edd0a7b..fb1b811 100644 --- a/src/app.module.ts +++ b/src/app.module.ts @@ -31,6 +31,7 @@ import { EmailModule } from './email/email.module'; import { ContactModule } from './contact/contact.module'; import { HoardingModule } from './hoarding/hoarding.module'; import { NamesModule } from './names/names.module'; +import { AssemblyAiModule } from './assembly-ai/assembly-ai.module'; @Module({ imports: [ @@ -108,6 +109,7 @@ import { NamesModule } from './names/names.module'; ContactModule, HoardingModule, NamesModule, + AssemblyAiModule, ], controllers: [AppController], providers: [ diff --git a/src/assembly-ai/assembly-ai.controller.ts b/src/assembly-ai/assembly-ai.controller.ts new file mode 100644 index 0000000..f1cf5a8 --- /dev/null +++ b/src/assembly-ai/assembly-ai.controller.ts @@ -0,0 +1,37 @@ +import { Body, Controller, Post } from '@nestjs/common'; +import { ApiResponse } from '@nestjs/swagger'; + +interface Utterance { + speaker: string; + text: string; + start: number; + end: number; + confidence: number; + words: Array<{ + start: number; + end: number; + text: string; + confidence: number; + speaker: string; + }>; +} + +@Controller('assembly-ai') +export class AssemblyAiController { + @Post('utterance-to-script') + @ApiResponse({ + status: 200, + description: 'Converts utterances to a script format', + type: String, + }) + async utteranceToScript( + @Body() body: { utterances: Utterance[] } | Utterance[], + ) { + const utterances = Array.isArray(body) ? body : body.utterances; + return utterances.map( + (utterance) => ` +${utterance.speaker}: +${utterance.text}`, + ); + } +} diff --git a/src/assembly-ai/assembly-ai.module.ts b/src/assembly-ai/assembly-ai.module.ts new file mode 100644 index 0000000..9086831 --- /dev/null +++ b/src/assembly-ai/assembly-ai.module.ts @@ -0,0 +1,7 @@ +import { Module } from '@nestjs/common'; +import { AssemblyAiController } from './assembly-ai.controller'; + +@Module({ + controllers: [AssemblyAiController] +}) +export class AssemblyAiModule {} diff --git a/src/hoarding/hoarding.service.ts b/src/hoarding/hoarding.service.ts index 8f2c90f..f63000e 100644 --- a/src/hoarding/hoarding.service.ts +++ b/src/hoarding/hoarding.service.ts @@ -22,7 +22,7 @@ export class HoardingService { this.logger.error(e); } try { - await this.hoardUserChessStats('archyotype'); + await this.hoardUserChessStats('archy_type'); } catch (e) { this.logger.error(e); } @@ -31,6 +31,11 @@ export class HoardingService { } catch (e) { this.logger.error(e); } + try { + await this.hoardLichessStats('archy_type'); + } catch (e) { + this.logger.error(e); + } } async hoardLichessStats(user: string) {