Cap speaker ID transcript length to 2000 tokens
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@ztimson/ai-utils",
|
"name": "@ztimson/ai-utils",
|
||||||
"version": "0.7.0",
|
"version": "0.7.1",
|
||||||
"description": "AI Utility library",
|
"description": "AI Utility library",
|
||||||
"author": "Zak Timson",
|
"author": "Zak Timson",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
|||||||
@@ -40,9 +40,11 @@ export class Audio {
|
|||||||
if(!this.ai.language.defaultModel) throw new Error('Configure an LLM for advanced ASR speaker detection');
|
if(!this.ai.language.defaultModel) throw new Error('Configure an LLM for advanced ASR speaker detection');
|
||||||
p = p.then(async transcript => {
|
p = p.then(async transcript => {
|
||||||
if(!transcript) return transcript;
|
if(!transcript) return transcript;
|
||||||
const names = await this.ai.language.json(transcript, '{1: "Detected Name"}', {
|
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"}', {
|
||||||
system: 'Use this following transcript to identify speakers. Only identify speakers you are sure about',
|
system: 'Use this following transcript to identify speakers. Only identify speakers you are sure about',
|
||||||
temperature: 0.2,
|
temperature: 0.1,
|
||||||
});
|
});
|
||||||
Object.entries(names).forEach(([speaker, name]) => {
|
Object.entries(names).forEach(([speaker, name]) => {
|
||||||
transcript = (<string>transcript).replaceAll(`[Speaker ${speaker}]`, `[${name}]`);
|
transcript = (<string>transcript).replaceAll(`[Speaker ${speaker}]`, `[${name}]`);
|
||||||
|
|||||||
Reference in New Issue
Block a user