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;
|
if(!llm) return transcript;
|
||||||
let chunks = this.ai.language.chunk(transcript, 500, 0);
|
let chunks = this.ai.language.chunk(transcript, 500, 0);
|
||||||
if(chunks.length > 4) chunks = [...chunks.slice(0, 3), <string>chunks.at(-1)];
|
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"}', {
|
await this.ai.language.ask(chunks.join('\n'), {
|
||||||
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',
|
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,
|
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;
|
return transcript;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user