Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@deepgram/captions

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@deepgram/captions - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

dist/main/converters/AssemblyAiConverter.d.ts

1

dist/main/converters/index.d.ts
export { DeepgramConverter } from "./DeepgramConverter";
export { AssemblyAiConverter } from "./AssemblyAiConverter";
export { IConverter, isConverter } from "./IConverter";
//# sourceMappingURL=index.d.ts.map

4

dist/main/converters/index.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isConverter = exports.DeepgramConverter = void 0;
exports.isConverter = exports.AssemblyAiConverter = exports.DeepgramConverter = void 0;
var DeepgramConverter_1 = require("./DeepgramConverter");
Object.defineProperty(exports, "DeepgramConverter", { enumerable: true, get: function () { return DeepgramConverter_1.DeepgramConverter; } });
var AssemblyAiConverter_1 = require("./AssemblyAiConverter");
Object.defineProperty(exports, "AssemblyAiConverter", { enumerable: true, get: function () { return AssemblyAiConverter_1.AssemblyAiConverter; } });
var IConverter_1 = require("./IConverter");
Object.defineProperty(exports, "isConverter", { enumerable: true, get: function () { return IConverter_1.isConverter; } });
//# sourceMappingURL=index.js.map

@@ -1,2 +0,2 @@

export declare const version = "1.0.0";
export declare const version = "1.1.0";
//# sourceMappingURL=version.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.version = void 0;
exports.version = "1.0.0";
exports.version = "1.1.0";
//# sourceMappingURL=version.js.map
export { DeepgramConverter } from "./DeepgramConverter";
export { AssemblyAiConverter } from "./AssemblyAiConverter";
export { IConverter, isConverter } from "./IConverter";
//# sourceMappingURL=index.d.ts.map
export { DeepgramConverter } from "./DeepgramConverter";
export { AssemblyAiConverter } from "./AssemblyAiConverter";
export { isConverter } from "./IConverter";
//# sourceMappingURL=index.js.map

@@ -1,2 +0,2 @@

export declare const version = "1.0.0";
export declare const version = "1.1.0";
//# sourceMappingURL=version.d.ts.map

@@ -1,2 +0,2 @@

