Add assembly ai conversion
This commit is contained in:
37
src/assembly-ai/assembly-ai.controller.ts
Normal file
37
src/assembly-ai/assembly-ai.controller.ts
Normal 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}`,
|
||||
);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user