Add assembly ai conversion

This commit is contained in:
2025-04-24 13:17:41 -06:00
parent 76f093eeda
commit 149668a673
4 changed files with 52 additions and 1 deletions

View File

@@ -31,6 +31,7 @@ import { EmailModule } from './email/email.module';
import { ContactModule } from './contact/contact.module'; import { ContactModule } from './contact/contact.module';
import { HoardingModule } from './hoarding/hoarding.module'; import { HoardingModule } from './hoarding/hoarding.module';
import { NamesModule } from './names/names.module'; import { NamesModule } from './names/names.module';
import { AssemblyAiModule } from './assembly-ai/assembly-ai.module';
@Module({ @Module({
imports: [ imports: [
@@ -108,6 +109,7 @@ import { NamesModule } from './names/names.module';
ContactModule, ContactModule,
HoardingModule, HoardingModule,
NamesModule, NamesModule,
AssemblyAiModule,
], ],
controllers: [AppController], controllers: [AppController],
providers: [ providers: [

View File

@@ -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}`,
);
}
}

View File

@@ -0,0 +1,7 @@
import { Module } from '@nestjs/common';
import { AssemblyAiController } from './assembly-ai.controller';
@Module({
controllers: [AssemblyAiController]
})
export class AssemblyAiModule {}

View File

@@ -22,7 +22,7 @@ export class HoardingService {
this.logger.error(e); this.logger.error(e);
} }
try { try {
await this.hoardUserChessStats('archyotype'); await this.hoardUserChessStats('archy_type');
} catch (e) { } catch (e) {
this.logger.error(e); this.logger.error(e);
} }
@@ -31,6 +31,11 @@ export class HoardingService {
} catch (e) { } catch (e) {
this.logger.error(e); this.logger.error(e);
} }
try {
await this.hoardLichessStats('archy_type');
} catch (e) {
this.logger.error(e);
}
} }
async hoardLichessStats(user: string) { async hoardLichessStats(user: string) {