Diarization fix
This commit is contained in:
13
src/audio.ts
13
src/audio.ts
@@ -141,11 +141,18 @@ print(json.dumps(segments))
|
||||
if(!llm) return transcript;
|
||||
let chunks = this.ai.language.chunk(transcript, 500, 0);
|
||||
if(chunks.length > 4) chunks = [...chunks.slice(0, 3), <string>chunks.at(-1)];
|
||||
const names = await this.ai.language.json(chunks.join('\n'), '{1: "Detected Name", 2: "Second Name"}', {
|
||||
system: 'Use the following transcript to identify speakers. Only identify speakers you are positive about, dont mention speakers you are unsure about in your response',
|
||||
await this.ai.language.ask(chunks.join('\n'), {
|
||||
system: 'Read the following transcript and attempt to identify every speaker. For every positively identified speaker, call the \`identify\` tool with the speaker\'s ID number & the identified name exactly once.',
|
||||
temperature: 0.1,
|
||||
tools: [
|
||||
{name: 'identify', description: 'Identify a speaker', args: {
|
||||
speaker: {type: 'number', description: 'Speaker number', required: true},
|
||||
name: {type: 'string', description: 'Inferred name', required: true},
|
||||
}, fn: ({speaker, name}) => {
|
||||
transcript = transcript.replaceAll(`[Speaker ${speaker}]`, `[${name}]`);
|
||||
}}
|
||||
]
|
||||
});
|
||||
Object.entries(names).forEach(([speaker, name]) => transcript = transcript.replaceAll(`[Speaker ${speaker}]`, `[${name}]`));
|
||||
return transcript;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user