assemblyai 4.4.7-beta.0 → 4.4.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/assemblyai.umd.js +36 -4
- package/dist/assemblyai.umd.min.js +1 -1
- package/dist/browser.mjs +34 -4
- package/dist/bun.mjs +34 -4
- package/dist/deno.mjs +34 -4
- package/dist/index.cjs +36 -4
- package/dist/index.mjs +36 -4
- package/dist/node.cjs +34 -4
- package/dist/node.mjs +34 -4
- package/dist/services/transcripts/index.d.ts +16 -3
- package/dist/types/transcripts/index.d.ts +9 -0
- package/dist/workerd.mjs +33 -3
- package/package.json +3 -3
- package/src/polyfills/fetch/default.ts +2 -2
- package/src/polyfills/fetch/workerd.ts +1 -2
- package/src/services/base.ts +2 -1
- package/src/services/transcripts/index.ts +35 -2
- package/src/types/transcripts/index.ts +10 -0
- package/README.internal.md +0 -100
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [4.4.7]
|
|
4
|
+
|
|
5
|
+
- Rename `TranscriptService.redactions` function to `TranscriptService.redactedAudio`.
|
|
6
|
+
- Add `TranscriptService.redactedAudioFile` function.
|
|
7
|
+
- Add `workerd` export to fix `cache` issue with `fetch` on Cloudflare Workers.
|
|
8
|
+
|
|
3
9
|
## [4.4.6]
|
|
4
10
|
|
|
5
11
|
- Fix Rollup exports so \_\_SDK_VERSION\_\_ is properly replaced with the version of the SDK.
|
package/dist/assemblyai.umd.js
CHANGED
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
};
|
|
50
50
|
|
|
51
51
|
const DEFAULT_FETCH_INIT = {
|
|
52
|
-
cache: "no-store"
|
|
52
|
+
cache: "no-store",
|
|
53
53
|
};
|
|
54
54
|
|
|
55
55
|
const buildUserAgent = (userAgent) => defaultUserAgentString +
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
defaultUserAgentString += navigator.userAgent;
|
|
66
66
|
}
|
|
67
67
|
const defaultUserAgent = {
|
|
68
|
-
sdk: { name: "JavaScript", version: "4.4.
|
|
68
|
+
sdk: { name: "JavaScript", version: "4.4.7" },
|
|
69
69
|
};
|
|
70
70
|
if (typeof process !== "undefined") {
|
|
71
71
|
if (process.versions.node && defaultUserAgentString.indexOf("Node") === -1) {
|
|
@@ -692,13 +692,45 @@
|
|
|
692
692
|
});
|
|
693
693
|
}
|
|
694
694
|
/**
|
|
695
|
-
* Retrieve
|
|
695
|
+
* Retrieve the redacted audio URL of a transcript.
|
|
696
696
|
* @param id - The identifier of the transcript.
|
|
697
|
-
* @returns A promise that resolves to the
|
|
697
|
+
* @returns A promise that resolves to the details of the redacted audio.
|
|
698
|
+
* @deprecated Use `redactedAudio` instead.
|
|
698
699
|
*/
|
|
699
700
|
redactions(id) {
|
|
701
|
+
return this.redactedAudio(id);
|
|
702
|
+
}
|
|
703
|
+
/**
|
|
704
|
+
* Retrieve the redacted audio URL of a transcript.
|
|
705
|
+
* @param id - The identifier of the transcript.
|
|
706
|
+
* @returns A promise that resolves to the details of the redacted audio.
|
|
707
|
+
*/
|
|
708
|
+
redactedAudio(id) {
|
|
700
709
|
return this.fetchJson(`/v2/transcript/${id}/redacted-audio`);
|
|
701
710
|
}
|
|
711
|
+
/**
|
|
712
|
+
* Retrieve the redacted audio file of a transcript.
|
|
713
|
+
* @param id - The identifier of the transcript.
|
|
714
|
+
* @returns A promise that resolves to the fetch HTTP response of the redacted audio file.
|
|
715
|
+
*/
|
|
716
|
+
redactedAudioFile(id) {
|
|
717
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
718
|
+
const { redacted_audio_url, status } = yield this.redactedAudio(id);
|
|
719
|
+
if (status !== "redacted_audio_ready") {
|
|
720
|
+
throw new Error(`Redacted audio status is ${status}`);
|
|
721
|
+
}
|
|
722
|
+
const response = yield fetch(redacted_audio_url);
|
|
723
|
+
if (!response.ok) {
|
|
724
|
+
throw new Error(`Failed to fetch redacted audio: ${response.statusText}`);
|
|
725
|
+
}
|
|
726
|
+
return {
|
|
727
|
+
arrayBuffer: response.arrayBuffer.bind(response),
|
|
728
|
+
blob: response.blob.bind(response),
|
|
729
|
+
body: response.body,
|
|
730
|
+
bodyUsed: response.bodyUsed,
|
|
731
|
+
};
|
|
732
|
+
});
|
|
733
|
+
}
|
|
702
734
|
}
|
|
703
735
|
function deprecateConformer2(params) {
|
|
704
736
|
if (!params)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).assemblyai={})}(this,(function(e){"use strict";function t(e,t,s,n){return new(s||(s=Promise))((function(i,o){function r(e){try{c(n.next(e))}catch(e){o(e)}}function a(e){try{c(n.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof s?t:new s((function(e){e(t)}))).then(r,a)}c((n=n.apply(e,t||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const s={cache:"no-store"};let n="";"undefined"!=typeof navigator&&navigator.userAgent&&(n+=navigator.userAgent);const i={sdk:{name:"JavaScript",version:"4.4.6"}};"undefined"!=typeof process&&(process.versions.node&&-1===n.indexOf("Node")&&(i.runtime_env={name:"Node",version:process.versions.node}),process.versions.bun&&-1===n.indexOf("Bun")&&(i.runtime_env={name:"Bun",version:process.versions.bun})),"undefined"!=typeof Deno&&process.versions.bun&&-1===n.indexOf("Deno")&&(i.runtime_env={name:"Deno",version:Deno.version.deno});class o{constructor(e){var t;this.params=e,!1===e.userAgent?this.userAgent=void 0:this.userAgent=(t=e.userAgent||{},n+(!1===t?"":" AssemblyAI/1.0 ("+Object.entries(Object.assign(Object.assign({},i),t)).map((([e,t])=>t?`${e}=${t.name}/${t.version}`:"")).join(" ")+")"))}fetch(e,n){return t(this,void 0,void 0,(function*(){n=Object.assign(Object.assign({},s),n);let t={Authorization:this.params.apiKey,"Content-Type":"application/json"};(null==s?void 0:s.headers)&&(t=Object.assign(Object.assign({},t),s.headers)),(null==n?void 0:n.headers)&&(t=Object.assign(Object.assign({},t),n.headers)),this.userAgent&&(t["User-Agent"]=this.userAgent,"undefined"!=typeof window&&"chrome"in window&&(t["AssemblyAI-Agent"]=this.userAgent)),n.headers=t,e.startsWith("http")||(e=this.params.baseUrl+e);const i=yield fetch(e,n);if(i.status>=400){let e;const t=yield i.text();if(t){try{e=JSON.parse(t)}catch(e){}if(null==e?void 0:e.error)throw new Error(e.error);throw new Error(t)}throw new Error(`HTTP Error: ${i.status} ${i.statusText}`)}return i}))}fetchJson(e,s){return t(this,void 0,void 0,(function*(){return(yield this.fetch(e,s)).json()}))}}class r extends o{summary(e){return this.fetchJson("/lemur/v3/generate/summary",{method:"POST",body:JSON.stringify(e)})}questionAnswer(e){return this.fetchJson("/lemur/v3/generate/question-answer",{method:"POST",body:JSON.stringify(e)})}actionItems(e){return this.fetchJson("/lemur/v3/generate/action-items",{method:"POST",body:JSON.stringify(e)})}task(e){return this.fetchJson("/lemur/v3/generate/task",{method:"POST",body:JSON.stringify(e)})}purgeRequestData(e){return this.fetchJson(`/lemur/v3/${e}`,{method:"DELETE"})}}const{WritableStream:a}="undefined"!=typeof window?window:"undefined"!=typeof global?global:globalThis;var c,l;const d=null!==(l=null!==(c=null!==WebSocket&&void 0!==WebSocket?WebSocket:null===global||void 0===global?void 0:global.WebSocket)&&void 0!==c?c:null===window||void 0===window?void 0:window.WebSocket)&&void 0!==l?l:null===self||void 0===self?void 0:self.WebSocket,h=(e,t)=>t?new d(e,t):new d(e);var u;!function(e){e[e.BadSampleRate=4e3]="BadSampleRate",e[e.AuthFailed=4001]="AuthFailed",e[e.InsufficientFundsOrFreeAccount=4002]="InsufficientFundsOrFreeAccount",e[e.NonexistentSessionId=4004]="NonexistentSessionId",e[e.SessionExpired=4008]="SessionExpired",e[e.ClosedSession=4010]="ClosedSession",e[e.RateLimited=4029]="RateLimited",e[e.UniqueSessionViolation=4030]="UniqueSessionViolation",e[e.SessionTimeout=4031]="SessionTimeout",e[e.AudioTooShort=4032]="AudioTooShort",e[e.AudioTooLong=4033]="AudioTooLong",e[e.BadJson=4100]="BadJson",e[e.BadSchema=4101]="BadSchema",e[e.TooManyStreams=4102]="TooManyStreams",e[e.Reconnected=4103]="Reconnected",e[e.ReconnectAttemptsExhausted=1013]="ReconnectAttemptsExhausted"}(u||(u={}));const p={[u.BadSampleRate]:"Sample rate must be a positive integer",[u.AuthFailed]:"Not Authorized",[u.InsufficientFundsOrFreeAccount]:"Insufficient funds or you are using a free account. This feature is paid-only and requires you to add a credit card. Please visit https://assemblyai.com/dashboard/ to add a credit card to your account.",[u.NonexistentSessionId]:"Session ID does not exist",[u.SessionExpired]:"Session has expired",[u.ClosedSession]:"Session is closed",[u.RateLimited]:"Rate limited",[u.UniqueSessionViolation]:"Unique session violation",[u.SessionTimeout]:"Session Timeout",[u.AudioTooShort]:"Audio too short",[u.AudioTooLong]:"Audio too long",[u.BadJson]:"Bad JSON",[u.BadSchema]:"Bad schema",[u.TooManyStreams]:"Too many streams",[u.Reconnected]:"Reconnected",[u.ReconnectAttemptsExhausted]:"Reconnect attempts exhausted"};class f extends Error{}const m='{"terminate_session":true}';class v{constructor(e){var t,s;if(this.listeners={},this.realtimeUrl=null!==(t=e.realtimeUrl)&&void 0!==t?t:"wss://api.assemblyai.com/v2/realtime/ws",this.sampleRate=null!==(s=e.sampleRate)&&void 0!==s?s:16e3,this.wordBoost=e.wordBoost,this.encoding=e.encoding,this.endUtteranceSilenceThreshold=e.endUtteranceSilenceThreshold,this.disablePartialTranscripts=e.disablePartialTranscripts,"token"in e&&e.token&&(this.token=e.token),"apiKey"in e&&e.apiKey&&(this.apiKey=e.apiKey),!this.token&&!this.apiKey)throw new Error("API key or temporary token is required.")}connectionUrl(){const e=new URL(this.realtimeUrl);if("wss:"!==e.protocol)throw new Error("Invalid protocol, must be wss");const t=new URLSearchParams;return this.token&&t.set("token",this.token),t.set("sample_rate",this.sampleRate.toString()),this.wordBoost&&this.wordBoost.length>0&&t.set("word_boost",JSON.stringify(this.wordBoost)),this.encoding&&t.set("encoding",this.encoding),t.set("enable_extra_session_information","true"),this.disablePartialTranscripts&&t.set("disable_partial_transcripts",this.disablePartialTranscripts.toString()),e.search=t.toString(),e}on(e,t){this.listeners[e]=t}connect(){return new Promise((e=>{if(this.socket)throw new Error("Already connected");const t=this.connectionUrl();this.token?this.socket=h(t.toString()):this.socket=h(t.toString(),{headers:{Authorization:this.apiKey}}),this.socket.binaryType="arraybuffer",this.socket.onopen=()=>{void 0!==this.endUtteranceSilenceThreshold&&null!==this.endUtteranceSilenceThreshold&&this.configureEndUtteranceSilenceThreshold(this.endUtteranceSilenceThreshold)},this.socket.onclose=({code:e,reason:t})=>{var s,n;t||e in u&&(t=p[e]),null===(n=(s=this.listeners).close)||void 0===n||n.call(s,e,t)},this.socket.onerror=e=>{var t,s,n,i;e.error?null===(s=(t=this.listeners).error)||void 0===s||s.call(t,e.error):null===(i=(n=this.listeners).error)||void 0===i||i.call(n,new Error(e.message))},this.socket.onmessage=({data:t})=>{var s,n,i,o,r,a,c,l,d,h,u,p,m,v,y;const S=JSON.parse(t.toString());if("error"in S)null===(n=(s=this.listeners).error)||void 0===n||n.call(s,new f(S.error));else switch(S.message_type){case"SessionBegins":{const t={sessionId:S.session_id,expiresAt:new Date(S.expires_at)};e(t),null===(o=(i=this.listeners).open)||void 0===o||o.call(i,t);break}case"PartialTranscript":S.created=new Date(S.created),null===(a=(r=this.listeners).transcript)||void 0===a||a.call(r,S),null===(l=(c=this.listeners)["transcript.partial"])||void 0===l||l.call(c,S);break;case"FinalTranscript":S.created=new Date(S.created),null===(h=(d=this.listeners).transcript)||void 0===h||h.call(d,S),null===(p=(u=this.listeners)["transcript.final"])||void 0===p||p.call(u,S);break;case"SessionInformation":null===(v=(m=this.listeners).session_information)||void 0===v||v.call(m,S);break;case"SessionTerminated":null===(y=this.sessionTerminatedResolve)||void 0===y||y.call(this)}}}))}sendAudio(e){this.send(e)}stream(){return new a({write:e=>{this.sendAudio(e)}})}forceEndUtterance(){this.send('{"force_end_utterance":true}')}configureEndUtteranceSilenceThreshold(e){this.send(`{"end_utterance_silence_threshold":${e}}`)}send(e){if(!this.socket||this.socket.readyState!==this.socket.OPEN)throw new Error("Socket is not open for communication");this.socket.send(e)}close(){return t(this,arguments,void 0,(function*(e=!0){var t;if(this.socket){if(this.socket.readyState===this.socket.OPEN)if(e){const e=new Promise((e=>{this.sessionTerminatedResolve=e}));this.socket.send(m),yield e}else this.socket.send(m);(null===(t=this.socket)||void 0===t?void 0:t.removeAllListeners)&&this.socket.removeAllListeners(),this.socket.close()}this.listeners={},this.socket=void 0}))}}class y extends o{constructor(e){super(e),this.rtFactoryParams=e}createService(e){return this.transcriber(e)}transcriber(e){const t=Object.assign({},e);return t.token||t.apiKey||(t.apiKey=this.rtFactoryParams.apiKey),new v(t)}createTemporaryToken(e){return t(this,void 0,void 0,(function*(){return(yield this.fetchJson("/v2/realtime/token",{method:"POST",body:JSON.stringify(e)})).token}))}}function S(e){return e.startsWith("http")||e.startsWith("https")||e.startsWith("data:")?null:e.startsWith("file://")?e.substring(7):e.startsWith("file:")?e.substring(5):e}class g extends o{constructor(e,t){super(e),this.files=t}transcribe(e,s){return t(this,void 0,void 0,(function*(){b(e);const t=yield this.submit(e);return yield this.waitUntilReady(t.id,s)}))}submit(e){return t(this,void 0,void 0,(function*(){let t,s;if(b(e),"audio"in e){const{audio:n}=e,i=function(e,t){var s={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(s[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(n=Object.getOwnPropertySymbols(e);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(s[n[i]]=e[n[i]])}return s}(e,["audio"]);if("string"==typeof n){const e=S(n);t=null!==e?yield this.files.upload(e):n.startsWith("data:")?yield this.files.upload(n):n}else t=yield this.files.upload(n);s=Object.assign(Object.assign({},i),{audio_url:t})}else s=e;return yield this.fetchJson("/v2/transcript",{method:"POST",body:JSON.stringify(s)})}))}create(e,s){return t(this,void 0,void 0,(function*(){var t;b(e);const n=S(e.audio_url);if(null!==n){const t=yield this.files.upload(n);e.audio_url=t}const i=yield this.fetchJson("/v2/transcript",{method:"POST",body:JSON.stringify(e)});return null===(t=null==s?void 0:s.poll)||void 0===t||t?yield this.waitUntilReady(i.id,s):i}))}waitUntilReady(e,s){return t(this,void 0,void 0,(function*(){var t,n;const i=null!==(t=null==s?void 0:s.pollingInterval)&&void 0!==t?t:3e3,o=null!==(n=null==s?void 0:s.pollingTimeout)&&void 0!==n?n:-1,r=Date.now();for(;;){const t=yield this.get(e);if("completed"===t.status||"error"===t.status)return t;if(o>0&&Date.now()-r>o)throw new Error("Polling timeout");yield new Promise((e=>setTimeout(e,i)))}}))}get(e){return this.fetchJson(`/v2/transcript/${e}`)}list(e){return t(this,void 0,void 0,(function*(){let t="/v2/transcript";"string"==typeof e?t=e:e&&(t=`${t}?${new URLSearchParams(Object.keys(e).map((t=>{var s;return[t,(null===(s=e[t])||void 0===s?void 0:s.toString())||""]})))}`);const s=yield this.fetchJson(t);for(const e of s.transcripts)e.created=new Date(e.created),e.completed&&(e.completed=new Date(e.completed));return s}))}delete(e){return this.fetchJson(`/v2/transcript/${e}`,{method:"DELETE"})}wordSearch(e,t){const s=new URLSearchParams({words:t.join(",")});return this.fetchJson(`/v2/transcript/${e}/word-search?${s.toString()}`)}sentences(e){return this.fetchJson(`/v2/transcript/${e}/sentences`)}paragraphs(e){return this.fetchJson(`/v2/transcript/${e}/paragraphs`)}subtitles(e){return t(this,arguments,void 0,(function*(e,t="srt",s){let n=`/v2/transcript/${e}/${t}`;if(s){const e=new URLSearchParams;e.set("chars_per_caption",s.toString()),n+=`?${e.toString()}`}const i=yield this.fetch(n);return yield i.text()}))}redactions(e){return this.fetchJson(`/v2/transcript/${e}/redacted-audio`)}}function b(e){e&&"conformer-2"===e.speech_model&&console.warn("The speech_model conformer-2 option is deprecated and will stop working in the near future. Use best or nano instead.")}class w extends o{upload(e){return t(this,void 0,void 0,(function*(){let s;s="string"==typeof e?e.startsWith("data:")?function(e){const t=e.split(","),s=t[0].match(/:(.*?);/)[1],n=atob(t[1]);let i=n.length;const o=new Uint8Array(i);for(;i--;)o[i]=n.charCodeAt(i);return new Blob([o],{type:s})}(e):yield function(e){return t(this,void 0,void 0,(function*(){throw new Error("Interacting with the file system is not supported in this environment.")}))}():e;return(yield this.fetchJson("/v2/upload",{method:"POST",body:s,headers:{"Content-Type":"application/octet-stream"},duplex:"half"})).upload_url}))}}e.AssemblyAI=class{constructor(e){e.baseUrl=e.baseUrl||"https://api.assemblyai.com",e.baseUrl&&e.baseUrl.endsWith("/")&&(e.baseUrl=e.baseUrl.slice(0,-1)),this.files=new w(e),this.transcripts=new g(e,this.files),this.lemur=new r(e),this.realtime=new y(e)}},e.FileService=w,e.LemurService=r,e.RealtimeService=class extends v{},e.RealtimeServiceFactory=class extends y{},e.RealtimeTranscriber=v,e.RealtimeTranscriberFactory=y,e.TranscriptService=g}));
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).assemblyai={})}(this,(function(e){"use strict";function t(e,t,s,i){return new(s||(s=Promise))((function(n,o){function r(e){try{d(i.next(e))}catch(e){o(e)}}function a(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?n(e.value):(t=e.value,t instanceof s?t:new s((function(e){e(t)}))).then(r,a)}d((i=i.apply(e,t||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const s={cache:"no-store"};let i="";"undefined"!=typeof navigator&&navigator.userAgent&&(i+=navigator.userAgent);const n={sdk:{name:"JavaScript",version:"4.4.7"}};"undefined"!=typeof process&&(process.versions.node&&-1===i.indexOf("Node")&&(n.runtime_env={name:"Node",version:process.versions.node}),process.versions.bun&&-1===i.indexOf("Bun")&&(n.runtime_env={name:"Bun",version:process.versions.bun})),"undefined"!=typeof Deno&&process.versions.bun&&-1===i.indexOf("Deno")&&(n.runtime_env={name:"Deno",version:Deno.version.deno});class o{constructor(e){var t;this.params=e,!1===e.userAgent?this.userAgent=void 0:this.userAgent=(t=e.userAgent||{},i+(!1===t?"":" AssemblyAI/1.0 ("+Object.entries(Object.assign(Object.assign({},n),t)).map((([e,t])=>t?`${e}=${t.name}/${t.version}`:"")).join(" ")+")"))}fetch(e,i){return t(this,void 0,void 0,(function*(){i=Object.assign(Object.assign({},s),i);let t={Authorization:this.params.apiKey,"Content-Type":"application/json"};(null==s?void 0:s.headers)&&(t=Object.assign(Object.assign({},t),s.headers)),(null==i?void 0:i.headers)&&(t=Object.assign(Object.assign({},t),i.headers)),this.userAgent&&(t["User-Agent"]=this.userAgent,"undefined"!=typeof window&&"chrome"in window&&(t["AssemblyAI-Agent"]=this.userAgent)),i.headers=t,e.startsWith("http")||(e=this.params.baseUrl+e);const n=yield fetch(e,i);if(n.status>=400){let e;const t=yield n.text();if(t){try{e=JSON.parse(t)}catch(e){}if(null==e?void 0:e.error)throw new Error(e.error);throw new Error(t)}throw new Error(`HTTP Error: ${n.status} ${n.statusText}`)}return n}))}fetchJson(e,s){return t(this,void 0,void 0,(function*(){return(yield this.fetch(e,s)).json()}))}}class r extends o{summary(e){return this.fetchJson("/lemur/v3/generate/summary",{method:"POST",body:JSON.stringify(e)})}questionAnswer(e){return this.fetchJson("/lemur/v3/generate/question-answer",{method:"POST",body:JSON.stringify(e)})}actionItems(e){return this.fetchJson("/lemur/v3/generate/action-items",{method:"POST",body:JSON.stringify(e)})}task(e){return this.fetchJson("/lemur/v3/generate/task",{method:"POST",body:JSON.stringify(e)})}purgeRequestData(e){return this.fetchJson(`/lemur/v3/${e}`,{method:"DELETE"})}}const{WritableStream:a}="undefined"!=typeof window?window:"undefined"!=typeof global?global:globalThis;var d,c;const l=null!==(c=null!==(d=null!==WebSocket&&void 0!==WebSocket?WebSocket:null===global||void 0===global?void 0:global.WebSocket)&&void 0!==d?d:null===window||void 0===window?void 0:window.WebSocket)&&void 0!==c?c:null===self||void 0===self?void 0:self.WebSocket,u=(e,t)=>t?new l(e,t):new l(e);var h;!function(e){e[e.BadSampleRate=4e3]="BadSampleRate",e[e.AuthFailed=4001]="AuthFailed",e[e.InsufficientFundsOrFreeAccount=4002]="InsufficientFundsOrFreeAccount",e[e.NonexistentSessionId=4004]="NonexistentSessionId",e[e.SessionExpired=4008]="SessionExpired",e[e.ClosedSession=4010]="ClosedSession",e[e.RateLimited=4029]="RateLimited",e[e.UniqueSessionViolation=4030]="UniqueSessionViolation",e[e.SessionTimeout=4031]="SessionTimeout",e[e.AudioTooShort=4032]="AudioTooShort",e[e.AudioTooLong=4033]="AudioTooLong",e[e.BadJson=4100]="BadJson",e[e.BadSchema=4101]="BadSchema",e[e.TooManyStreams=4102]="TooManyStreams",e[e.Reconnected=4103]="Reconnected",e[e.ReconnectAttemptsExhausted=1013]="ReconnectAttemptsExhausted"}(h||(h={}));const f={[h.BadSampleRate]:"Sample rate must be a positive integer",[h.AuthFailed]:"Not Authorized",[h.InsufficientFundsOrFreeAccount]:"Insufficient funds or you are using a free account. This feature is paid-only and requires you to add a credit card. Please visit https://assemblyai.com/dashboard/ to add a credit card to your account.",[h.NonexistentSessionId]:"Session ID does not exist",[h.SessionExpired]:"Session has expired",[h.ClosedSession]:"Session is closed",[h.RateLimited]:"Rate limited",[h.UniqueSessionViolation]:"Unique session violation",[h.SessionTimeout]:"Session Timeout",[h.AudioTooShort]:"Audio too short",[h.AudioTooLong]:"Audio too long",[h.BadJson]:"Bad JSON",[h.BadSchema]:"Bad schema",[h.TooManyStreams]:"Too many streams",[h.Reconnected]:"Reconnected",[h.ReconnectAttemptsExhausted]:"Reconnect attempts exhausted"};class p extends Error{}const m='{"terminate_session":true}';class v{constructor(e){var t,s;if(this.listeners={},this.realtimeUrl=null!==(t=e.realtimeUrl)&&void 0!==t?t:"wss://api.assemblyai.com/v2/realtime/ws",this.sampleRate=null!==(s=e.sampleRate)&&void 0!==s?s:16e3,this.wordBoost=e.wordBoost,this.encoding=e.encoding,this.endUtteranceSilenceThreshold=e.endUtteranceSilenceThreshold,this.disablePartialTranscripts=e.disablePartialTranscripts,"token"in e&&e.token&&(this.token=e.token),"apiKey"in e&&e.apiKey&&(this.apiKey=e.apiKey),!this.token&&!this.apiKey)throw new Error("API key or temporary token is required.")}connectionUrl(){const e=new URL(this.realtimeUrl);if("wss:"!==e.protocol)throw new Error("Invalid protocol, must be wss");const t=new URLSearchParams;return this.token&&t.set("token",this.token),t.set("sample_rate",this.sampleRate.toString()),this.wordBoost&&this.wordBoost.length>0&&t.set("word_boost",JSON.stringify(this.wordBoost)),this.encoding&&t.set("encoding",this.encoding),t.set("enable_extra_session_information","true"),this.disablePartialTranscripts&&t.set("disable_partial_transcripts",this.disablePartialTranscripts.toString()),e.search=t.toString(),e}on(e,t){this.listeners[e]=t}connect(){return new Promise((e=>{if(this.socket)throw new Error("Already connected");const t=this.connectionUrl();this.token?this.socket=u(t.toString()):this.socket=u(t.toString(),{headers:{Authorization:this.apiKey}}),this.socket.binaryType="arraybuffer",this.socket.onopen=()=>{void 0!==this.endUtteranceSilenceThreshold&&null!==this.endUtteranceSilenceThreshold&&this.configureEndUtteranceSilenceThreshold(this.endUtteranceSilenceThreshold)},this.socket.onclose=({code:e,reason:t})=>{var s,i;t||e in h&&(t=f[e]),null===(i=(s=this.listeners).close)||void 0===i||i.call(s,e,t)},this.socket.onerror=e=>{var t,s,i,n;e.error?null===(s=(t=this.listeners).error)||void 0===s||s.call(t,e.error):null===(n=(i=this.listeners).error)||void 0===n||n.call(i,new Error(e.message))},this.socket.onmessage=({data:t})=>{var s,i,n,o,r,a,d,c,l,u,h,f,m,v,y;const b=JSON.parse(t.toString());if("error"in b)null===(i=(s=this.listeners).error)||void 0===i||i.call(s,new p(b.error));else switch(b.message_type){case"SessionBegins":{const t={sessionId:b.session_id,expiresAt:new Date(b.expires_at)};e(t),null===(o=(n=this.listeners).open)||void 0===o||o.call(n,t);break}case"PartialTranscript":b.created=new Date(b.created),null===(a=(r=this.listeners).transcript)||void 0===a||a.call(r,b),null===(c=(d=this.listeners)["transcript.partial"])||void 0===c||c.call(d,b);break;case"FinalTranscript":b.created=new Date(b.created),null===(u=(l=this.listeners).transcript)||void 0===u||u.call(l,b),null===(f=(h=this.listeners)["transcript.final"])||void 0===f||f.call(h,b);break;case"SessionInformation":null===(v=(m=this.listeners).session_information)||void 0===v||v.call(m,b);break;case"SessionTerminated":null===(y=this.sessionTerminatedResolve)||void 0===y||y.call(this)}}}))}sendAudio(e){this.send(e)}stream(){return new a({write:e=>{this.sendAudio(e)}})}forceEndUtterance(){this.send('{"force_end_utterance":true}')}configureEndUtteranceSilenceThreshold(e){this.send(`{"end_utterance_silence_threshold":${e}}`)}send(e){if(!this.socket||this.socket.readyState!==this.socket.OPEN)throw new Error("Socket is not open for communication");this.socket.send(e)}close(){return t(this,arguments,void 0,(function*(e=!0){var t;if(this.socket){if(this.socket.readyState===this.socket.OPEN)if(e){const e=new Promise((e=>{this.sessionTerminatedResolve=e}));this.socket.send(m),yield e}else this.socket.send(m);(null===(t=this.socket)||void 0===t?void 0:t.removeAllListeners)&&this.socket.removeAllListeners(),this.socket.close()}this.listeners={},this.socket=void 0}))}}class y extends o{constructor(e){super(e),this.rtFactoryParams=e}createService(e){return this.transcriber(e)}transcriber(e){const t=Object.assign({},e);return t.token||t.apiKey||(t.apiKey=this.rtFactoryParams.apiKey),new v(t)}createTemporaryToken(e){return t(this,void 0,void 0,(function*(){return(yield this.fetchJson("/v2/realtime/token",{method:"POST",body:JSON.stringify(e)})).token}))}}function b(e){return e.startsWith("http")||e.startsWith("https")||e.startsWith("data:")?null:e.startsWith("file://")?e.substring(7):e.startsWith("file:")?e.substring(5):e}class S extends o{constructor(e,t){super(e),this.files=t}transcribe(e,s){return t(this,void 0,void 0,(function*(){w(e);const t=yield this.submit(e);return yield this.waitUntilReady(t.id,s)}))}submit(e){return t(this,void 0,void 0,(function*(){let t,s;if(w(e),"audio"in e){const{audio:i}=e,n=function(e,t){var s={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(s[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(i=Object.getOwnPropertySymbols(e);n<i.length;n++)t.indexOf(i[n])<0&&Object.prototype.propertyIsEnumerable.call(e,i[n])&&(s[i[n]]=e[i[n]])}return s}(e,["audio"]);if("string"==typeof i){const e=b(i);t=null!==e?yield this.files.upload(e):i.startsWith("data:")?yield this.files.upload(i):i}else t=yield this.files.upload(i);s=Object.assign(Object.assign({},n),{audio_url:t})}else s=e;return yield this.fetchJson("/v2/transcript",{method:"POST",body:JSON.stringify(s)})}))}create(e,s){return t(this,void 0,void 0,(function*(){var t;w(e);const i=b(e.audio_url);if(null!==i){const t=yield this.files.upload(i);e.audio_url=t}const n=yield this.fetchJson("/v2/transcript",{method:"POST",body:JSON.stringify(e)});return null===(t=null==s?void 0:s.poll)||void 0===t||t?yield this.waitUntilReady(n.id,s):n}))}waitUntilReady(e,s){return t(this,void 0,void 0,(function*(){var t,i;const n=null!==(t=null==s?void 0:s.pollingInterval)&&void 0!==t?t:3e3,o=null!==(i=null==s?void 0:s.pollingTimeout)&&void 0!==i?i:-1,r=Date.now();for(;;){const t=yield this.get(e);if("completed"===t.status||"error"===t.status)return t;if(o>0&&Date.now()-r>o)throw new Error("Polling timeout");yield new Promise((e=>setTimeout(e,n)))}}))}get(e){return this.fetchJson(`/v2/transcript/${e}`)}list(e){return t(this,void 0,void 0,(function*(){let t="/v2/transcript";"string"==typeof e?t=e:e&&(t=`${t}?${new URLSearchParams(Object.keys(e).map((t=>{var s;return[t,(null===(s=e[t])||void 0===s?void 0:s.toString())||""]})))}`);const s=yield this.fetchJson(t);for(const e of s.transcripts)e.created=new Date(e.created),e.completed&&(e.completed=new Date(e.completed));return s}))}delete(e){return this.fetchJson(`/v2/transcript/${e}`,{method:"DELETE"})}wordSearch(e,t){const s=new URLSearchParams({words:t.join(",")});return this.fetchJson(`/v2/transcript/${e}/word-search?${s.toString()}`)}sentences(e){return this.fetchJson(`/v2/transcript/${e}/sentences`)}paragraphs(e){return this.fetchJson(`/v2/transcript/${e}/paragraphs`)}subtitles(e){return t(this,arguments,void 0,(function*(e,t="srt",s){let i=`/v2/transcript/${e}/${t}`;if(s){const e=new URLSearchParams;e.set("chars_per_caption",s.toString()),i+=`?${e.toString()}`}const n=yield this.fetch(i);return yield n.text()}))}redactions(e){return this.redactedAudio(e)}redactedAudio(e){return this.fetchJson(`/v2/transcript/${e}/redacted-audio`)}redactedAudioFile(e){return t(this,void 0,void 0,(function*(){const{redacted_audio_url:t,status:s}=yield this.redactedAudio(e);if("redacted_audio_ready"!==s)throw new Error(`Redacted audio status is ${s}`);const i=yield fetch(t);if(!i.ok)throw new Error(`Failed to fetch redacted audio: ${i.statusText}`);return{arrayBuffer:i.arrayBuffer.bind(i),blob:i.blob.bind(i),body:i.body,bodyUsed:i.bodyUsed}}))}}function w(e){e&&"conformer-2"===e.speech_model&&console.warn("The speech_model conformer-2 option is deprecated and will stop working in the near future. Use best or nano instead.")}class g extends o{upload(e){return t(this,void 0,void 0,(function*(){let s;s="string"==typeof e?e.startsWith("data:")?function(e){const t=e.split(","),s=t[0].match(/:(.*?);/)[1],i=atob(t[1]);let n=i.length;const o=new Uint8Array(n);for(;n--;)o[n]=i.charCodeAt(n);return new Blob([o],{type:s})}(e):yield function(e){return t(this,void 0,void 0,(function*(){throw new Error("Interacting with the file system is not supported in this environment.")}))}():e;return(yield this.fetchJson("/v2/upload",{method:"POST",body:s,headers:{"Content-Type":"application/octet-stream"},duplex:"half"})).upload_url}))}}e.AssemblyAI=class{constructor(e){e.baseUrl=e.baseUrl||"https://api.assemblyai.com",e.baseUrl&&e.baseUrl.endsWith("/")&&(e.baseUrl=e.baseUrl.slice(0,-1)),this.files=new g(e),this.transcripts=new S(e,this.files),this.lemur=new r(e),this.realtime=new y(e)}},e.FileService=g,e.LemurService=r,e.RealtimeService=class extends v{},e.RealtimeServiceFactory=class extends y{},e.RealtimeTranscriber=v,e.RealtimeTranscriberFactory=y,e.TranscriptService=S}));
|
package/dist/browser.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const DEFAULT_FETCH_INIT = {
|
|
2
|
-
cache: "no-store"
|
|
2
|
+
cache: "no-store",
|
|
3
3
|
};
|
|
4
4
|
|
|
5
5
|
const buildUserAgent = (userAgent) => defaultUserAgentString +
|
|
@@ -15,7 +15,7 @@ if (typeof navigator !== "undefined" && navigator.userAgent) {
|
|
|
15
15
|
defaultUserAgentString += navigator.userAgent;
|
|
16
16
|
}
|
|
17
17
|
const defaultUserAgent = {
|
|
18
|
-
sdk: { name: "JavaScript", version: "4.4.
|
|
18
|
+
sdk: { name: "JavaScript", version: "4.4.7" },
|
|
19
19
|
};
|
|
20
20
|
if (typeof process !== "undefined") {
|
|
21
21
|
if (process.versions.node && defaultUserAgentString.indexOf("Node") === -1) {
|
|
@@ -611,13 +611,43 @@ class TranscriptService extends BaseService {
|
|
|
611
611
|
return await response.text();
|
|
612
612
|
}
|
|
613
613
|
/**
|
|
614
|
-
* Retrieve
|
|
614
|
+
* Retrieve the redacted audio URL of a transcript.
|
|
615
615
|
* @param id - The identifier of the transcript.
|
|
616
|
-
* @returns A promise that resolves to the
|
|
616
|
+
* @returns A promise that resolves to the details of the redacted audio.
|
|
617
|
+
* @deprecated Use `redactedAudio` instead.
|
|
617
618
|
*/
|
|
618
619
|
redactions(id) {
|
|
620
|
+
return this.redactedAudio(id);
|
|
621
|
+
}
|
|
622
|
+
/**
|
|
623
|
+
* Retrieve the redacted audio URL of a transcript.
|
|
624
|
+
* @param id - The identifier of the transcript.
|
|
625
|
+
* @returns A promise that resolves to the details of the redacted audio.
|
|
626
|
+
*/
|
|
627
|
+
redactedAudio(id) {
|
|
619
628
|
return this.fetchJson(`/v2/transcript/${id}/redacted-audio`);
|
|
620
629
|
}
|
|
630
|
+
/**
|
|
631
|
+
* Retrieve the redacted audio file of a transcript.
|
|
632
|
+
* @param id - The identifier of the transcript.
|
|
633
|
+
* @returns A promise that resolves to the fetch HTTP response of the redacted audio file.
|
|
634
|
+
*/
|
|
635
|
+
async redactedAudioFile(id) {
|
|
636
|
+
const { redacted_audio_url, status } = await this.redactedAudio(id);
|
|
637
|
+
if (status !== "redacted_audio_ready") {
|
|
638
|
+
throw new Error(`Redacted audio status is ${status}`);
|
|
639
|
+
}
|
|
640
|
+
const response = await fetch(redacted_audio_url);
|
|
641
|
+
if (!response.ok) {
|
|
642
|
+
throw new Error(`Failed to fetch redacted audio: ${response.statusText}`);
|
|
643
|
+
}
|
|
644
|
+
return {
|
|
645
|
+
arrayBuffer: response.arrayBuffer.bind(response),
|
|
646
|
+
blob: response.blob.bind(response),
|
|
647
|
+
body: response.body,
|
|
648
|
+
bodyUsed: response.bodyUsed,
|
|
649
|
+
};
|
|
650
|
+
}
|
|
621
651
|
}
|
|
622
652
|
function deprecateConformer2(params) {
|
|
623
653
|
if (!params)
|
package/dist/bun.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import ws from 'ws';
|
|
2
2
|
|
|
3
3
|
const DEFAULT_FETCH_INIT = {
|
|
4
|
-
cache: "no-store"
|
|
4
|
+
cache: "no-store",
|
|
5
5
|
};
|
|
6
6
|
|
|
7
7
|
const buildUserAgent = (userAgent) => defaultUserAgentString +
|
|
@@ -17,7 +17,7 @@ if (typeof navigator !== "undefined" && navigator.userAgent) {
|
|
|
17
17
|
defaultUserAgentString += navigator.userAgent;
|
|
18
18
|
}
|
|
19
19
|
const defaultUserAgent = {
|
|
20
|
-
sdk: { name: "JavaScript", version: "4.4.
|
|
20
|
+
sdk: { name: "JavaScript", version: "4.4.7" },
|
|
21
21
|
};
|
|
22
22
|
if (typeof process !== "undefined") {
|
|
23
23
|
if (process.versions.node && defaultUserAgentString.indexOf("Node") === -1) {
|
|
@@ -607,13 +607,43 @@ class TranscriptService extends BaseService {
|
|
|
607
607
|
return await response.text();
|
|
608
608
|
}
|
|
609
609
|
/**
|
|
610
|
-
* Retrieve
|
|
610
|
+
* Retrieve the redacted audio URL of a transcript.
|
|
611
611
|
* @param id - The identifier of the transcript.
|
|
612
|
-
* @returns A promise that resolves to the
|
|
612
|
+
* @returns A promise that resolves to the details of the redacted audio.
|
|
613
|
+
* @deprecated Use `redactedAudio` instead.
|
|
613
614
|
*/
|
|
614
615
|
redactions(id) {
|
|
616
|
+
return this.redactedAudio(id);
|
|
617
|
+
}
|
|
618
|
+
/**
|
|
619
|
+
* Retrieve the redacted audio URL of a transcript.
|
|
620
|
+
* @param id - The identifier of the transcript.
|
|
621
|
+
* @returns A promise that resolves to the details of the redacted audio.
|
|
622
|
+
*/
|
|
623
|
+
redactedAudio(id) {
|
|
615
624
|
return this.fetchJson(`/v2/transcript/${id}/redacted-audio`);
|
|
616
625
|
}
|
|
626
|
+
/**
|
|
627
|
+
* Retrieve the redacted audio file of a transcript.
|
|
628
|
+
* @param id - The identifier of the transcript.
|
|
629
|
+
* @returns A promise that resolves to the fetch HTTP response of the redacted audio file.
|
|
630
|
+
*/
|
|
631
|
+
async redactedAudioFile(id) {
|
|
632
|
+
const { redacted_audio_url, status } = await this.redactedAudio(id);
|
|
633
|
+
if (status !== "redacted_audio_ready") {
|
|
634
|
+
throw new Error(`Redacted audio status is ${status}`);
|
|
635
|
+
}
|
|
636
|
+
const response = await fetch(redacted_audio_url);
|
|
637
|
+
if (!response.ok) {
|
|
638
|
+
throw new Error(`Failed to fetch redacted audio: ${response.statusText}`);
|
|
639
|
+
}
|
|
640
|
+
return {
|
|
641
|
+
arrayBuffer: response.arrayBuffer.bind(response),
|
|
642
|
+
blob: response.blob.bind(response),
|
|
643
|
+
body: response.body,
|
|
644
|
+
bodyUsed: response.bodyUsed,
|
|
645
|
+
};
|
|
646
|
+
}
|
|
617
647
|
}
|
|
618
648
|
function deprecateConformer2(params) {
|
|
619
649
|
if (!params)
|
package/dist/deno.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import ws from 'ws';
|
|
2
2
|
|
|
3
3
|
const DEFAULT_FETCH_INIT = {
|
|
4
|
-
cache: "no-store"
|
|
4
|
+
cache: "no-store",
|
|
5
5
|
};
|
|
6
6
|
|
|
7
7
|
const buildUserAgent = (userAgent) => defaultUserAgentString +
|
|
@@ -17,7 +17,7 @@ if (typeof navigator !== "undefined" && navigator.userAgent) {
|
|
|
17
17
|
defaultUserAgentString += navigator.userAgent;
|
|
18
18
|
}
|
|
19
19
|
const defaultUserAgent = {
|
|
20
|
-
sdk: { name: "JavaScript", version: "4.4.
|
|
20
|
+
sdk: { name: "JavaScript", version: "4.4.7" },
|
|
21
21
|
};
|
|
22
22
|
if (typeof process !== "undefined") {
|
|
23
23
|
if (process.versions.node && defaultUserAgentString.indexOf("Node") === -1) {
|
|
@@ -607,13 +607,43 @@ class TranscriptService extends BaseService {
|
|
|
607
607
|
return await response.text();
|
|
608
608
|
}
|
|
609
609
|
/**
|
|
610
|
-
* Retrieve
|
|
610
|
+
* Retrieve the redacted audio URL of a transcript.
|
|
611
611
|
* @param id - The identifier of the transcript.
|
|
612
|
-
* @returns A promise that resolves to the
|
|
612
|
+
* @returns A promise that resolves to the details of the redacted audio.
|
|
613
|
+
* @deprecated Use `redactedAudio` instead.
|
|
613
614
|
*/
|
|
614
615
|
redactions(id) {
|
|
616
|
+
return this.redactedAudio(id);
|
|
617
|
+
}
|
|
618
|
+
/**
|
|
619
|
+
* Retrieve the redacted audio URL of a transcript.
|
|
620
|
+
* @param id - The identifier of the transcript.
|
|
621
|
+
* @returns A promise that resolves to the details of the redacted audio.
|
|
622
|
+
*/
|
|
623
|
+
redactedAudio(id) {
|
|
615
624
|
return this.fetchJson(`/v2/transcript/${id}/redacted-audio`);
|
|
616
625
|
}
|
|
626
|
+
/**
|
|
627
|
+
* Retrieve the redacted audio file of a transcript.
|
|
628
|
+
* @param id - The identifier of the transcript.
|
|
629
|
+
* @returns A promise that resolves to the fetch HTTP response of the redacted audio file.
|
|
630
|
+
*/
|
|
631
|
+
async redactedAudioFile(id) {
|
|
632
|
+
const { redacted_audio_url, status } = await this.redactedAudio(id);
|
|
633
|
+
if (status !== "redacted_audio_ready") {
|
|
634
|
+
throw new Error(`Redacted audio status is ${status}`);
|
|
635
|
+
}
|
|
636
|
+
const response = await fetch(redacted_audio_url);
|
|
637
|
+
if (!response.ok) {
|
|
638
|
+
throw new Error(`Failed to fetch redacted audio: ${response.statusText}`);
|
|
639
|
+
}
|
|
640
|
+
return {
|
|
641
|
+
arrayBuffer: response.arrayBuffer.bind(response),
|
|
642
|
+
blob: response.blob.bind(response),
|
|
643
|
+
body: response.body,
|
|
644
|
+
bodyUsed: response.bodyUsed,
|
|
645
|
+
};
|
|
646
|
+
}
|
|
617
647
|
}
|
|
618
648
|
function deprecateConformer2(params) {
|
|
619
649
|
if (!params)
|
package/dist/index.cjs
CHANGED
|
@@ -47,7 +47,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
47
47
|
};
|
|
48
48
|
|
|
49
49
|
const DEFAULT_FETCH_INIT = {
|
|
50
|
-
cache: "no-store"
|
|
50
|
+
cache: "no-store",
|
|
51
51
|
};
|
|
52
52
|
|
|
53
53
|
const buildUserAgent = (userAgent) => defaultUserAgentString +
|
|
@@ -63,7 +63,7 @@ if (typeof navigator !== "undefined" && navigator.userAgent) {
|
|
|
63
63
|
defaultUserAgentString += navigator.userAgent;
|
|
64
64
|
}
|
|
65
65
|
const defaultUserAgent = {
|
|
66
|
-
sdk: { name: "JavaScript", version: "4.4.
|
|
66
|
+
sdk: { name: "JavaScript", version: "4.4.7" },
|
|
67
67
|
};
|
|
68
68
|
if (typeof process !== "undefined") {
|
|
69
69
|
if (process.versions.node && defaultUserAgentString.indexOf("Node") === -1) {
|
|
@@ -683,13 +683,45 @@ class TranscriptService extends BaseService {
|
|
|
683
683
|
});
|
|
684
684
|
}
|
|
685
685
|
/**
|
|
686
|
-
* Retrieve
|
|
686
|
+
* Retrieve the redacted audio URL of a transcript.
|
|
687
687
|
* @param id - The identifier of the transcript.
|
|
688
|
-
* @returns A promise that resolves to the
|
|
688
|
+
* @returns A promise that resolves to the details of the redacted audio.
|
|
689
|
+
* @deprecated Use `redactedAudio` instead.
|
|
689
690
|
*/
|
|
690
691
|
redactions(id) {
|
|
692
|
+
return this.redactedAudio(id);
|
|
693
|
+
}
|
|
694
|
+
/**
|
|
695
|
+
* Retrieve the redacted audio URL of a transcript.
|
|
696
|
+
* @param id - The identifier of the transcript.
|
|
697
|
+
* @returns A promise that resolves to the details of the redacted audio.
|
|
698
|
+
*/
|
|
699
|
+
redactedAudio(id) {
|
|
691
700
|
return this.fetchJson(`/v2/transcript/${id}/redacted-audio`);
|
|
692
701
|
}
|
|
702
|
+
/**
|
|
703
|
+
* Retrieve the redacted audio file of a transcript.
|
|
704
|
+
* @param id - The identifier of the transcript.
|
|
705
|
+
* @returns A promise that resolves to the fetch HTTP response of the redacted audio file.
|
|
706
|
+
*/
|
|
707
|
+
redactedAudioFile(id) {
|
|
708
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
709
|
+
const { redacted_audio_url, status } = yield this.redactedAudio(id);
|
|
710
|
+
if (status !== "redacted_audio_ready") {
|
|
711
|
+
throw new Error(`Redacted audio status is ${status}`);
|
|
712
|
+
}
|
|
713
|
+
const response = yield fetch(redacted_audio_url);
|
|
714
|
+
if (!response.ok) {
|
|
715
|
+
throw new Error(`Failed to fetch redacted audio: ${response.statusText}`);
|
|
716
|
+
}
|
|
717
|
+
return {
|
|
718
|
+
arrayBuffer: response.arrayBuffer.bind(response),
|
|
719
|
+
blob: response.blob.bind(response),
|
|
720
|
+
body: response.body,
|
|
721
|
+
bodyUsed: response.bodyUsed,
|
|
722
|
+
};
|
|
723
|
+
});
|
|
724
|
+
}
|
|
693
725
|
}
|
|
694
726
|
function deprecateConformer2(params) {
|
|
695
727
|
if (!params)
|
package/dist/index.mjs
CHANGED
|
@@ -45,7 +45,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
45
45
|
};
|
|
46
46
|
|
|
47
47
|
const DEFAULT_FETCH_INIT = {
|
|
48
|
-
cache: "no-store"
|
|
48
|
+
cache: "no-store",
|
|
49
49
|
};
|
|
50
50
|
|
|
51
51
|
const buildUserAgent = (userAgent) => defaultUserAgentString +
|
|
@@ -61,7 +61,7 @@ if (typeof navigator !== "undefined" && navigator.userAgent) {
|
|
|
61
61
|
defaultUserAgentString += navigator.userAgent;
|
|
62
62
|
}
|
|
63
63
|
const defaultUserAgent = {
|
|
64
|
-
sdk: { name: "JavaScript", version: "4.4.
|
|
64
|
+
sdk: { name: "JavaScript", version: "4.4.7" },
|
|
65
65
|
};
|
|
66
66
|
if (typeof process !== "undefined") {
|
|
67
67
|
if (process.versions.node && defaultUserAgentString.indexOf("Node") === -1) {
|
|
@@ -681,13 +681,45 @@ class TranscriptService extends BaseService {
|
|
|
681
681
|
});
|
|
682
682
|
}
|
|
683
683
|
/**
|
|
684
|
-
* Retrieve
|
|
684
|
+
* Retrieve the redacted audio URL of a transcript.
|
|
685
685
|
* @param id - The identifier of the transcript.
|
|
686
|
-
* @returns A promise that resolves to the
|
|
686
|
+
* @returns A promise that resolves to the details of the redacted audio.
|
|
687
|
+
* @deprecated Use `redactedAudio` instead.
|
|
687
688
|
*/
|
|
688
689
|
redactions(id) {
|
|
690
|
+
return this.redactedAudio(id);
|
|
691
|
+
}
|
|
692
|
+
/**
|
|
693
|
+
* Retrieve the redacted audio URL of a transcript.
|
|
694
|
+
* @param id - The identifier of the transcript.
|
|
695
|
+
* @returns A promise that resolves to the details of the redacted audio.
|
|
696
|
+
*/
|
|
697
|
+
redactedAudio(id) {
|
|
689
698
|
return this.fetchJson(`/v2/transcript/${id}/redacted-audio`);
|
|
690
699
|
}
|
|
700
|
+
/**
|
|
701
|
+
* Retrieve the redacted audio file of a transcript.
|
|
702
|
+
* @param id - The identifier of the transcript.
|
|
703
|
+
* @returns A promise that resolves to the fetch HTTP response of the redacted audio file.
|
|
704
|
+
*/
|
|
705
|
+
redactedAudioFile(id) {
|
|
706
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
707
|
+
const { redacted_audio_url, status } = yield this.redactedAudio(id);
|
|
708
|
+
if (status !== "redacted_audio_ready") {
|
|
709
|
+
throw new Error(`Redacted audio status is ${status}`);
|
|
710
|
+
}
|
|
711
|
+
const response = yield fetch(redacted_audio_url);
|
|
712
|
+
if (!response.ok) {
|
|
713
|
+
throw new Error(`Failed to fetch redacted audio: ${response.statusText}`);
|
|
714
|
+
}
|
|
715
|
+
return {
|
|
716
|
+
arrayBuffer: response.arrayBuffer.bind(response),
|
|
717
|
+
blob: response.blob.bind(response),
|
|
718
|
+
body: response.body,
|
|
719
|
+
bodyUsed: response.bodyUsed,
|
|
720
|
+
};
|
|
721
|
+
});
|
|
722
|
+
}
|
|
691
723
|
}
|
|
692
724
|
function deprecateConformer2(params) {
|
|
693
725
|
if (!params)
|
package/dist/node.cjs
CHANGED
|
@@ -6,7 +6,7 @@ var fs = require('fs');
|
|
|
6
6
|
var stream = require('stream');
|
|
7
7
|
|
|
8
8
|
const DEFAULT_FETCH_INIT = {
|
|
9
|
-
cache: "no-store"
|
|
9
|
+
cache: "no-store",
|
|
10
10
|
};
|
|
11
11
|
|
|
12
12
|
const buildUserAgent = (userAgent) => defaultUserAgentString +
|
|
@@ -22,7 +22,7 @@ if (typeof navigator !== "undefined" && navigator.userAgent) {
|
|
|
22
22
|
defaultUserAgentString += navigator.userAgent;
|
|
23
23
|
}
|
|
24
24
|
const defaultUserAgent = {
|
|
25
|
-
sdk: { name: "JavaScript", version: "4.4.
|
|
25
|
+
sdk: { name: "JavaScript", version: "4.4.7" },
|
|
26
26
|
};
|
|
27
27
|
if (typeof process !== "undefined") {
|
|
28
28
|
if (process.versions.node && defaultUserAgentString.indexOf("Node") === -1) {
|
|
@@ -606,13 +606,43 @@ class TranscriptService extends BaseService {
|
|
|
606
606
|
return await response.text();
|
|
607
607
|
}
|
|
608
608
|
/**
|
|
609
|
-
* Retrieve
|
|
609
|
+
* Retrieve the redacted audio URL of a transcript.
|
|
610
610
|
* @param id - The identifier of the transcript.
|
|
611
|
-
* @returns A promise that resolves to the
|
|
611
|
+
* @returns A promise that resolves to the details of the redacted audio.
|
|
612
|
+
* @deprecated Use `redactedAudio` instead.
|
|
612
613
|
*/
|
|
613
614
|
redactions(id) {
|
|
615
|
+
return this.redactedAudio(id);
|
|
616
|
+
}
|
|
617
|
+
/**
|
|
618
|
+
* Retrieve the redacted audio URL of a transcript.
|
|
619
|
+
* @param id - The identifier of the transcript.
|
|
620
|
+
* @returns A promise that resolves to the details of the redacted audio.
|
|
621
|
+
*/
|
|
622
|
+
redactedAudio(id) {
|
|
614
623
|
return this.fetchJson(`/v2/transcript/${id}/redacted-audio`);
|
|
615
624
|
}
|
|
625
|
+
/**
|
|
626
|
+
* Retrieve the redacted audio file of a transcript.
|
|
627
|
+
* @param id - The identifier of the transcript.
|
|
628
|
+
* @returns A promise that resolves to the fetch HTTP response of the redacted audio file.
|
|
629
|
+
*/
|
|
630
|
+
async redactedAudioFile(id) {
|
|
631
|
+
const { redacted_audio_url, status } = await this.redactedAudio(id);
|
|
632
|
+
if (status !== "redacted_audio_ready") {
|
|
633
|
+
throw new Error(`Redacted audio status is ${status}`);
|
|
634
|
+
}
|
|
635
|
+
const response = await fetch(redacted_audio_url);
|
|
636
|
+
if (!response.ok) {
|
|
637
|
+
throw new Error(`Failed to fetch redacted audio: ${response.statusText}`);
|
|
638
|
+
}
|
|
639
|
+
return {
|
|
640
|
+
arrayBuffer: response.arrayBuffer.bind(response),
|
|
641
|
+
blob: response.blob.bind(response),
|
|
642
|
+
body: response.body,
|
|
643
|
+
bodyUsed: response.bodyUsed,
|
|
644
|
+
};
|
|
645
|
+
}
|
|
616
646
|
}
|
|
617
647
|
function deprecateConformer2(params) {
|
|
618
648
|
if (!params)
|
package/dist/node.mjs
CHANGED
|
@@ -4,7 +4,7 @@ import { createReadStream } from 'fs';
|
|
|
4
4
|
import { Readable } from 'stream';
|
|
5
5
|
|
|
6
6
|
const DEFAULT_FETCH_INIT = {
|
|
7
|
-
cache: "no-store"
|
|
7
|
+
cache: "no-store",
|
|
8
8
|
};
|
|
9
9
|
|
|
10
10
|
const buildUserAgent = (userAgent) => defaultUserAgentString +
|
|
@@ -20,7 +20,7 @@ if (typeof navigator !== "undefined" && navigator.userAgent) {
|
|
|
20
20
|
defaultUserAgentString += navigator.userAgent;
|
|
21
21
|
}
|
|
22
22
|
const defaultUserAgent = {
|
|
23
|
-
sdk: { name: "JavaScript", version: "4.4.
|
|
23
|
+
sdk: { name: "JavaScript", version: "4.4.7" },
|
|
24
24
|
};
|
|
25
25
|
if (typeof process !== "undefined") {
|
|
26
26
|
if (process.versions.node && defaultUserAgentString.indexOf("Node") === -1) {
|
|
@@ -604,13 +604,43 @@ class TranscriptService extends BaseService {
|
|
|
604
604
|
return await response.text();
|
|
605
605
|
}
|
|
606
606
|
/**
|
|
607
|
-
* Retrieve
|
|
607
|
+
* Retrieve the redacted audio URL of a transcript.
|
|
608
608
|
* @param id - The identifier of the transcript.
|
|
609
|
-
* @returns A promise that resolves to the
|
|
609
|
+
* @returns A promise that resolves to the details of the redacted audio.
|
|
610
|
+
* @deprecated Use `redactedAudio` instead.
|
|
610
611
|
*/
|
|
611
612
|
redactions(id) {
|
|
613
|
+
return this.redactedAudio(id);
|
|
614
|
+
}
|
|
615
|
+
/**
|
|
616
|
+
* Retrieve the redacted audio URL of a transcript.
|
|
617
|
+
* @param id - The identifier of the transcript.
|
|
618
|
+
* @returns A promise that resolves to the details of the redacted audio.
|
|
619
|
+
*/
|
|
620
|
+
redactedAudio(id) {
|
|
612
621
|
return this.fetchJson(`/v2/transcript/${id}/redacted-audio`);
|
|
613
622
|
}
|
|
623
|
+
/**
|
|
624
|
+
* Retrieve the redacted audio file of a transcript.
|
|
625
|
+
* @param id - The identifier of the transcript.
|
|
626
|
+
* @returns A promise that resolves to the fetch HTTP response of the redacted audio file.
|
|
627
|
+
*/
|
|
628
|
+
async redactedAudioFile(id) {
|
|
629
|
+
const { redacted_audio_url, status } = await this.redactedAudio(id);
|
|
630
|
+
if (status !== "redacted_audio_ready") {
|
|
631
|
+
throw new Error(`Redacted audio status is ${status}`);
|
|
632
|
+
}
|
|
633
|
+
const response = await fetch(redacted_audio_url);
|
|
634
|
+
if (!response.ok) {
|
|
635
|
+
throw new Error(`Failed to fetch redacted audio: ${response.statusText}`);
|
|
636
|
+
}
|
|
637
|
+
return {
|
|
638
|
+
arrayBuffer: response.arrayBuffer.bind(response),
|
|
639
|
+
blob: response.blob.bind(response),
|
|
640
|
+
body: response.body,
|
|
641
|
+
bodyUsed: response.bodyUsed,
|
|
642
|
+
};
|
|
643
|
+
}
|
|
614
644
|
}
|
|
615
645
|
function deprecateConformer2(params) {
|
|
616
646
|
if (!params)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BaseService } from "../base";
|
|
2
|
-
import { ParagraphsResponse, SentencesResponse, Transcript, TranscriptList, TranscriptParams, CreateTranscriptOptions, SubtitleFormat, RedactedAudioResponse, ListTranscriptParams, WordSearchResponse, BaseServiceParams, PollingOptions, TranscribeParams, TranscribeOptions, SubmitParams } from "../..";
|
|
2
|
+
import { ParagraphsResponse, SentencesResponse, Transcript, TranscriptList, TranscriptParams, CreateTranscriptOptions, SubtitleFormat, RedactedAudioResponse, ListTranscriptParams, WordSearchResponse, BaseServiceParams, PollingOptions, TranscribeParams, TranscribeOptions, SubmitParams, RedactedAudioFile } from "../..";
|
|
3
3
|
import { FileService } from "../files";
|
|
4
4
|
export declare class TranscriptService extends BaseService {
|
|
5
5
|
private files;
|
|
@@ -78,9 +78,22 @@ export declare class TranscriptService extends BaseService {
|
|
|
78
78
|
*/
|
|
79
79
|
subtitles(id: string, format?: SubtitleFormat, chars_per_caption?: number): Promise<string>;
|
|
80
80
|
/**
|
|
81
|
-
* Retrieve
|
|
81
|
+
* Retrieve the redacted audio URL of a transcript.
|
|
82
82
|
* @param id - The identifier of the transcript.
|
|
83
|
-
* @returns A promise that resolves to the
|
|
83
|
+
* @returns A promise that resolves to the details of the redacted audio.
|
|
84
|
+
* @deprecated Use `redactedAudio` instead.
|
|
84
85
|
*/
|
|
85
86
|
redactions(id: string): Promise<RedactedAudioResponse>;
|
|
87
|
+
/**
|
|
88
|
+
* Retrieve the redacted audio URL of a transcript.
|
|
89
|
+
* @param id - The identifier of the transcript.
|
|
90
|
+
* @returns A promise that resolves to the details of the redacted audio.
|
|
91
|
+
*/
|
|
92
|
+
redactedAudio(id: string): Promise<RedactedAudioResponse>;
|
|
93
|
+
/**
|
|
94
|
+
* Retrieve the redacted audio file of a transcript.
|
|
95
|
+
* @param id - The identifier of the transcript.
|
|
96
|
+
* @returns A promise that resolves to the fetch HTTP response of the redacted audio file.
|
|
97
|
+
*/
|
|
98
|
+
redactedAudioFile(id: string): Promise<RedactedAudioFile>;
|
|
86
99
|
}
|
|
@@ -46,3 +46,12 @@ export type SubmitParams = TranscribeParams;
|
|
|
46
46
|
* The options to transcribe an audio file, including polling options.
|
|
47
47
|
*/
|
|
48
48
|
export type TranscribeOptions = PollingOptions;
|
|
49
|
+
/**
|
|
50
|
+
* The PII redacted audio file, transmitted over the network.
|
|
51
|
+
*/
|
|
52
|
+
export type RedactedAudioFile = {
|
|
53
|
+
arrayBuffer: () => Promise<ArrayBuffer>;
|
|
54
|
+
blob: () => Promise<Blob>;
|
|
55
|
+
body: ReadableStream<Uint8Array> | null;
|
|
56
|
+
bodyUsed: boolean;
|
|
57
|
+
};
|
package/dist/workerd.mjs
CHANGED
|
@@ -15,7 +15,7 @@ if (typeof navigator !== "undefined" && navigator.userAgent) {
|
|
|
15
15
|
defaultUserAgentString += navigator.userAgent;
|
|
16
16
|
}
|
|
17
17
|
const defaultUserAgent = {
|
|
18
|
-
sdk: { name: "JavaScript", version: "4.4.
|
|
18
|
+
sdk: { name: "JavaScript", version: "4.4.7" },
|
|
19
19
|
};
|
|
20
20
|
if (typeof process !== "undefined") {
|
|
21
21
|
if (process.versions.node && defaultUserAgentString.indexOf("Node") === -1) {
|
|
@@ -605,13 +605,43 @@ class TranscriptService extends BaseService {
|
|
|
605
605
|
return await response.text();
|
|
606
606
|
}
|
|
607
607
|
/**
|
|
608
|
-
* Retrieve
|
|
608
|
+
* Retrieve the redacted audio URL of a transcript.
|
|
609
609
|
* @param id - The identifier of the transcript.
|
|
610
|
-
* @returns A promise that resolves to the
|
|
610
|
+
* @returns A promise that resolves to the details of the redacted audio.
|
|
611
|
+
* @deprecated Use `redactedAudio` instead.
|
|
611
612
|
*/
|
|
612
613
|
redactions(id) {
|
|
614
|
+
return this.redactedAudio(id);
|
|
615
|
+
}
|
|
616
|
+
/**
|
|
617
|
+
* Retrieve the redacted audio URL of a transcript.
|
|
618
|
+
* @param id - The identifier of the transcript.
|
|
619
|
+
* @returns A promise that resolves to the details of the redacted audio.
|
|
620
|
+
*/
|
|
621
|
+
redactedAudio(id) {
|
|
613
622
|
return this.fetchJson(`/v2/transcript/${id}/redacted-audio`);
|
|
614
623
|
}
|
|
624
|
+
/**
|
|
625
|
+
* Retrieve the redacted audio file of a transcript.
|
|
626
|
+
* @param id - The identifier of the transcript.
|
|
627
|
+
* @returns A promise that resolves to the fetch HTTP response of the redacted audio file.
|
|
628
|
+
*/
|
|
629
|
+
async redactedAudioFile(id) {
|
|
630
|
+
const { redacted_audio_url, status } = await this.redactedAudio(id);
|
|
631
|
+
if (status !== "redacted_audio_ready") {
|
|
632
|
+
throw new Error(`Redacted audio status is ${status}`);
|
|
633
|
+
}
|
|
634
|
+
const response = await fetch(redacted_audio_url);
|
|
635
|
+
if (!response.ok) {
|
|
636
|
+
throw new Error(`Failed to fetch redacted audio: ${response.statusText}`);
|
|
637
|
+
}
|
|
638
|
+
return {
|
|
639
|
+
arrayBuffer: response.arrayBuffer.bind(response),
|
|
640
|
+
blob: response.blob.bind(response),
|
|
641
|
+
body: response.body,
|
|
642
|
+
bodyUsed: response.bodyUsed,
|
|
643
|
+
};
|
|
644
|
+
}
|
|
615
645
|
}
|
|
616
646
|
function deprecateConformer2(params) {
|
|
617
647
|
if (!params)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "assemblyai",
|
|
3
|
-
"version": "4.4.7
|
|
3
|
+
"version": "4.4.7",
|
|
4
4
|
"description": "The AssemblyAI JavaScript SDK provides an easy-to-use interface for interacting with the AssemblyAI API, which supports async and real-time transcription, as well as the latest LeMUR models.",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=18"
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"./package.json": "./package.json"
|
|
39
39
|
},
|
|
40
40
|
"imports": {
|
|
41
|
-
"#fetch":{
|
|
41
|
+
"#fetch": {
|
|
42
42
|
"workerd": "./src/polyfills/fetch/workerd.ts",
|
|
43
43
|
"default": "./src/polyfills/fetch/default.ts"
|
|
44
44
|
},
|
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
"url": "git+https://github.com/AssemblyAI/assemblyai-node-sdk.git"
|
|
72
72
|
},
|
|
73
73
|
"publishConfig": {
|
|
74
|
-
"tag": "
|
|
74
|
+
"tag": "latest",
|
|
75
75
|
"access": "public",
|
|
76
76
|
"registry": "https://registry.npmjs.org/"
|
|
77
77
|
},
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export const DEFAULT_FETCH_INIT: Record<string, unknown> = {
|
|
2
|
-
cache: "no-store"
|
|
3
|
-
};
|
|
2
|
+
cache: "no-store",
|
|
3
|
+
};
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export const DEFAULT_FETCH_INIT: Record<string, unknown> = {
|
|
2
|
-
};
|
|
1
|
+
export const DEFAULT_FETCH_INIT: Record<string, unknown> = {};
|
package/src/services/base.ts
CHANGED
|
@@ -27,7 +27,8 @@ export abstract class BaseService {
|
|
|
27
27
|
Authorization: this.params.apiKey,
|
|
28
28
|
"Content-Type": "application/json",
|
|
29
29
|
};
|
|
30
|
-
if (DEFAULT_FETCH_INIT?.headers)
|
|
30
|
+
if (DEFAULT_FETCH_INIT?.headers)
|
|
31
|
+
headers = { ...headers, ...DEFAULT_FETCH_INIT.headers };
|
|
31
32
|
if (init?.headers) headers = { ...headers, ...init.headers };
|
|
32
33
|
|
|
33
34
|
if (this.userAgent) {
|
|
@@ -16,6 +16,7 @@ import {
|
|
|
16
16
|
TranscribeOptions,
|
|
17
17
|
SubmitParams,
|
|
18
18
|
SpeechModel,
|
|
19
|
+
RedactedAudioFile,
|
|
19
20
|
} from "../..";
|
|
20
21
|
import { FileService } from "../files";
|
|
21
22
|
import { getPath } from "../../utils/path";
|
|
@@ -244,15 +245,47 @@ export class TranscriptService extends BaseService {
|
|
|
244
245
|
}
|
|
245
246
|
|
|
246
247
|
/**
|
|
247
|
-
* Retrieve
|
|
248
|
+
* Retrieve the redacted audio URL of a transcript.
|
|
248
249
|
* @param id - The identifier of the transcript.
|
|
249
|
-
* @returns A promise that resolves to the
|
|
250
|
+
* @returns A promise that resolves to the details of the redacted audio.
|
|
251
|
+
* @deprecated Use `redactedAudio` instead.
|
|
250
252
|
*/
|
|
251
253
|
redactions(id: string): Promise<RedactedAudioResponse> {
|
|
254
|
+
return this.redactedAudio(id);
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* Retrieve the redacted audio URL of a transcript.
|
|
259
|
+
* @param id - The identifier of the transcript.
|
|
260
|
+
* @returns A promise that resolves to the details of the redacted audio.
|
|
261
|
+
*/
|
|
262
|
+
redactedAudio(id: string): Promise<RedactedAudioResponse> {
|
|
252
263
|
return this.fetchJson<RedactedAudioResponse>(
|
|
253
264
|
`/v2/transcript/${id}/redacted-audio`,
|
|
254
265
|
);
|
|
255
266
|
}
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* Retrieve the redacted audio file of a transcript.
|
|
270
|
+
* @param id - The identifier of the transcript.
|
|
271
|
+
* @returns A promise that resolves to the fetch HTTP response of the redacted audio file.
|
|
272
|
+
*/
|
|
273
|
+
async redactedAudioFile(id: string): Promise<RedactedAudioFile> {
|
|
274
|
+
const { redacted_audio_url, status } = await this.redactedAudio(id);
|
|
275
|
+
if (status !== "redacted_audio_ready") {
|
|
276
|
+
throw new Error(`Redacted audio status is ${status}`);
|
|
277
|
+
}
|
|
278
|
+
const response = await fetch(redacted_audio_url);
|
|
279
|
+
if (!response.ok) {
|
|
280
|
+
throw new Error(`Failed to fetch redacted audio: ${response.statusText}`);
|
|
281
|
+
}
|
|
282
|
+
return {
|
|
283
|
+
arrayBuffer: response.arrayBuffer.bind(response),
|
|
284
|
+
blob: response.blob.bind(response),
|
|
285
|
+
body: response.body,
|
|
286
|
+
bodyUsed: response.bodyUsed,
|
|
287
|
+
};
|
|
288
|
+
}
|
|
256
289
|
}
|
|
257
290
|
|
|
258
291
|
function deprecateConformer2(params: { speech_model?: SpeechModel | null }) {
|
|
@@ -54,3 +54,13 @@ export type SubmitParams = TranscribeParams;
|
|
|
54
54
|
* The options to transcribe an audio file, including polling options.
|
|
55
55
|
*/
|
|
56
56
|
export type TranscribeOptions = PollingOptions;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* The PII redacted audio file, transmitted over the network.
|
|
60
|
+
*/
|
|
61
|
+
export type RedactedAudioFile = {
|
|
62
|
+
arrayBuffer: () => Promise<ArrayBuffer>;
|
|
63
|
+
blob: () => Promise<Blob>;
|
|
64
|
+
body: ReadableStream<Uint8Array> | null;
|
|
65
|
+
bodyUsed: boolean;
|
|
66
|
+
};
|
package/README.internal.md
DELETED
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
# AssemblyAI JavaScript SDK
|
|
2
|
-
|
|
3
|
-
The AssemblyAI JavaScript SDK is developed using:
|
|
4
|
-
|
|
5
|
-
- Language: TypeScript
|
|
6
|
-
- Testing: Jest
|
|
7
|
-
- Bundler: Rollup
|
|
8
|
-
- Package manager: pnpm
|
|
9
|
-
|
|
10
|
-
## Private vs public spec repository
|
|
11
|
-
|
|
12
|
-
This README.internal.md file and adjacent files are stored in
|
|
13
|
-
the [DeepLearning monorepo](#private-deeplearning-monorepo), which is private for AssemblyAI employees only.
|
|
14
|
-
|
|
15
|
-
Most files are also synced to the [public spec repo](#public-spec-repo) using [Copybara](#copybara).
|
|
16
|
-
|
|
17
|
-
### Private DeepLearning monorepo
|
|
18
|
-
|
|
19
|
-
While most of the files in this folder are shared publicly using the public spec repo,
|
|
20
|
-
some files should only be kept in the [private repo](https://github.com/AssemblyAI/DeepLearning), like this README.internal.md.
|
|
21
|
-
|
|
22
|
-
The files that are synced are defined in the [Copybara configuration](./copy.bara.sky).
|
|
23
|
-
|
|
24
|
-
### Public spec repo
|
|
25
|
-
|
|
26
|
-
[The public spec repo](https://github.com/AssemblyAI/assemblyai-node-sdk) has multiple purposes:
|
|
27
|
-
|
|
28
|
-
1. Open-source the SDK code
|
|
29
|
-
2. Accept feedback & contributions through issues and PRs
|
|
30
|
-
3. Release the SDK to npmjs
|
|
31
|
-
4. Publish the API reference using GitHub Actions
|
|
32
|
-
|
|
33
|
-
## Copybara
|
|
34
|
-
|
|
35
|
-
We use [Copybara](https://github.com/google/copybara) to synchronize the private and public repo.
|
|
36
|
-
Copybara relies on [Bazel](https://bazel.build/) as part of the monorepo tooling.
|
|
37
|
-
To use the Copybara scripts, you must [set up Bazel](../../../docs/general/installation/05-bazel.md).
|
|
38
|
-
|
|
39
|
-
To create a PR with synced changes from the private to the public repo, run the following:
|
|
40
|
-
|
|
41
|
-
```bash
|
|
42
|
-
./copybara.sh sync_out --init-history
|
|
43
|
-
## or the pnpm script
|
|
44
|
-
# pnpm copybara:pr
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
To verify the synced changes before create the PR, you can also perform a _dry run_:
|
|
48
|
-
|
|
49
|
-
```bash
|
|
50
|
-
./copybara.sh dry_run --init-history
|
|
51
|
-
## or the pnpm script
|
|
52
|
-
# pnpm copybara:dry-run
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
The Copybara configuration is defined in [copy.bara.sky](./copy.bara.sky).
|
|
56
|
-
|
|
57
|
-
## Contribute to the JavaScript SDK
|
|
58
|
-
|
|
59
|
-
If you want to contribute to the spec, you should do so via the [private monorepo](#private-deeplearning-monorepo).
|
|
60
|
-
The private repo enforces our internal rules and peer-reviews.
|
|
61
|
-
|
|
62
|
-
### Set up
|
|
63
|
-
|
|
64
|
-
Follow these steps to set up the private repo:
|
|
65
|
-
|
|
66
|
-
1. Clone the [monorepo](https://github.com/AssemblyAI/DeepLearning).
|
|
67
|
-
2. [Set up Bazel](../../../docs/general/installation/05-bazel.md).
|
|
68
|
-
3. [Set up pnpm (version 8)](https://pnpm.io/installation).
|
|
69
|
-
|
|
70
|
-
### Make changes
|
|
71
|
-
|
|
72
|
-
Refer to the [CONTRIBUTING.md](./CONTRIBUTING.md) file for guidance on how to contribute.
|
|
73
|
-
The CONTRIBUTING.md file is written for contributors that don't work at AssemblyAI.
|
|
74
|
-
|
|
75
|
-
For AssemblyAI, the development workflow differs in the following ways:
|
|
76
|
-
|
|
77
|
-
- Instead of forking the public repo and cloning it, clone the monorepo.
|
|
78
|
-
- Get the latest changes from the `master` branch, not the `main` branch.
|
|
79
|
-
- Commit your changes, push your branch, and create a pull request (follow [the PR guidelines](../../../docs/general/pr_process.md)).
|
|
80
|
-
- Your PR will be checked using GitHub Actions. These checks run [Bazel](#Bazel) targets.
|
|
81
|
-
|
|
82
|
-
### Push changes to public repo
|
|
83
|
-
|
|
84
|
-
Follow these steps to push your changes to the public spec repo:
|
|
85
|
-
|
|
86
|
-
1. Make sure your changes have been merged into `master` via a PR.
|
|
87
|
-
2. Git checkout `master` and get the latest changes.
|
|
88
|
-
3. Run `pnpm copybara:dry-run` and verify the output is desired.
|
|
89
|
-
If not desired, update the [copy.bara.sky](./copy.bara.sky) file.
|
|
90
|
-
4. Run `pnpm copybara:pr`.
|
|
91
|
-
5. Go to the new PR, update the title and description.
|
|
92
|
-
6. Ensure the checks pass for the PR before merging the PR to `main`.
|
|
93
|
-
|
|
94
|
-
## Notes about the JavaScript SDK
|
|
95
|
-
|
|
96
|
-
### Bazel
|
|
97
|
-
|
|
98
|
-
Bazel is used to automate and ensure code quality inside the DeepLearning monorepo.
|
|
99
|
-
GitHub Actions will run a variety of checks which run Bazel targets defined for the
|
|
100
|
-
whole repo, and additional targets defined in [BUILD.bazel](./BUILD.bazel).
|