export const version = "1.0.0";
export const version = "1.1.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+)?$/,$=/\[([^\]]+)]|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])+"]"}},p=function(t,e,r){var n=String(t);return!n||n.length>=e?t:""+Array(e+1-n.length).join(r)+t},m={s:p,z:function(t){var e=-t.utcOffset(),r=Math.abs(e),n=Math.floor(r/60),s=r%60;return(e<=0?"+":"-")+p(n,2,"0")+":"+p(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])},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},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)},b=m;b.l=S,b.i=M,b.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=S(t.locale,null,!0),this.parse(t),this.$x=this.$x||t.x||{},this[y]=!0}var p=v.prototype;return p.parse=function(t){this.$d=function(t){var e=t.date,r=t.utc;if(null===e)return new Date(NaN);if(b.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()},p.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()},p.$utils=function(){return b},p.isValid=function(){return!(this.$d.toString()===d)},p.isSame=function(t,e){var r=O(t);return this.startOf(e)<=r&&r<=this.endOf(e)},p.isAfter=function(t,e){return O(t)<this.startOf(e)},p.isBefore=function(t,e){return this.endOf(e)<O(t)},p.$g=function(t,e,r){return b.u(t)?this[e]:this.set(r,t)},p.unix=function(){return Math.floor(this.valueOf()/1e3)},p.valueOf=function(){return this.$d.getTime()},p.startOf=function(t,e){var r=this,c=!!b.u(e)||e,d=b.p(t),l=function(t,e){var n=b.w(r.$u?Date.UTC(r.$y,e,t):new Date(r.$y,e,t),r);return c?n:n.endOf(a)},$=function(t,e){return b.w(r.toDate()[t].apply(r.toDate("s"),(c?[0,0,0,0]:[23,59,59,999]).slice(e)),r)},v=this.$W,p=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,p):l(0,p+1);case u:var D=this.$locale().weekStart||0,y=(v<D?v+7:v)-D;return l(c?m-y:m+(6-y),p);case a:case h:return $(g+"Hours",0);case i:return $(g+"Minutes",1);case s:return $(g+"Seconds",2);case n:return $(g+"Milliseconds",3);default:return this.clone()}},p.endOf=function(t){return this.startOf(t,!1)},p.$set=function(t,e){var u,c=b.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],$=c===a?this.$D+(e-this.$W):e;if(c===o||c===f){var v=this.clone().set(h,1);v.$d[l]($),v.init(),this.$d=v.set(h,Math.min(this.$D,v.daysInMonth())).$d}else l&&this.$d[l]($);return this.init(),this},p.set=function(t,e){return this.clone().$set(t,e)},p.get=function(t){return this[b.p(t)]()},p.add=function(r,c){var h,d=this;r=Number(r);var l=b.p(c),$=function(t){var e=O(d);return b.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 $(1);if(l===u)return $(7);var v=(h={},h[s]=t,h[i]=e,h[n]=1e3,h)[l]||1,p=this.$d.getTime()+r*v;return b.w(p,this)},p.subtract=function(t,e){return this.add(-1*t,e)},p.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=b.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 b.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($,(function(t,n){return n||function(t){switch(t){case"YY":return String(e.$y).slice(-2);case"YYYY":return b.s(e.$y,4,"0");case"M":return u+1;case"MM":return b.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 b.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 b.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 b.s(a,2,"0");case"s":return String(e.$s);case"ss":return b.s(e.$s,2,"0");case"SSS":return b.s(e.$ms,3,"0");case"Z":return s}return null}(t)||s.replace(":","")}))},p.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},p.diff=function(r,h,d){var l,$=this,v=b.p(h),p=O(r),m=(p.utcOffset()-this.utcOffset())*t,g=this-p,D=function(){return b.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:b.a(l)},p.daysInMonth=function(){return this.endOf(o).$D},p.$locale=function(){return D[this.$L]},p.locale=function(t,e){if(!t)return this.$L;var r=this.clone(),n=S(t,e,!0);return n&&(r.$L=n),r},p.clone=function(){return b.w(this.$d,this)},p.toDate=function(){return new Date(this.valueOf())},p.toJSON=function(){return this.isValid()?this.toISOString():null},p.toISOString=function(){return this.$d.toISOString()},p.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=S,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)}}}()},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.DeepgramConverter=void 0;var n=r(99);Object.defineProperty(e,"DeepgramConverter",{enumerable:!0,get:function(){return n.DeepgramConverter}});var s=r(730);Object.defineProperty(e,"IConverter",{enumerable:!0,get:function(){return s.IConverter}}),Object.defineProperty(e,"isConverter",{enumerable:!0,get:function(){return s.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,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}));
{
"name": "@deepgram/captions",
"version": "1.0.0",
"version": "1.1.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": [

@@ -86,2 +86,12 @@ # Deepgram Captions

### Included Converters
#### Assembly AI
```ts
import { webvtt, AssemblyAiConverter } from "@deepgram/captions";
const result = webvtt(new AssemblyAiConverter(assembly_result));
```
## Output WebVTT

@@ -91,2 +101,12 @@

```ts
import { webvtt } from "@deepgram/captions";
const result = webvtt(deepgram_transcription_result);
console.log(result);
```
This is the result:
```text

@@ -137,2 +157,12 @@ WEBVTT

```ts
import { srt } from "@deepgram/captions";
const result = srt(deepgram_transcription_result);
console.log(result);
```
This is the result:
```text

@@ -139,0 +169,0 @@ 1

@@ -44,4 +44,5 @@ import { chunkArray } from "../lib/helpers";

: null;
return output;
}
}
export { DeepgramConverter } from "./DeepgramConverter";
export { AssemblyAiConverter } from "./AssemblyAiConverter";
export { IConverter, isConverter } from "./IConverter";

@@ -1,1 +0,1 @@

export const version = "1.0.0";
export const version = "1.1.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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc