@deepgram/captions
Advanced tools
Comparing version 1.1.1 to 1.2.0
@@ -23,3 +23,22 @@ "use strict"; | ||
else { | ||
content.push(...(0, helpers_1.chunkArray)(results.channels[0].alternatives[0].words, lineLength)); | ||
const words = results.channels[0].alternatives[0].words; | ||
const diarize = "speaker" in words[0]; // was diarization used | ||
let buffer = []; | ||
let currentSpeaker = 0; | ||
words.forEach((word) => { | ||
var _a; | ||
if (diarize && word.speaker !== currentSpeaker) { | ||
content.push(buffer); | ||
buffer = []; | ||
} | ||
if (buffer.length === lineLength) { | ||
content.push(buffer); | ||
buffer = []; | ||
} | ||
if (diarize) { | ||
currentSpeaker = (_a = word.speaker) !== null && _a !== void 0 ? _a : 0; | ||
} | ||
buffer.push(word); | ||
}); | ||
content.push(buffer); | ||
} | ||
@@ -26,0 +45,0 @@ return content; |
@@ -37,2 +37,4 @@ "use strict"; | ||
const lines = data.getLines(lineLength); | ||
// is speaker output required? | ||
const speakerLabels = "speaker" in lines[0][0]; | ||
lines.forEach((words) => { | ||
@@ -42,3 +44,5 @@ const firstWord = words[0]; | ||
output.push(`${(0, helpers_1.secondsToTimestamp)(firstWord.start)} --> ${(0, helpers_1.secondsToTimestamp)(lastWord.end)}`); | ||
output.push(words.map((word) => { var _a; return (_a = word.punctuated_word) !== null && _a !== void 0 ? _a : word.word; }).join(" ")); | ||
const line = words.map((word) => { var _a; return (_a = word.punctuated_word) !== null && _a !== void 0 ? _a : word.word; }).join(" "); | ||
const speakerLabel = speakerLabels ? `<v Speaker ${firstWord.speaker}>` : ""; | ||
output.push(`${speakerLabel}${line}`); | ||
output.push(""); | ||
@@ -51,5 +55,9 @@ }); | ||
const output = []; | ||
const data = parseInput(transcription); | ||
// get the lines | ||
const lines = parseInput(transcription).getLines(lineLength); | ||
let lines = data.getLines(lineLength); | ||
// is speaker output required? | ||
const speakerLabels = "speaker" in lines[0][0]; | ||
let entry = 1; | ||
let currentSpeaker; | ||
lines.forEach((words) => { | ||
@@ -60,4 +68,9 @@ output.push((entry++).toString()); | ||
output.push(`${(0, helpers_1.secondsToTimestamp)(firstWord.start, "HH:mm:ss,SSS")} --> ${(0, helpers_1.secondsToTimestamp)(lastWord.end, "HH:mm:ss,SSS")}`); | ||
output.push(words.map((word) => { var _a; return (_a = word.punctuated_word) !== null && _a !== void 0 ? _a : word.word; }).join(" ")); | ||
const line = words.map((word) => { var _a; return (_a = word.punctuated_word) !== null && _a !== void 0 ? _a : word.word; }).join(" "); | ||
const speakerLabel = speakerLabels && currentSpeaker !== firstWord.speaker | ||
? `[Speaker ${firstWord.speaker}]\n` | ||
: ""; | ||
output.push(`${speakerLabel}${line}`); | ||
output.push(""); | ||
currentSpeaker = firstWord.speaker; | ||
}); | ||
@@ -64,0 +77,0 @@ return output.join("\n"); |
@@ -115,3 +115,3 @@ export interface DeepgramResponse { | ||
end: number; | ||
confidence: number; | ||
confidence?: number; | ||
punctuated_word?: string; | ||
@@ -118,0 +118,0 @@ speaker?: number; |
@@ -1,2 +0,2 @@ | ||
export declare const version = "1.1.1"; | ||
export declare const version = "1.2.0"; | ||
//# sourceMappingURL=version.d.ts.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.version = void 0; | ||
exports.version = "1.1.1"; | ||
exports.version = "1.2.0"; | ||
//# sourceMappingURL=version.js.map |
@@ -20,3 +20,22 @@ import { chunkArray } from "../lib/helpers"; | ||
else { | ||
content.push(...chunkArray(results.channels[0].alternatives[0].words, lineLength)); | ||
const words = results.channels[0].alternatives[0].words; | ||
const diarize = "speaker" in words[0]; // was diarization used | ||
let buffer = []; | ||
let currentSpeaker = 0; | ||
words.forEach((word) => { | ||
var _a; | ||
if (diarize && word.speaker !== currentSpeaker) { | ||
content.push(buffer); | ||
buffer = []; | ||
} | ||
if (buffer.length === lineLength) { | ||
content.push(buffer); | ||
buffer = []; | ||
} | ||
if (diarize) { | ||
currentSpeaker = (_a = word.speaker) !== null && _a !== void 0 ? _a : 0; | ||
} | ||
buffer.push(word); | ||
}); | ||
content.push(buffer); | ||
} | ||
@@ -23,0 +42,0 @@ return content; |
@@ -20,2 +20,4 @@ import { DeepgramConverter, isConverter } from "./converters"; | ||
const lines = data.getLines(lineLength); | ||
// is speaker output required? | ||
const speakerLabels = "speaker" in lines[0][0]; | ||
lines.forEach((words) => { | ||
@@ -25,3 +27,5 @@ const firstWord = words[0]; | ||
output.push(`${secondsToTimestamp(firstWord.start)} --> ${secondsToTimestamp(lastWord.end)}`); | ||
output.push(words.map((word) => { var _a; return (_a = word.punctuated_word) !== null && _a !== void 0 ? _a : word.word; }).join(" ")); | ||
const line = words.map((word) => { var _a; return (_a = word.punctuated_word) !== null && _a !== void 0 ? _a : word.word; }).join(" "); | ||
const speakerLabel = speakerLabels ? `<v Speaker ${firstWord.speaker}>` : ""; | ||
output.push(`${speakerLabel}${line}`); | ||
output.push(""); | ||
@@ -33,5 +37,9 @@ }); | ||
const output = []; | ||
const data = parseInput(transcription); | ||
// get the lines | ||
const lines = parseInput(transcription).getLines(lineLength); | ||
let lines = data.getLines(lineLength); | ||
// is speaker output required? | ||
const speakerLabels = "speaker" in lines[0][0]; | ||
let entry = 1; | ||
let currentSpeaker; | ||
lines.forEach((words) => { | ||
@@ -42,4 +50,9 @@ output.push((entry++).toString()); | ||
output.push(`${secondsToTimestamp(firstWord.start, "HH:mm:ss,SSS")} --> ${secondsToTimestamp(lastWord.end, "HH:mm:ss,SSS")}`); | ||
output.push(words.map((word) => { var _a; return (_a = word.punctuated_word) !== null && _a !== void 0 ? _a : word.word; }).join(" ")); | ||
const line = words.map((word) => { var _a; return (_a = word.punctuated_word) !== null && _a !== void 0 ? _a : word.word; }).join(" "); | ||
const speakerLabel = speakerLabels && currentSpeaker !== firstWord.speaker | ||
? `[Speaker ${firstWord.speaker}]\n` | ||
: ""; | ||
output.push(`${speakerLabel}${line}`); | ||
output.push(""); | ||
currentSpeaker = firstWord.speaker; | ||
}); | ||
@@ -46,0 +59,0 @@ return output.join("\n"); |
@@ -115,3 +115,3 @@ export interface DeepgramResponse { | ||
end: number; | ||
confidence: number; | ||
confidence?: number; | ||
punctuated_word?: string; | ||
@@ -118,0 +118,0 @@ speaker?: number; |
@@ -1,2 +0,2 @@ | ||
export declare const version = "1.1.1"; | ||
export declare const version = "1.2.0"; | ||
//# sourceMappingURL=version.d.ts.map |
@@ -1,2 +0,2 @@ | ||
export const version = "1.1.1"; | ||
export const version = "1.2.0"; | ||
//# sourceMappingURL=version.js.map |
@@ -1,1 +0,1 @@ | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.deepgram=e():t.deepgram=e()}(self,(()=>{return t={484:function(t){t.exports=function(){"use strict";var t=6e4,e=36e5,r="millisecond",n="second",s="minute",i="hour",a="day",u="week",o="month",c="quarter",f="year",h="date",d="Invalid Date",l=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,p=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,v={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(t){var e=["th","st","nd","rd"],r=t%100;return"["+t+(e[(r-20)%10]||e[r]||e[0])+"]"}},$=function(t,e,r){var n=String(t);return!n||n.length>=e?t:""+Array(e+1-n.length).join(r)+t},m={s:$,z:function(t){var e=-t.utcOffset(),r=Math.abs(e),n=Math.floor(r/60),s=r%60;return(e<=0?"+":"-")+$(n,2,"0")+":"+$(s,2,"0")},m:function t(e,r){if(e.date()<r.date())return-t(r,e);var n=12*(r.year()-e.year())+(r.month()-e.month()),s=e.clone().add(n,o),i=r-s<0,a=e.clone().add(n+(i?-1:1),o);return+(-(n+(r-s)/(i?s-a:a-s))||0)},a:function(t){return t<0?Math.ceil(t)||0:Math.floor(t)},p:function(t){return{M:o,y:f,w:u,d:a,D:h,h:i,m:s,s:n,ms:r,Q:c}[t]||String(t||"").toLowerCase().replace(/s$/,"")},u:function(t){return void 0===t}},g="en",D={};D[g]=v;var y="$isDayjsObject",M=function(t){return t instanceof _||!(!t||!t[y])},b=function t(e,r,n){var s;if(!e)return g;if("string"==typeof e){var i=e.toLowerCase();D[i]&&(s=i),r&&(D[i]=r,s=i);var a=e.split("-");if(!s&&a.length>1)return t(a[0])}else{var u=e.name;D[u]=e,s=u}return!n&&s&&(g=s),s||!n&&g},O=function(t,e){if(M(t))return t.clone();var r="object"==typeof e?e:{};return r.date=t,r.args=arguments,new _(r)},S=m;S.l=b,S.i=M,S.w=function(t,e){return O(t,{locale:e.$L,utc:e.$u,x:e.$x,$offset:e.$offset})};var _=function(){function v(t){this.$L=b(t.locale,null,!0),this.parse(t),this.$x=this.$x||t.x||{},this[y]=!0}var $=v.prototype;return $.parse=function(t){this.$d=function(t){var e=t.date,r=t.utc;if(null===e)return new Date(NaN);if(S.u(e))return new Date;if(e instanceof Date)return new Date(e);if("string"==typeof e&&!/Z$/i.test(e)){var n=e.match(l);if(n){var s=n[2]-1||0,i=(n[7]||"0").substring(0,3);return r?new Date(Date.UTC(n[1],s,n[3]||1,n[4]||0,n[5]||0,n[6]||0,i)):new Date(n[1],s,n[3]||1,n[4]||0,n[5]||0,n[6]||0,i)}}return new Date(e)}(t),this.init()},$.init=function(){var t=this.$d;this.$y=t.getFullYear(),this.$M=t.getMonth(),this.$D=t.getDate(),this.$W=t.getDay(),this.$H=t.getHours(),this.$m=t.getMinutes(),this.$s=t.getSeconds(),this.$ms=t.getMilliseconds()},$.$utils=function(){return S},$.isValid=function(){return!(this.$d.toString()===d)},$.isSame=function(t,e){var r=O(t);return this.startOf(e)<=r&&r<=this.endOf(e)},$.isAfter=function(t,e){return O(t)<this.startOf(e)},$.isBefore=function(t,e){return this.endOf(e)<O(t)},$.$g=function(t,e,r){return S.u(t)?this[e]:this.set(r,t)},$.unix=function(){return Math.floor(this.valueOf()/1e3)},$.valueOf=function(){return this.$d.getTime()},$.startOf=function(t,e){var r=this,c=!!S.u(e)||e,d=S.p(t),l=function(t,e){var n=S.w(r.$u?Date.UTC(r.$y,e,t):new Date(r.$y,e,t),r);return c?n:n.endOf(a)},p=function(t,e){return S.w(r.toDate()[t].apply(r.toDate("s"),(c?[0,0,0,0]:[23,59,59,999]).slice(e)),r)},v=this.$W,$=this.$M,m=this.$D,g="set"+(this.$u?"UTC":"");switch(d){case f:return c?l(1,0):l(31,11);case o:return c?l(1,$):l(0,$+1);case u:var D=this.$locale().weekStart||0,y=(v<D?v+7:v)-D;return l(c?m-y:m+(6-y),$);case a:case h:return p(g+"Hours",0);case i:return p(g+"Minutes",1);case s:return p(g+"Seconds",2);case n:return p(g+"Milliseconds",3);default:return this.clone()}},$.endOf=function(t){return this.startOf(t,!1)},$.$set=function(t,e){var u,c=S.p(t),d="set"+(this.$u?"UTC":""),l=(u={},u[a]=d+"Date",u[h]=d+"Date",u[o]=d+"Month",u[f]=d+"FullYear",u[i]=d+"Hours",u[s]=d+"Minutes",u[n]=d+"Seconds",u[r]=d+"Milliseconds",u)[c],p=c===a?this.$D+(e-this.$W):e;if(c===o||c===f){var v=this.clone().set(h,1);v.$d[l](p),v.init(),this.$d=v.set(h,Math.min(this.$D,v.daysInMonth())).$d}else l&&this.$d[l](p);return this.init(),this},$.set=function(t,e){return this.clone().$set(t,e)},$.get=function(t){return this[S.p(t)]()},$.add=function(r,c){var h,d=this;r=Number(r);var l=S.p(c),p=function(t){var e=O(d);return S.w(e.date(e.date()+Math.round(t*r)),d)};if(l===o)return this.set(o,this.$M+r);if(l===f)return this.set(f,this.$y+r);if(l===a)return p(1);if(l===u)return p(7);var v=(h={},h[s]=t,h[i]=e,h[n]=1e3,h)[l]||1,$=this.$d.getTime()+r*v;return S.w($,this)},$.subtract=function(t,e){return this.add(-1*t,e)},$.format=function(t){var e=this,r=this.$locale();if(!this.isValid())return r.invalidDate||d;var n=t||"YYYY-MM-DDTHH:mm:ssZ",s=S.z(this),i=this.$H,a=this.$m,u=this.$M,o=r.weekdays,c=r.months,f=r.meridiem,h=function(t,r,s,i){return t&&(t[r]||t(e,n))||s[r].slice(0,i)},l=function(t){return S.s(i%12||12,t,"0")},v=f||function(t,e,r){var n=t<12?"AM":"PM";return r?n.toLowerCase():n};return n.replace(p,(function(t,n){return n||function(t){switch(t){case"YY":return String(e.$y).slice(-2);case"YYYY":return S.s(e.$y,4,"0");case"M":return u+1;case"MM":return S.s(u+1,2,"0");case"MMM":return h(r.monthsShort,u,c,3);case"MMMM":return h(c,u);case"D":return e.$D;case"DD":return S.s(e.$D,2,"0");case"d":return String(e.$W);case"dd":return h(r.weekdaysMin,e.$W,o,2);case"ddd":return h(r.weekdaysShort,e.$W,o,3);case"dddd":return o[e.$W];case"H":return String(i);case"HH":return S.s(i,2,"0");case"h":return l(1);case"hh":return l(2);case"a":return v(i,a,!0);case"A":return v(i,a,!1);case"m":return String(a);case"mm":return S.s(a,2,"0");case"s":return String(e.$s);case"ss":return S.s(e.$s,2,"0");case"SSS":return S.s(e.$ms,3,"0");case"Z":return s}return null}(t)||s.replace(":","")}))},$.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},$.diff=function(r,h,d){var l,p=this,v=S.p(h),$=O(r),m=($.utcOffset()-this.utcOffset())*t,g=this-$,D=function(){return S.m(p,$)};switch(v){case f:l=D()/12;break;case o:l=D();break;case c:l=D()/3;break;case u:l=(g-m)/6048e5;break;case a:l=(g-m)/864e5;break;case i:l=g/e;break;case s:l=g/t;break;case n:l=g/1e3;break;default:l=g}return d?l:S.a(l)},$.daysInMonth=function(){return this.endOf(o).$D},$.$locale=function(){return D[this.$L]},$.locale=function(t,e){if(!t)return this.$L;var r=this.clone(),n=b(t,e,!0);return n&&(r.$L=n),r},$.clone=function(){return S.w(this.$d,this)},$.toDate=function(){return new Date(this.valueOf())},$.toJSON=function(){return this.isValid()?this.toISOString():null},$.toISOString=function(){return this.$d.toISOString()},$.toString=function(){return this.$d.toUTCString()},v}(),w=_.prototype;return O.prototype=w,[["$ms",r],["$s",n],["$m",s],["$H",i],["$W",a],["$M",o],["$y",f],["$D",h]].forEach((function(t){w[t[1]]=function(e){return this.$g(e,t[0],t[1])}})),O.extend=function(t,e){return t.$i||(t(e,_,O),t.$i=!0),O},O.locale=b,O.isDayjs=M,O.unix=function(t){return O(1e3*t)},O.en=D[g],O.Ls=D,O.p={},O}()},178:function(t){t.exports=function(){"use strict";var t="minute",e=/[+-]\d\d(?::?\d\d)?/g,r=/([+-]|\d\d)/g;return function(n,s,i){var a=s.prototype;i.utc=function(t){return new s({date:t,utc:!0,args:arguments})},a.utc=function(e){var r=i(this.toDate(),{locale:this.$L,utc:!0});return e?r.add(this.utcOffset(),t):r},a.local=function(){return i(this.toDate(),{locale:this.$L,utc:!1})};var u=a.parse;a.parse=function(t){t.utc&&(this.$u=!0),this.$utils().u(t.$offset)||(this.$offset=t.$offset),u.call(this,t)};var o=a.init;a.init=function(){if(this.$u){var t=this.$d;this.$y=t.getUTCFullYear(),this.$M=t.getUTCMonth(),this.$D=t.getUTCDate(),this.$W=t.getUTCDay(),this.$H=t.getUTCHours(),this.$m=t.getUTCMinutes(),this.$s=t.getUTCSeconds(),this.$ms=t.getUTCMilliseconds()}else o.call(this)};var c=a.utcOffset;a.utcOffset=function(n,s){var i=this.$utils().u;if(i(n))return this.$u?0:i(this.$offset)?c.call(this):this.$offset;if("string"==typeof n&&(n=function(t){void 0===t&&(t="");var n=t.match(e);if(!n)return null;var s=(""+n[0]).match(r)||["-",0,0],i=s[0],a=60*+s[1]+ +s[2];return 0===a?0:"+"===i?a:-a}(n),null===n))return this;var a=Math.abs(n)<=16?60*n:n,u=this;if(s)return u.$offset=a,u.$u=0===n,u;if(0!==n){var o=this.$u?this.toDate().getTimezoneOffset():-1*this.utcOffset();(u=this.local().add(a+o,t)).$offset=a,u.$x.$localOffset=o}else u=this.utc();return u};var f=a.format;a.format=function(t){var e=t||(this.$u?"YYYY-MM-DDTHH:mm:ss[Z]":"");return f.call(this,e)},a.valueOf=function(){var t=this.$utils().u(this.$offset)?0:this.$offset+(this.$x.$localOffset||this.$d.getTimezoneOffset());return this.$d.valueOf()-6e4*t},a.isUTC=function(){return!!this.$u},a.toISOString=function(){return this.toDate().toISOString()},a.toString=function(){return this.toDate().toUTCString()};var h=a.toDate;a.toDate=function(t){return"s"===t&&this.$offset?i(this.format("YYYY-MM-DD HH:mm:ss:SSS")).toDate():h.call(this)};var d=a.diff;a.diff=function(t,e,r){if(t&&this.$u===t.$u)return d.call(this,t,e,r);var n=this.local(),s=i(t).local();return d.call(n,s,e,r)}}}()},148:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.AssemblyAiConverter=void 0;const n=r(610),s=t=>({word:t.text,start:t.start,end:t.end,confidence:t.confidence,punctuated_word:t.text,speaker:t.speaker});e.AssemblyAiConverter=class{constructor(t){this.transcriptionData=t}getLines(t=8){const e=this.transcriptionData;let r=[];return e.utterances?e.utterances.forEach((e=>{e.words.length>t?r.push(...(0,n.chunkArray)(e.words.map((t=>s(t))),t)):r.push(e.words.map((t=>s(t))))})):r.push(...(0,n.chunkArray)(e.words.map((t=>s(t))),t)),r}getHeaders(){const t=[];return t.push("NOTE"),t.push("Transcription provided by Assembly AI"),this.transcriptionData.id&&t.push(`Id: ${this.transcriptionData.id}`),this.transcriptionData.audio_duration&&t.push(`Duration: ${this.transcriptionData.audio_duration}`),t}}},99:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.DeepgramConverter=void 0;const n=r(610);e.DeepgramConverter=class{constructor(t){this.transcriptionData=t}getLines(t=8){const{results:e}=this.transcriptionData;let r=[];return e.utterances?e.utterances.forEach((e=>{e.words.length>t?r.push(...(0,n.chunkArray)(e.words,t)):r.push(e.words)})):r.push(...(0,n.chunkArray)(e.channels[0].alternatives[0].words,t)),r}getHeaders(){var t,e,r,n,s,i,a,u;const o=[];return o.push("NOTE"),o.push("Transcription provided by Deepgram"),(null===(t=this.transcriptionData.metadata)||void 0===t?void 0:t.request_id)&&o.push(`Request Id: ${null===(e=this.transcriptionData.metadata)||void 0===e?void 0:e.request_id}`),(null===(r=this.transcriptionData.metadata)||void 0===r?void 0:r.created)&&o.push(`Created: ${null===(n=this.transcriptionData.metadata)||void 0===n?void 0:n.created}`),(null===(s=this.transcriptionData.metadata)||void 0===s?void 0:s.duration)&&o.push(`Duration: ${null===(i=this.transcriptionData.metadata)||void 0===i?void 0:i.duration}`),(null===(a=this.transcriptionData.metadata)||void 0===a?void 0:a.channels)&&o.push(`Channels: ${null===(u=this.transcriptionData.metadata)||void 0===u?void 0:u.channels}`),o}}},730:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.isConverter=void 0,e.isConverter=function(t){return"transcriptionData"in t}},550:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.isConverter=e.IConverter=e.AssemblyAiConverter=e.DeepgramConverter=void 0;var n=r(99);Object.defineProperty(e,"DeepgramConverter",{enumerable:!0,get:function(){return n.DeepgramConverter}});var s=r(148);Object.defineProperty(e,"AssemblyAiConverter",{enumerable:!0,get:function(){return s.AssemblyAiConverter}});var i=r(730);Object.defineProperty(e,"IConverter",{enumerable:!0,get:function(){return i.IConverter}}),Object.defineProperty(e,"isConverter",{enumerable:!0,get:function(){return i.isConverter}})},341:function(t,e,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r);var s=Object.getOwnPropertyDescriptor(e,r);s&&!("get"in s?!e.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,s)}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),s=this&&this.__exportStar||function(t,e){for(var r in t)"default"===r||Object.prototype.hasOwnProperty.call(e,r)||n(e,t,r)};Object.defineProperty(e,"__esModule",{value:!0}),e.srt=e.webvtt=void 0;const i=r(550),a=r(610),u=t=>(0,i.isConverter)(t)?t:new i.DeepgramConverter(t);e.webvtt=(t,e=8)=>{const r=[];let n=u(t);return r.push("WEBVTT"),r.push(""),n.getHeaders&&r.push(n.getHeaders().join("\n")),n.getHeaders&&r.push(""),n.getLines(e).forEach((t=>{const e=t[0],n=t[t.length-1];r.push(`${(0,a.secondsToTimestamp)(e.start)} --\x3e ${(0,a.secondsToTimestamp)(n.end)}`),r.push(t.map((t=>{var e;return null!==(e=t.punctuated_word)&&void 0!==e?e:t.word})).join(" ")),r.push("")})),r.join("\n")},e.srt=(t,e=8)=>{const r=[],n=u(t).getLines(e);let s=1;return n.forEach((t=>{r.push((s++).toString());const e=t[0],n=t[t.length-1];r.push(`${(0,a.secondsToTimestamp)(e.start,"HH:mm:ss,SSS")} --\x3e ${(0,a.secondsToTimestamp)(n.end,"HH:mm:ss,SSS")}`),r.push(t.map((t=>{var e;return null!==(e=t.punctuated_word)&&void 0!==e?e:t.word})).join(" ")),r.push("")})),r.join("\n")},s(r(550),e),s(r(717),e),s(r(610),e)},610:function(t,e,r){"use strict";var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.chunkArray=e.secondsToTimestamp=void 0;const s=n(r(484)),i=n(r(178));s.default.extend(i.default),e.secondsToTimestamp=function(t,e="HH:mm:ss.SSS"){return(0,s.default)(1e3*t).utc().format(e)},e.chunkArray=function(t,e){const r=[];for(let n=0;n<t.length;n+=e){const s=t.slice(n,n+e);r.push(s)}return r}},717:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0})}},e={},function r(n){var s=e[n];if(void 0!==s)return s.exports;var i=e[n]={exports:{}};return t[n].call(i.exports,i,i.exports,r),i.exports}(341);var t,e})); | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.deepgram=e():t.deepgram=e()}(self,(()=>{return t={484:function(t){t.exports=function(){"use strict";var t=6e4,e=36e5,r="millisecond",n="second",s="minute",i="hour",a="day",u="week",o="month",c="quarter",f="year",h="date",d="Invalid Date",l=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,p=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,$={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(t){var e=["th","st","nd","rd"],r=t%100;return"["+t+(e[(r-20)%10]||e[r]||e[0])+"]"}},v=function(t,e,r){var n=String(t);return!n||n.length>=e?t:""+Array(e+1-n.length).join(r)+t},m={s:v,z:function(t){var e=-t.utcOffset(),r=Math.abs(e),n=Math.floor(r/60),s=r%60;return(e<=0?"+":"-")+v(n,2,"0")+":"+v(s,2,"0")},m:function t(e,r){if(e.date()<r.date())return-t(r,e);var n=12*(r.year()-e.year())+(r.month()-e.month()),s=e.clone().add(n,o),i=r-s<0,a=e.clone().add(n+(i?-1:1),o);return+(-(n+(r-s)/(i?s-a:a-s))||0)},a:function(t){return t<0?Math.ceil(t)||0:Math.floor(t)},p:function(t){return{M:o,y:f,w:u,d:a,D:h,h:i,m:s,s:n,ms:r,Q:c}[t]||String(t||"").toLowerCase().replace(/s$/,"")},u:function(t){return void 0===t}},g="en",D={};D[g]=$;var y="$isDayjsObject",M=function(t){return t instanceof _||!(!t||!t[y])},S=function t(e,r,n){var s;if(!e)return g;if("string"==typeof e){var i=e.toLowerCase();D[i]&&(s=i),r&&(D[i]=r,s=i);var a=e.split("-");if(!s&&a.length>1)return t(a[0])}else{var u=e.name;D[u]=e,s=u}return!n&&s&&(g=s),s||!n&&g},b=function(t,e){if(M(t))return t.clone();var r="object"==typeof e?e:{};return r.date=t,r.args=arguments,new _(r)},O=m;O.l=S,O.i=M,O.w=function(t,e){return b(t,{locale:e.$L,utc:e.$u,x:e.$x,$offset:e.$offset})};var _=function(){function $(t){this.$L=S(t.locale,null,!0),this.parse(t),this.$x=this.$x||t.x||{},this[y]=!0}var v=$.prototype;return v.parse=function(t){this.$d=function(t){var e=t.date,r=t.utc;if(null===e)return new Date(NaN);if(O.u(e))return new Date;if(e instanceof Date)return new Date(e);if("string"==typeof e&&!/Z$/i.test(e)){var n=e.match(l);if(n){var s=n[2]-1||0,i=(n[7]||"0").substring(0,3);return r?new Date(Date.UTC(n[1],s,n[3]||1,n[4]||0,n[5]||0,n[6]||0,i)):new Date(n[1],s,n[3]||1,n[4]||0,n[5]||0,n[6]||0,i)}}return new Date(e)}(t),this.init()},v.init=function(){var t=this.$d;this.$y=t.getFullYear(),this.$M=t.getMonth(),this.$D=t.getDate(),this.$W=t.getDay(),this.$H=t.getHours(),this.$m=t.getMinutes(),this.$s=t.getSeconds(),this.$ms=t.getMilliseconds()},v.$utils=function(){return O},v.isValid=function(){return!(this.$d.toString()===d)},v.isSame=function(t,e){var r=b(t);return this.startOf(e)<=r&&r<=this.endOf(e)},v.isAfter=function(t,e){return b(t)<this.startOf(e)},v.isBefore=function(t,e){return this.endOf(e)<b(t)},v.$g=function(t,e,r){return O.u(t)?this[e]:this.set(r,t)},v.unix=function(){return Math.floor(this.valueOf()/1e3)},v.valueOf=function(){return this.$d.getTime()},v.startOf=function(t,e){var r=this,c=!!O.u(e)||e,d=O.p(t),l=function(t,e){var n=O.w(r.$u?Date.UTC(r.$y,e,t):new Date(r.$y,e,t),r);return c?n:n.endOf(a)},p=function(t,e){return O.w(r.toDate()[t].apply(r.toDate("s"),(c?[0,0,0,0]:[23,59,59,999]).slice(e)),r)},$=this.$W,v=this.$M,m=this.$D,g="set"+(this.$u?"UTC":"");switch(d){case f:return c?l(1,0):l(31,11);case o:return c?l(1,v):l(0,v+1);case u:var D=this.$locale().weekStart||0,y=($<D?$+7:$)-D;return l(c?m-y:m+(6-y),v);case a:case h:return p(g+"Hours",0);case i:return p(g+"Minutes",1);case s:return p(g+"Seconds",2);case n:return p(g+"Milliseconds",3);default:return this.clone()}},v.endOf=function(t){return this.startOf(t,!1)},v.$set=function(t,e){var u,c=O.p(t),d="set"+(this.$u?"UTC":""),l=(u={},u[a]=d+"Date",u[h]=d+"Date",u[o]=d+"Month",u[f]=d+"FullYear",u[i]=d+"Hours",u[s]=d+"Minutes",u[n]=d+"Seconds",u[r]=d+"Milliseconds",u)[c],p=c===a?this.$D+(e-this.$W):e;if(c===o||c===f){var $=this.clone().set(h,1);$.$d[l](p),$.init(),this.$d=$.set(h,Math.min(this.$D,$.daysInMonth())).$d}else l&&this.$d[l](p);return this.init(),this},v.set=function(t,e){return this.clone().$set(t,e)},v.get=function(t){return this[O.p(t)]()},v.add=function(r,c){var h,d=this;r=Number(r);var l=O.p(c),p=function(t){var e=b(d);return O.w(e.date(e.date()+Math.round(t*r)),d)};if(l===o)return this.set(o,this.$M+r);if(l===f)return this.set(f,this.$y+r);if(l===a)return p(1);if(l===u)return p(7);var $=(h={},h[s]=t,h[i]=e,h[n]=1e3,h)[l]||1,v=this.$d.getTime()+r*$;return O.w(v,this)},v.subtract=function(t,e){return this.add(-1*t,e)},v.format=function(t){var e=this,r=this.$locale();if(!this.isValid())return r.invalidDate||d;var n=t||"YYYY-MM-DDTHH:mm:ssZ",s=O.z(this),i=this.$H,a=this.$m,u=this.$M,o=r.weekdays,c=r.months,f=r.meridiem,h=function(t,r,s,i){return t&&(t[r]||t(e,n))||s[r].slice(0,i)},l=function(t){return O.s(i%12||12,t,"0")},$=f||function(t,e,r){var n=t<12?"AM":"PM";return r?n.toLowerCase():n};return n.replace(p,(function(t,n){return n||function(t){switch(t){case"YY":return String(e.$y).slice(-2);case"YYYY":return O.s(e.$y,4,"0");case"M":return u+1;case"MM":return O.s(u+1,2,"0");case"MMM":return h(r.monthsShort,u,c,3);case"MMMM":return h(c,u);case"D":return e.$D;case"DD":return O.s(e.$D,2,"0");case"d":return String(e.$W);case"dd":return h(r.weekdaysMin,e.$W,o,2);case"ddd":return h(r.weekdaysShort,e.$W,o,3);case"dddd":return o[e.$W];case"H":return String(i);case"HH":return O.s(i,2,"0");case"h":return l(1);case"hh":return l(2);case"a":return $(i,a,!0);case"A":return $(i,a,!1);case"m":return String(a);case"mm":return O.s(a,2,"0");case"s":return String(e.$s);case"ss":return O.s(e.$s,2,"0");case"SSS":return O.s(e.$ms,3,"0");case"Z":return s}return null}(t)||s.replace(":","")}))},v.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},v.diff=function(r,h,d){var l,p=this,$=O.p(h),v=b(r),m=(v.utcOffset()-this.utcOffset())*t,g=this-v,D=function(){return O.m(p,v)};switch($){case f:l=D()/12;break;case o:l=D();break;case c:l=D()/3;break;case u:l=(g-m)/6048e5;break;case a:l=(g-m)/864e5;break;case i:l=g/e;break;case s:l=g/t;break;case n:l=g/1e3;break;default:l=g}return d?l:O.a(l)},v.daysInMonth=function(){return this.endOf(o).$D},v.$locale=function(){return D[this.$L]},v.locale=function(t,e){if(!t)return this.$L;var r=this.clone(),n=S(t,e,!0);return n&&(r.$L=n),r},v.clone=function(){return O.w(this.$d,this)},v.toDate=function(){return new Date(this.valueOf())},v.toJSON=function(){return this.isValid()?this.toISOString():null},v.toISOString=function(){return this.$d.toISOString()},v.toString=function(){return this.$d.toUTCString()},$}(),w=_.prototype;return b.prototype=w,[["$ms",r],["$s",n],["$m",s],["$H",i],["$W",a],["$M",o],["$y",f],["$D",h]].forEach((function(t){w[t[1]]=function(e){return this.$g(e,t[0],t[1])}})),b.extend=function(t,e){return t.$i||(t(e,_,b),t.$i=!0),b},b.locale=S,b.isDayjs=M,b.unix=function(t){return b(1e3*t)},b.en=D[g],b.Ls=D,b.p={},b}()},178:function(t){t.exports=function(){"use strict";var t="minute",e=/[+-]\d\d(?::?\d\d)?/g,r=/([+-]|\d\d)/g;return function(n,s,i){var a=s.prototype;i.utc=function(t){return new s({date:t,utc:!0,args:arguments})},a.utc=function(e){var r=i(this.toDate(),{locale:this.$L,utc:!0});return e?r.add(this.utcOffset(),t):r},a.local=function(){return i(this.toDate(),{locale:this.$L,utc:!1})};var u=a.parse;a.parse=function(t){t.utc&&(this.$u=!0),this.$utils().u(t.$offset)||(this.$offset=t.$offset),u.call(this,t)};var o=a.init;a.init=function(){if(this.$u){var t=this.$d;this.$y=t.getUTCFullYear(),this.$M=t.getUTCMonth(),this.$D=t.getUTCDate(),this.$W=t.getUTCDay(),this.$H=t.getUTCHours(),this.$m=t.getUTCMinutes(),this.$s=t.getUTCSeconds(),this.$ms=t.getUTCMilliseconds()}else o.call(this)};var c=a.utcOffset;a.utcOffset=function(n,s){var i=this.$utils().u;if(i(n))return this.$u?0:i(this.$offset)?c.call(this):this.$offset;if("string"==typeof n&&(n=function(t){void 0===t&&(t="");var n=t.match(e);if(!n)return null;var s=(""+n[0]).match(r)||["-",0,0],i=s[0],a=60*+s[1]+ +s[2];return 0===a?0:"+"===i?a:-a}(n),null===n))return this;var a=Math.abs(n)<=16?60*n:n,u=this;if(s)return u.$offset=a,u.$u=0===n,u;if(0!==n){var o=this.$u?this.toDate().getTimezoneOffset():-1*this.utcOffset();(u=this.local().add(a+o,t)).$offset=a,u.$x.$localOffset=o}else u=this.utc();return u};var f=a.format;a.format=function(t){var e=t||(this.$u?"YYYY-MM-DDTHH:mm:ss[Z]":"");return f.call(this,e)},a.valueOf=function(){var t=this.$utils().u(this.$offset)?0:this.$offset+(this.$x.$localOffset||this.$d.getTimezoneOffset());return this.$d.valueOf()-6e4*t},a.isUTC=function(){return!!this.$u},a.toISOString=function(){return this.toDate().toISOString()},a.toString=function(){return this.toDate().toUTCString()};var h=a.toDate;a.toDate=function(t){return"s"===t&&this.$offset?i(this.format("YYYY-MM-DD HH:mm:ss:SSS")).toDate():h.call(this)};var d=a.diff;a.diff=function(t,e,r){if(t&&this.$u===t.$u)return d.call(this,t,e,r);var n=this.local(),s=i(t).local();return d.call(n,s,e,r)}}}()},148:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.AssemblyAiConverter=void 0;const n=r(610),s=t=>({word:t.text,start:t.start,end:t.end,confidence:t.confidence,punctuated_word:t.text,speaker:t.speaker});e.AssemblyAiConverter=class{constructor(t){this.transcriptionData=t}getLines(t=8){const e=this.transcriptionData;let r=[];return e.utterances?e.utterances.forEach((e=>{e.words.length>t?r.push(...(0,n.chunkArray)(e.words.map((t=>s(t))),t)):r.push(e.words.map((t=>s(t))))})):r.push(...(0,n.chunkArray)(e.words.map((t=>s(t))),t)),r}getHeaders(){const t=[];return t.push("NOTE"),t.push("Transcription provided by Assembly AI"),this.transcriptionData.id&&t.push(`Id: ${this.transcriptionData.id}`),this.transcriptionData.audio_duration&&t.push(`Duration: ${this.transcriptionData.audio_duration}`),t}}},99:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.DeepgramConverter=void 0;const n=r(610);e.DeepgramConverter=class{constructor(t){this.transcriptionData=t}getLines(t=8){const{results:e}=this.transcriptionData;let r=[];if(e.utterances)e.utterances.forEach((e=>{e.words.length>t?r.push(...(0,n.chunkArray)(e.words,t)):r.push(e.words)}));else{const n=e.channels[0].alternatives[0].words,s="speaker"in n[0];let i=[],a=0;n.forEach((e=>{var n;s&&e.speaker!==a&&(r.push(i),i=[]),i.length===t&&(r.push(i),i=[]),s&&(a=null!==(n=e.speaker)&&void 0!==n?n:0),i.push(e)})),r.push(i)}return r}getHeaders(){var t,e,r,n,s,i,a,u;const o=[];return o.push("NOTE"),o.push("Transcription provided by Deepgram"),(null===(t=this.transcriptionData.metadata)||void 0===t?void 0:t.request_id)&&o.push(`Request Id: ${null===(e=this.transcriptionData.metadata)||void 0===e?void 0:e.request_id}`),(null===(r=this.transcriptionData.metadata)||void 0===r?void 0:r.created)&&o.push(`Created: ${null===(n=this.transcriptionData.metadata)||void 0===n?void 0:n.created}`),(null===(s=this.transcriptionData.metadata)||void 0===s?void 0:s.duration)&&o.push(`Duration: ${null===(i=this.transcriptionData.metadata)||void 0===i?void 0:i.duration}`),(null===(a=this.transcriptionData.metadata)||void 0===a?void 0:a.channels)&&o.push(`Channels: ${null===(u=this.transcriptionData.metadata)||void 0===u?void 0:u.channels}`),o}}},730:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.isConverter=void 0,e.isConverter=function(t){return"transcriptionData"in t}},550:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.isConverter=e.IConverter=e.AssemblyAiConverter=e.DeepgramConverter=void 0;var n=r(99);Object.defineProperty(e,"DeepgramConverter",{enumerable:!0,get:function(){return n.DeepgramConverter}});var s=r(148);Object.defineProperty(e,"AssemblyAiConverter",{enumerable:!0,get:function(){return s.AssemblyAiConverter}});var i=r(730);Object.defineProperty(e,"IConverter",{enumerable:!0,get:function(){return i.IConverter}}),Object.defineProperty(e,"isConverter",{enumerable:!0,get:function(){return i.isConverter}})},341:function(t,e,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r);var s=Object.getOwnPropertyDescriptor(e,r);s&&!("get"in s?!e.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,s)}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),s=this&&this.__exportStar||function(t,e){for(var r in t)"default"===r||Object.prototype.hasOwnProperty.call(e,r)||n(e,t,r)};Object.defineProperty(e,"__esModule",{value:!0}),e.srt=e.webvtt=void 0;const i=r(550),a=r(610),u=t=>(0,i.isConverter)(t)?t:new i.DeepgramConverter(t);e.webvtt=(t,e=8)=>{const r=[];let n=u(t);r.push("WEBVTT"),r.push(""),n.getHeaders&&r.push(n.getHeaders().join("\n")),n.getHeaders&&r.push("");const s=n.getLines(e),i="speaker"in s[0][0];return s.forEach((t=>{const e=t[0],n=t[t.length-1];r.push(`${(0,a.secondsToTimestamp)(e.start)} --\x3e ${(0,a.secondsToTimestamp)(n.end)}`);const s=t.map((t=>{var e;return null!==(e=t.punctuated_word)&&void 0!==e?e:t.word})).join(" "),u=i?`<v Speaker ${e.speaker}>`:"";r.push(`${u}${s}`),r.push("")})),r.join("\n")},e.srt=(t,e=8)=>{const r=[];let n=u(t).getLines(e);const s="speaker"in n[0][0];let i,o=1;return n.forEach((t=>{r.push((o++).toString());const e=t[0],n=t[t.length-1];r.push(`${(0,a.secondsToTimestamp)(e.start,"HH:mm:ss,SSS")} --\x3e ${(0,a.secondsToTimestamp)(n.end,"HH:mm:ss,SSS")}`);const u=t.map((t=>{var e;return null!==(e=t.punctuated_word)&&void 0!==e?e:t.word})).join(" "),c=s&&i!==e.speaker?`[Speaker ${e.speaker}]\n`:"";r.push(`${c}${u}`),r.push(""),i=e.speaker})),r.join("\n")},s(r(550),e),s(r(717),e),s(r(610),e)},610:function(t,e,r){"use strict";var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.chunkArray=e.secondsToTimestamp=void 0;const s=n(r(484)),i=n(r(178));s.default.extend(i.default),e.secondsToTimestamp=function(t,e="HH:mm:ss.SSS"){return(0,s.default)(1e3*t).utc().format(e)},e.chunkArray=function(t,e){const r=[];for(let n=0;n<t.length;n+=e){const s=t.slice(n,n+e);r.push(s)}return r}},717:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0})}},e={},function r(n){var s=e[n];if(void 0!==s)return s.exports;var i=e[n]={exports:{}};return t[n].call(i.exports,i,i.exports,r),i.exports}(341);var t,e})); |
{ | ||
"name": "@deepgram/captions", | ||
"version": "1.1.1", | ||
"version": "1.2.0", | ||
"description": "Node implementation of Deepgram's WebVTT and SRT formatting. Given a transcription, this package can return a valid string to store as WebVTT or SRT caption files.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -21,3 +21,27 @@ import { chunkArray } from "../lib/helpers"; | ||
} else { | ||
content.push(...chunkArray(results.channels[0].alternatives[0].words, lineLength)); | ||
const words = results.channels[0].alternatives[0].words; | ||
const diarize = "speaker" in words[0]; // was diarization used | ||
let buffer: WordBase[] = []; | ||
let currentSpeaker = 0; | ||
words.forEach((word) => { | ||
if (diarize && word.speaker !== currentSpeaker) { | ||
content.push(buffer); | ||
buffer = []; | ||
} | ||
if (buffer.length === lineLength) { | ||
content.push(buffer); | ||
buffer = []; | ||
} | ||
if (diarize) { | ||
currentSpeaker = word.speaker ?? 0; | ||
} | ||
buffer.push(word); | ||
}); | ||
content.push(buffer); | ||
} | ||
@@ -24,0 +48,0 @@ |
import { DeepgramConverter, IConverter, isConverter } from "./converters"; | ||
import { secondsToTimestamp } from "./lib/helpers"; | ||
import { chunkArray, secondsToTimestamp } from "./lib/helpers"; | ||
import { DeepgramResponse } from "./lib/types"; | ||
@@ -29,2 +29,5 @@ | ||
// is speaker output required? | ||
const speakerLabels = "speaker" in lines[0][0]; | ||
lines.forEach((words) => { | ||
@@ -35,3 +38,7 @@ const firstWord = words[0]; | ||
output.push(`${secondsToTimestamp(firstWord.start)} --> ${secondsToTimestamp(lastWord.end)}`); | ||
output.push(words.map((word) => word.punctuated_word ?? word.word).join(" ")); | ||
const line = words.map((word) => word.punctuated_word ?? word.word).join(" "); | ||
const speakerLabel = speakerLabels ? `<v Speaker ${firstWord.speaker}>` : ""; | ||
output.push(`${speakerLabel}${line}`); | ||
output.push(""); | ||
@@ -46,5 +53,12 @@ }); | ||
const data = parseInput(transcription); | ||
// get the lines | ||
const lines = parseInput(transcription).getLines(lineLength); | ||
let lines = data.getLines(lineLength); | ||
// is speaker output required? | ||
const speakerLabels = "speaker" in lines[0][0]; | ||
let entry = 1; | ||
let currentSpeaker: any; | ||
@@ -63,4 +77,13 @@ lines.forEach((words) => { | ||
); | ||
output.push(words.map((word) => word.punctuated_word ?? word.word).join(" ")); | ||
const line = words.map((word) => word.punctuated_word ?? word.word).join(" "); | ||
const speakerLabel = | ||
speakerLabels && currentSpeaker !== firstWord.speaker | ||
? `[Speaker ${firstWord.speaker}]\n` | ||
: ""; | ||
output.push(`${speakerLabel}${line}`); | ||
output.push(""); | ||
currentSpeaker = firstWord.speaker; | ||
}); | ||
@@ -67,0 +90,0 @@ |
@@ -133,3 +133,3 @@ export interface DeepgramResponse { | ||
end: number; | ||
confidence: number; | ||
confidence?: number; | ||
punctuated_word?: string; | ||
@@ -136,0 +136,0 @@ speaker?: number; |
@@ -1,1 +0,1 @@ | ||
export const version = "1.1.1"; | ||
export const version = "1.2.0"; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
86067
1076