1// 2.2.3 2import { d as k, g as Wp, e as Hp } from "./index-DVPerhZa.js"; 3function Kp(t, e) { 4 for (var r = 0; r < e.length; r++) { 5 const s = e[r]; 6 if (typeof s != "string" && !Array.isArray(s)) { 7 for (const p in s) 8 if (p !== "default" && !(p in t)) { 9 const a = Object.getOwnPropertyDescriptor(s, p); 10 a && Object.defineProperty(t, p, a.get ? a : { 11 enumerable: !0, 12 get: () => s[p] 13 }); 14 } 15 } 16 } 17 return Object.freeze(Object.defineProperty(t, Symbol.toStringTag, { value: "Module" })); 18} 19var On = {}, on = {}, Jr = {}, an = {}, B = {}, Ge = {}, oe = {}, ma = {}, Vr = {}, Gr = {}; 20Object.defineProperty(Gr, "__esModule", { 21 value: !0 22}); 23Gr.default = Vp; 24let Fr; 25const Jp = new Uint8Array(16); 26function Vp() { 27 if (!Fr && (Fr = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !Fr)) 28 throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported"); 29 return Fr(Jp); 30} 31var Te = {}, Fe = {}, Qr = {}; 32Object.defineProperty(Qr, "__esModule", { 33 value: !0 34}); 35Qr.default = void 0; 36var Gp = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i; 37Qr.default = Gp; 38Object.defineProperty(Fe, "__esModule", { 39 value: !0 40}); 41Fe.default = void 0; 42var Qp = Xp(Qr); 43function Xp(t) { 44 return t && t.__esModule ? t : { default: t }; 45} 46function Yp(t) { 47 return typeof t == "string" && Qp.default.test(t); 48} 49var Zp = Yp; 50Fe.default = Zp; 51Object.defineProperty(Te, "__esModule", { 52 value: !0 53}); 54Te.default = void 0; 55Te.unsafeStringify = Sa; 56var $p = eu(Fe); 57function eu(t) { 58 return t && t.__esModule ? t : { default: t }; 59} 60const F = []; 61for (let t = 0; t < 256; ++t) 62 F.push((t + 256).toString(16).slice(1)); 63function Sa(t, e = 0) { 64 return F[t[e + 0]] + F[t[e + 1]] + F[t[e + 2]] + F[t[e + 3]] + "-" + F[t[e + 4]] + F[t[e + 5]] + "-" + F[t[e + 6]] + F[t[e + 7]] + "-" + F[t[e + 8]] + F[t[e + 9]] + "-" + F[t[e + 10]] + F[t[e + 11]] + F[t[e + 12]] + F[t[e + 13]] + F[t[e + 14]] + F[t[e + 15]]; 65} 66function tu(t, e = 0) { 67 const r = Sa(t, e); 68 if (!(0, $p.default)(r)) 69 throw TypeError("Stringified UUID is invalid"); 70 return r; 71} 72var ru = tu; 73Te.default = ru; 74Object.defineProperty(Vr, "__esModule", { 75 value: !0 76}); 77Vr.default = void 0; 78var iu = su(Gr), nu = Te; 79function su(t) { 80 return t && t.__esModule ? t : { default: t }; 81} 82let os, cn, pn = 0, un = 0; 83function ou(t, e, r) { 84 let s = e && r || 0; 85 const p = e || new Array(16); 86 t = t || {}; 87 let a = t.node || os, n = t.clockseq !== void 0 ? t.clockseq : cn; 88 if (a == null || n == null) { 89 const d = t.random || (t.rng || iu.default)(); 90 a == null && (a = os = [d[0] | 1, d[1], d[2], d[3], d[4], d[5]]), n == null && (n = cn = (d[6] << 8 | d[7]) & 16383); 91 } 92 let i = t.msecs !== void 0 ? t.msecs : Date.now(), o = t.nsecs !== void 0 ? t.nsecs : un + 1; 93 const c = i - pn + (o - un) / 1e4; 94 if (c < 0 && t.clockseq === void 0 && (n = n + 1 & 16383), (c < 0 || i > pn) && t.nsecs === void 0 && (o = 0), o >= 1e4) 95 throw new Error("uuid.v1(): Can't create more than 10M uuids/sec"); 96 pn = i, un = o, cn = n, i += 122192928e5; 97 const u = ((i & 268435455) * 1e4 + o) % 4294967296; 98 p[s++] = u >>> 24 & 255, p[s++] = u >>> 16 & 255, p[s++] = u >>> 8 & 255, p[s++] = u & 255; 99 const h = i / 4294967296 * 1e4 & 268435455; 100 p[s++] = h >>> 8 & 255, p[s++] = h & 255, p[s++] = h >>> 24 & 15 | 16, p[s++] = h >>> 16 & 255, p[s++] = n >>> 8 | 128, p[s++] = n & 255; 101 for (let d = 0; d < 6; ++d) 102 p[s + d] = a[d]; 103 return e || (0, nu.unsafeStringify)(p); 104} 105var au = ou; 106Vr.default = au; 107var Xr = {}, Re = {}, _r = {}; 108Object.defineProperty(_r, "__esModule", { 109 value: !0 110}); 111_r.default = void 0; 112var cu = pu(Fe); 113function pu(t) { 114 return t && t.__esModule ? t : { default: t }; 115} 116function uu(t) { 117 if (!(0, cu.default)(t)) 118 throw TypeError("Invalid UUID"); 119 let e; 120 const r = new Uint8Array(16); 121 return r[0] = (e = parseInt(t.slice(0, 8), 16)) >>> 24, r[1] = e >>> 16 & 255, r[2] = e >>> 8 & 255, r[3] = e & 255, r[4] = (e = parseInt(t.slice(9, 13), 16)) >>> 8, r[5] = e & 255, r[6] = (e = parseInt(t.slice(14, 18), 16)) >>> 8, r[7] = e & 255, r[8] = (e = parseInt(t.slice(19, 23), 16)) >>> 8, r[9] = e & 255, r[10] = (e = parseInt(t.slice(24, 36), 16)) / 1099511627776 & 255, r[11] = e / 4294967296 & 255, r[12] = e >>> 24 & 255, r[13] = e >>> 16 & 255, r[14] = e >>> 8 & 255, r[15] = e & 255, r; 122} 123var hu = uu; 124_r.default = hu; 125Object.defineProperty(Re, "__esModule", { 126 value: !0 127}); 128Re.URL = Re.DNS = void 0; 129Re.default = gu; 130var du = Te, vu = lu(_r); 131function lu(t) { 132 return t && t.__esModule ? t : { default: t }; 133} 134function fu(t) { 135 t = unescape(encodeURIComponent(t)); 136 const e = []; 137 for (let r = 0; r < t.length; ++r) 138 e.push(t.charCodeAt(r)); 139 return e; 140} 141const Ca = "6ba7b810-9dad-11d1-80b4-00c04fd430c8"; 142Re.DNS = Ca; 143const ya = "6ba7b811-9dad-11d1-80b4-00c04fd430c8"; 144Re.URL = ya; 145function gu(t, e, r) { 146 function s(p, a, n, i) { 147 var o; 148 if (typeof p == "string" && (p = fu(p)), typeof a == "string" && (a = (0, vu.default)(a)), ((o = a) === null || o === void 0 ? void 0 : o.length) !== 16) 149 throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");
150 let c = new Uint8Array(16 + p.length); 151 if (c.set(a), c.set(p, a.length), c = r(c), c[6] = c[6] & 15 | e, c[8] = c[8] & 63 | 128, n) { 152 i = i || 0; 153 for (let u = 0; u < 16; ++u) 154 n[i + u] = c[u]; 155 return n; 156 } 157 return (0, du.unsafeStringify)(c); 158 } 159 try { 160 s.name = t; 161 } catch { 162 } 163 return s.DNS = Ca, s.URL = ya, s; 164} 165var Yr = {}; 166Object.defineProperty(Yr, "__esModule", { 167 value: !0 168}); 169Yr.default = void 0; 170function mu(t) { 171 if (typeof t == "string") { 172 const e = unescape(encodeURIComponent(t)); 173 t = new Uint8Array(e.length); 174 for (let r = 0; r < e.length; ++r) 175 t[r] = e.charCodeAt(r); 176 } 177 return Su(Cu(yu(t), t.length * 8)); 178} 179function Su(t) { 180 const e = [], r = t.length * 32, s = "0123456789abcdef"; 181 for (let p = 0; p < r; p += 8) { 182 const a = t[p >> 5] >>> p % 32 & 255, n = parseInt(s.charAt(a >>> 4 & 15) + s.charAt(a & 15), 16); 183 e.push(n); 184 } 185 return e; 186} 187function Pa(t) { 188 return (t + 64 >>> 9 << 4) + 14 + 1; 189} 190function Cu(t, e) { 191 t[e >> 5] |= 128 << e % 32, t[Pa(e) - 1] = e; 192 let r = 1732584193, s = -271733879, p = -1732584194, a = 271733878; 193 for (let n = 0; n < t.length; n += 16) { 194 const i = r, o = s, c = p, u = a; 195 r = K(r, s, p, a, t[n], 7, -680876936), a = K(a, r, s, p, t[n + 1], 12, -389564586), p = K(p, a, r, s, t[n + 2], 17, 606105819), s = K(s, p, a, r, t[n + 3], 22, -1044525330), r = K(r, s, p, a, t[n + 4], 7, -176418897), a = K(a, r, s, p, t[n + 5], 12, 1200080426), p = K(p, a, r, s, t[n + 6], 17, -1473231341), s = K(s, p, a, r, t[n + 7], 22, -45705983), r = K(r, s, p, a, t[n + 8], 7, 1770035416), a = K(a, r, s, p, t[n + 9], 12, -1958414417), p = K(p, a, r, s, t[n + 10], 17, -42063), s = K(s, p, a, r, t[n + 11], 22, -1990404162), r = K(r, s, p, a, t[n + 12], 7, 1804603682), a = K(a, r, s, p, t[n + 13], 12, -40341101), p = K(p, a, r, s, t[n + 14], 17, -1502002290), s = K(s, p, a, r, t[n + 15], 22, 1236535329), r = J(r, s, p, a, t[n + 1], 5, -165796510), a = J(a, r, s, p, t[n + 6], 9, -1069501632), p = J(p, a, r, s, t[n + 11], 14, 643717713), s = J(s, p, a, r, t[n], 20, -373897302), r = J(r, s, p, a, t[n + 5], 5, -701558691), a = J(a, r, s, p, t[n + 10], 9, 38016083), p = J(p, a, r, s, t[n + 15], 14, -660478335), s = J(s, p, a, r, t[n + 4], 20, -405537848), r = J(r, s, p, a, t[n + 9], 5, 568446438), a = J(a, r, s, p, t[n + 14], 9, -1019803690), p = J(p, a, r, s, t[n + 3], 14, -187363961), s = J(s, p, a, r, t[n + 8], 20, 1163531501), r = J(r, s, p, a, t[n + 13], 5, -1444681467), a = J(a, r, s, p, t[n + 2], 9, -51403784), p = J(p, a, r, s, t[n + 7], 14, 1735328473), s = J(s, p, a, r, t[n + 12], 20, -1926607734), r = V(r, s, p, a, t[n + 5], 4, -378558), a = V(a, r, s, p, t[n + 8], 11, -2022574463), p = V(p, a, r, s, t[n + 11], 16, 1839030562), s = V(s, p, a, r, t[n + 14], 23, -35309556), r = V(r, s, p, a, t[n + 1], 4, -1530992060), a = V(a, r, s, p, t[n + 4], 11, 1272893353), p = V(p, a, r, s, t[n + 7], 16, -155497632), s = V(s, p, a, r, t[n + 10], 23, -1094730640), r = V(r, s, p, a, t[n + 13], 4, 681279174), a = V(a, r, s, p, t[n], 11, -358537222), p = V(p, a, r, s, t[n + 3], 16, -722521979), s = V(s, p, a, r, t[n + 6], 23, 76029189), r = V(r, s, p, a, t[n + 9], 4, -640364487), a = V(a, r, s, p, t[n + 12], 11, -421815835), p = V(p, a, r, s, t[n + 15], 16, 530742520), s = V(s, p, a, r, t[n + 2], 23, -995338651), r = G(r, s, p, a, t[n], 6, -198630844), a = G(a, r, s, p, t[n + 7], 10, 1126891415), p = G(p, a, r, s, t[n + 14], 15, -1416354905), s = G(s, p, a, r, t[n + 5], 21, -57434055), r = G(r, s, p, a, t[n + 12], 6, 1700485571), a = G(a, r, s, p, t[n + 3], 10, -1894986606), p = G(p, a, r, s, t[n + 10], 15, -1051523), s = G(s, p, a, r, t[n + 1], 21, -2054922799), r = G(r, s, p, a, t[n + 8], 6, 1873313359), a = G(a, r, s, p, t[n + 15], 10, -30611744), p = G(p, a, r, s, t[n + 6], 15, -1560198380), s = G(s, p, a, r, t[n + 13], 21, 1309151649), r = G(r, s, p, a, t[n + 4], 6, -145523070), a = G(a, r, s, p, t[n + 11], 10, -1120210379), p = G(p, a, r, s, t[n + 2], 15, 718787259), s = G(s, p, a, r, t[n + 9], 21, -343485551), r = ye(r, i), s = ye(s, o), p = ye(p, c), a = ye(a, u); 196 } 197 return [r, s, p, a]; 198} 199function yu(t) { 200 if (t.length === 0) 201 return []; 202 const e = t.length * 8, r = new Uint32Array(Pa(e)); 203 for (let s = 0; s < e; s += 8) 204 r[s >> 5] |= (t[s / 8] & 255) << s % 32; 205 return r; 206} 207function ye(t, e) { 208 const r = (t & 65535) + (e & 65535); 209 return (t >> 16) + (e >> 16) + (r >> 16) << 16 | r & 65535; 210} 211function Pu(t, e) { 212 return t << e | t >>> 32 - e; 213} 214function Zr(t, e, r, s, p, a) { 215 return ye(Pu(ye(ye(e, t), ye(s, a)), p), r); 216} 217function K(t, e, r, s, p, a, n) { 218 return Zr(e & r | ~e & s, t, e, p, a, n); 219} 220function J(t, e, r, s, p, a, n) { 221 return Zr(e & s | r & ~s, t, e, p, a, n); 222} 223function V(t, e, r, s, p, a, n) { 224 return Zr(e ^ r ^ s, t, e, p, a, n); 225} 226function G(t, e, r, s, p, a, n) { 227 return Zr(r ^ (e | ~s), t, e, p, a, n); 228} 229var Ru = mu; 230Yr.default = Ru; 231Object.defineProperty(Xr, "__esModule", { 232 value: !0 233}); 234Xr.default = void 0; 235var Eu = Ra(Re), Tu = Ra(Yr); 236function Ra(t) { 237 return t && t.__esModule ? t : { default: t }; 238} 239const Au = (0, Eu.default)("v3", 48, Tu.default); 240var Iu = Au; 241Xr.default = Iu; 242var $r = {}, ei = {}; 243Object.defineProperty(ei, "__esModule", { 244 value: !0 245}); 246ei.default = void 0; 247const wu = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto); 248var _u = { 249 randomUUID: wu 250}; 251ei.default = _u; 252Object.defineProperty($r, "__esModule", { 253 value: !0 254}); 255$r.default = void 0; 256var as = Ea(ei), bu = Ea(Gr), Mu = Te; 257function Ea(t) { 258 return t && t.__esModule ? t : { default: t }; 259} 260function Ou(t, e, r) { 261 if (as.default.randomUUID && !e && !t) 262 return as.default.randomUUID(); 263 t = t || {}; 264 const s = t.random || (t.rng || bu.default)(); 265 if (s[6] = s[6] & 15 | 64, s[8] = s[8] & 63 | 128, e) { 266 r = r || 0; 267 for (let p = 0; p < 16; ++p) 268 e[r + p] = s[p]; 269 return e; 270 } 271 return (0, Mu.unsafeStringify)(s); 272} 273var Du = Ou; 274$r.default = Du; 275var ti = {}, ri = {}; 276Object.defineProperty(ri, "__esModule", { 277 value: !0 278}); 279ri.default = void 0; 280function ku(t, e, r, s) { 281 switch (t) { 282 case 0: 283 return e & r ^ ~e & s; 284 case 1: 285 return e ^ r ^ s; 286 case 2: 287 return e & r ^ e & s ^ r & s; 288 case 3: 289 return e ^ r ^ s; 290 } 291} 292function hn(t, e) { 293 return t << e | t >>> 32 - e; 294} 295function Nu(t) { 296 const e = [1518500249, 1859775393, 2400959708, 3395469782], r = [1732584193, 4023233417, 2562383102, 271733878, 3285377520]; 297 if (typeof t == "string") { 298 const n = unescape(encodeURIComponent(t)); 299 t = []; 300 for (let i = 0; i < n.length; ++i) 301 t.push(n.charCodeAt(i)); 302 } else Array.isArray(t) || (t = Array.prototype.slice.call(t)); 303 t.push(128); 304 const s = t.length / 4 + 2, p = Math.ceil(s / 16), a = new Array(p); 305 for (let n = 0; n < p; ++n) { 306 const i = new Uint32Array(16); 307 for (let o = 0; o < 16; ++o) 308 i[o] = t[n * 64 + o * 4] << 24 | t[n * 64 + o * 4 + 1] << 16 | t[n * 64 + o * 4 + 2] << 8 | t[n * 64 + o * 4 + 3]; 309 a[n] = i; 310 }
311 a[p - 1][14] = (t.length - 1) * 8 / Math.pow(2, 32), a[p - 1][14] = Math.floor(a[p - 1][14]), a[p - 1][15] = (t.length - 1) * 8 & 4294967295; 312 for (let n = 0; n < p; ++n) { 313 const i = new Uint32Array(80); 314 for (let v = 0; v < 16; ++v) 315 i[v] = a[n][v]; 316 for (let v = 16; v < 80; ++v) 317 i[v] = hn(i[v - 3] ^ i[v - 8] ^ i[v - 14] ^ i[v - 16], 1); 318 let o = r[0], c = r[1], u = r[2], h = r[3], d = r[4]; 319 for (let v = 0; v < 80; ++v) { 320 const f = Math.floor(v / 20), m = hn(o, 5) + ku(f, c, u, h) + d + e[f] + i[v] >>> 0; 321 d = h, h = u, u = hn(c, 30) >>> 0, c = o, o = m; 322 } 323 r[0] = r[0] + o >>> 0, r[1] = r[1] + c >>> 0, r[2] = r[2] + u >>> 0, r[3] = r[3] + h >>> 0, r[4] = r[4] + d >>> 0; 324 } 325 return [r[0] >> 24 & 255, r[0] >> 16 & 255, r[0] >> 8 & 255, r[0] & 255, r[1] >> 24 & 255, r[1] >> 16 & 255, r[1] >> 8 & 255, r[1] & 255, r[2] >> 24 & 255, r[2] >> 16 & 255, r[2] >> 8 & 255, r[2] & 255, r[3] >> 24 & 255, r[3] >> 16 & 255, r[3] >> 8 & 255, r[3] & 255, r[4] >> 24 & 255, r[4] >> 16 & 255, r[4] >> 8 & 255, r[4] & 255]; 326} 327var zu = Nu; 328ri.default = zu; 329Object.defineProperty(ti, "__esModule", { 330 value: !0 331}); 332ti.default = void 0; 333var ju = Ta(Re), Lu = Ta(ri); 334function Ta(t) { 335 return t && t.__esModule ? t : { default: t }; 336} 337const Bu = (0, ju.default)("v5", 80, Lu.default); 338var qu = Bu; 339ti.default = qu; 340var ii = {}; 341Object.defineProperty(ii, "__esModule", { 342 value: !0 343}); 344ii.default = void 0; 345var Fu = "00000000-0000-0000-0000-000000000000"; 346ii.default = Fu; 347var ni = {}; 348Object.defineProperty(ni, "__esModule", { 349 value: !0 350}); 351ni.default = void 0; 352var Uu = xu(Fe); 353function xu(t) { 354 return t && t.__esModule ? t : { default: t }; 355} 356function Wu(t) { 357 if (!(0, Uu.default)(t)) 358 throw TypeError("Invalid UUID"); 359 return parseInt(t.slice(14, 15), 16); 360} 361var Hu = Wu; 362ni.default = Hu; 363(function(t) { 364 Object.defineProperty(t, "__esModule", { 365 value: !0 366 }), Object.defineProperty(t, "NIL", { 367 enumerable: !0, 368 get: function() { 369 return a.default; 370 } 371 }), Object.defineProperty(t, "parse", { 372 enumerable: !0, 373 get: function() { 374 return c.default; 375 } 376 }), Object.defineProperty(t, "stringify", { 377 enumerable: !0, 378 get: function() { 379 return o.default; 380 } 381 }), Object.defineProperty(t, "v1", { 382 enumerable: !0, 383 get: function() { 384 return e.default; 385 } 386 }), Object.defineProperty(t, "v3", { 387 enumerable: !0, 388 get: function() { 389 return r.default; 390 } 391 }), Object.defineProperty(t, "v4", { 392 enumerable: !0, 393 get: function() { 394 return s.default; 395 } 396 }), Object.defineProperty(t, "v5", { 397 enumerable: !0, 398 get: function() { 399 return p.default; 400 } 401 }), Object.defineProperty(t, "validate", { 402 enumerable: !0, 403 get: function() { 404 return i.default; 405 } 406 }), Object.defineProperty(t, "version", { 407 enumerable: !0, 408 get: function() { 409 return n.default; 410 } 411 }); 412 var e = u(Vr), r = u(Xr), s = u($r), p = u(ti), a = u(ii), n = u(ni), i = u(Fe), o = u(Te), c = u(_r); 413 function u(h) { 414 return h && h.__esModule ? h : { default: h }; 415 } 416})(ma); 417Object.defineProperty(oe, "__esModule", { value: !0 }); 418oe.createNoDashGuid = oe.createGuid = void 0; 419const Ku = ma, Aa = () => (0, Ku.v4)(); 420oe.createGuid = Aa; 421const Ju = () => Aa().replace(new RegExp("-", "g"), "").toUpperCase(); 422oe.createNoDashGuid = Ju; 423(function(t) { 424 Object.defineProperty(t, "__esModule", { value: !0 }), t.PlatformEvent = t.EventType = void 0; 425 const e = oe; 426 (function(s) { 427 s[s.Debug = 0] = "Debug", s[s.Info = 1] = "Info", s[s.Warning = 2] = "Warning", s[s.Error = 3] = "Error", s[s.None = 4] = "None"; 428 })(t.EventType || (t.EventType = {})); 429 class r { 430 constructor(p, a) { 431 this.privName = p, this.privEventId = (0, e.createNoDashGuid)(), this.privEventTime = (/* @__PURE__ */ new Date()).toISOString(), this.privEventType = a, this.privMetadata = {}; 432 } 433 get name() { 434 return this.privName; 435 } 436 get eventId() { 437 return this.privEventId; 438 } 439 get eventTime() { 440 return this.privEventTime; 441 } 442 get eventType() { 443 return this.privEventType; 444 } 445 get metadata() { 446 return this.privMetadata; 447 } 448 } 449 t.PlatformEvent = r; 450})(Ge); 451Object.defineProperty(B, "__esModule", { value: !0 }); 452B.AudioStreamNodeErrorEvent = B.AudioStreamNodeDetachedEvent = B.AudioStreamNodeAttachedEvent = B.AudioStreamNodeAttachingEvent = B.AudioStreamNodeEvent = B.AudioSourceErrorEvent = B.AudioSourceOffEvent = B.AudioSourceReadyEvent = B.AudioSourceInitializingEvent = B.AudioSourceEvent = void 0; 453const In = Ge; 454class Qe extends In.PlatformEvent { 455 constructor(e, r, s = In.EventType.Info) { 456 super(e, s), this.privAudioSourceId = r; 457 } 458 get audioSourceId() { 459 return this.privAudioSourceId; 460 } 461} 462B.AudioSourceEvent = Qe; 463class Vu extends Qe {
464 constructor(e) { 465 super("AudioSourceInitializingEvent", e); 466 } 467} 468B.AudioSourceInitializingEvent = Vu; 469class Gu extends Qe { 470 constructor(e) { 471 super("AudioSourceReadyEvent", e); 472 } 473} 474B.AudioSourceReadyEvent = Gu; 475class Qu extends Qe { 476 constructor(e) { 477 super("AudioSourceOffEvent", e); 478 } 479} 480B.AudioSourceOffEvent = Qu; 481class Xu extends Qe { 482 constructor(e, r) { 483 super("AudioSourceErrorEvent", e, In.EventType.Error), this.privError = r; 484 } 485 get error() { 486 return this.privError; 487 } 488} 489B.AudioSourceErrorEvent = Xu; 490class br extends Qe { 491 constructor(e, r, s) { 492 super(e, r), this.privAudioNodeId = s; 493 } 494 get audioNodeId() { 495 return this.privAudioNodeId; 496 } 497} 498B.AudioStreamNodeEvent = br; 499class Yu extends br { 500 constructor(e, r) { 501 super("AudioStreamNodeAttachingEvent", e, r); 502 } 503} 504B.AudioStreamNodeAttachingEvent = Yu; 505class Zu extends br { 506 constructor(e, r) { 507 super("AudioStreamNodeAttachedEvent", e, r); 508 } 509} 510B.AudioStreamNodeAttachedEvent = Zu; 511class $u extends br { 512 constructor(e, r) { 513 super("AudioStreamNodeDetachedEvent", e, r); 514 } 515} 516B.AudioStreamNodeDetachedEvent = $u; 517class eh extends br { 518 constructor(e, r, s) { 519 super("AudioStreamNodeErrorEvent", e, r), this.privError = s; 520 } 521 get error() { 522 return this.privError; 523 } 524} 525B.AudioStreamNodeErrorEvent = eh; 526var q = {}; 527Object.defineProperty(q, "__esModule", { value: !0 }); 528q.ConnectionRedirectEvent = q.ConnectionMessageSentEvent = q.ConnectionMessageReceivedEvent = q.ConnectionEstablishErrorEvent = q.ConnectionErrorEvent = q.ConnectionClosedEvent = q.ConnectionEstablishedEvent = q.ConnectionStartEvent = q.ConnectionEvent = q.ServiceEvent = void 0; 529const Ee = Ge;
530class th extends Ee.PlatformEvent { 531 constructor(e, r, s = Ee.EventType.Info) { 532 super(e, s), this.privJsonResult = r; 533 } 534 get jsonString() { 535 return this.privJsonResult; 536 } 537} 538q.ServiceEvent = th; 539class me extends Ee.PlatformEvent { 540 constructor(e, r, s = Ee.EventType.Info) { 541 super(e, s), this.privConnectionId = r; 542 } 543 get connectionId() { 544 return this.privConnectionId; 545 } 546} 547q.ConnectionEvent = me; 548class rh extends me { 549 constructor(e, r, s) { 550 super("ConnectionStartEvent", e), this.privUri = r, this.privHeaders = s; 551 } 552 get uri() { 553 return this.privUri; 554 } 555 get headers() { 556 return this.privHeaders; 557 } 558} 559q.ConnectionStartEvent = rh; 560class ih extends me { 561 constructor(e) { 562 super("ConnectionEstablishedEvent", e); 563 } 564} 565q.ConnectionEstablishedEvent = ih; 566class nh extends me { 567 constructor(e, r, s) { 568 super("ConnectionClosedEvent", e, Ee.EventType.Debug), this.privReason = s, this.privStatusCode = r; 569 } 570 get reason() { 571 return this.privReason; 572 } 573 get statusCode() { 574 return this.privStatusCode; 575 } 576} 577q.ConnectionClosedEvent = nh; 578class sh extends me { 579 constructor(e, r, s) { 580 super("ConnectionErrorEvent", e, Ee.EventType.Debug), this.privMessage = r, this.privType = s; 581 } 582 get message() { 583 return this.privMessage; 584 } 585 get type() { 586 return this.privType; 587 } 588} 589q.ConnectionErrorEvent = sh; 590class oh extends me { 591 constructor(e, r, s) { 592 super("ConnectionEstablishErrorEvent", e, Ee.EventType.Error), this.privStatusCode = r, this.privReason = s; 593 } 594 get reason() { 595 return this.privReason; 596 } 597 get statusCode() { 598 return this.privStatusCode; 599 } 600} 601q.ConnectionEstablishErrorEvent = oh; 602class ah extends me { 603 constructor(e, r, s) { 604 super("ConnectionMessageReceivedEvent", e), this.privNetworkReceivedTime = r, this.privMessage = s; 605 } 606 get networkReceivedTime() { 607 return this.privNetworkReceivedTime; 608 } 609 get message() { 610 return this.privMessage; 611 } 612} 613q.ConnectionMessageReceivedEvent = ah; 614class ch extends me { 615 constructor(e, r, s) { 616 super("ConnectionMessageSentEvent", e), this.privNetworkSentTime = r, this.privMessage = s; 617 } 618 get networkSentTime() { 619 return this.privNetworkSentTime; 620 } 621 get message() { 622 return this.privMessage; 623 } 624} 625q.ConnectionMessageSentEvent = ch; 626class ph extends me { 627 constructor(e, r, s, p) { 628 super("ConnectionRedirectEvent", e, Ee.EventType.Info), this.privRedirectUrl = r, this.privOriginalUrl = s, this.privContext = p; 629 } 630 get redirectUrl() { 631 return this.privRedirectUrl; 632 } 633 get originalUrl() { 634 return this.privOriginalUrl; 635 } 636 get context() { 637 return this.privContext; 638 } 639} 640q.ConnectionRedirectEvent = ph; 641var Dn = {}, x = {}; 642Object.defineProperty(x, "__esModule", { value: !0 }); 643x.ObjectDisposedError = x.InvalidOperationError = x.ArgumentNullError = void 0; 644class uh extends Error { 645 /** 646 * Creates an instance of ArgumentNullError. 647 * 648 * @param {string} argumentName - Name of the argument that is null 649 * 650 * @memberOf ArgumentNullError 651 */ 652 constructor(e) { 653 super(e), this.name = "ArgumentNull", this.message = e; 654 } 655} 656x.ArgumentNullError = uh; 657class hh extends Error { 658 /** 659 * Creates an instance of InvalidOperationError. 660 * 661 * @param {string} error - The error 662 * 663 * @memberOf InvalidOperationError 664 */ 665 constructor(e) { 666 super(e), this.name = "InvalidOperation", this.message = e; 667 } 668} 669x.InvalidOperationError = hh; 670class dh extends Error { 671 /** 672 * Creates an instance of ObjectDisposedError. 673 * 674 * @param {string} objectName - The object that is disposed 675 * @param {string} error - The error 676 * 677 * @memberOf ObjectDisposedError 678 */ 679 constructor(e, r) { 680 super(r), this.name = e + "ObjectDisposed", this.message = r; 681 } 682} 683x.ObjectDisposedError = dh; 684(function(t) { 685 Object.defineProperty(t, "__esModule", { value: !0 }), t.ConnectionMessage = t.MessageType = void 0; 686 const e = x, r = oe; 687 var s; 688 (function(a) { 689 a[a.Text = 0] = "Text", a[a.Binary = 1] = "Binary"; 690 })(s = t.MessageType || (t.MessageType = {})); 691 class p { 692 constructor(n, i, o, c) { 693 if (this.privBody = null, n === s.Text && i && typeof i != "string") 694 throw new e.InvalidOperationError("Payload must be a string"); 695 if (n === s.Binary && i && !(i instanceof ArrayBuffer)) 696 throw new e.InvalidOperationError("Payload must be ArrayBuffer");
697 switch (this.privMessageType = n, this.privBody = i, this.privHeaders = o || {}, this.privId = c || (0, r.createNoDashGuid)(), this.messageType) { 698 case s.Binary: 699 this.privSize = this.binaryBody !== null ? this.binaryBody.byteLength : 0; 700 break; 701 case s.Text: 702 this.privSize = this.textBody.length; 703 } 704 } 705 get messageType() { 706 return this.privMessageType; 707 } 708 get headers() { 709 return this.privHeaders; 710 } 711 get body() { 712 return this.privBody; 713 } 714 get textBody() { 715 if (this.privMessageType === s.Binary) 716 throw new e.InvalidOperationError("Not supported for binary message"); 717 return this.privBody; 718 } 719 get binaryBody() { 720 if (this.privMessageType === s.Text) 721 throw new e.InvalidOperationError("Not supported for text message"); 722 return this.privBody; 723 } 724 get id() { 725 return this.privId; 726 } 727 } 728 t.ConnectionMessage = p; 729})(Dn); 730var si = {}; 731Object.defineProperty(si, "__esModule", { value: !0 }); 732si.ConnectionOpenResponse = void 0; 733class vh { 734 constructor(e, r) { 735 this.privStatusCode = e, this.privReason = r; 736 } 737 get statusCode() { 738 return this.privStatusCode; 739 } 740 get reason() { 741 return this.privReason; 742 } 743} 744si.ConnectionOpenResponse = vh; 745var oi = {}; 746Object.defineProperty(oi, "__esModule", { value: !0 }); 747oi.DeferralMap = void 0; 748class lh { 749 constructor() { 750 this.privMap = {}; 751 } 752 add(e, r) { 753 this.privMap[e] = r; 754 } 755 getId(e) { 756 return this.privMap[e]; 757 } 758 complete(e, r) { 759 try { 760 this.privMap[e].resolve(r); 761 } catch (s) { 762 this.privMap[e].reject(s); 763 } finally { 764 this.privMap[e] = void 0; 765 } 766 } 767} 768oi.DeferralMap = lh; 769var qe = {}; 770Object.defineProperty(qe, "__esModule", { value: !0 }); 771qe.SendingAgentContextMessageEvent = qe.DialogEvent = void 0; 772const cs = Ge; 773class Ia extends cs.PlatformEvent { 774 constructor(e, r = cs.EventType.Info) { 775 super(e, r); 776 } 777} 778qe.DialogEvent = Ia; 779class fh extends Ia { 780 constructor(e) { 781 super("SendingAgentContextMessageEvent"), this.privAgentConfig = e; 782 } 783 get agentConfig() { 784 return this.privAgentConfig; 785 } 786} 787qe.SendingAgentContextMessageEvent = fh; 788var ai = {}, Mr = {}; 789Object.defineProperty(Mr, "__esModule", { value: !0 }); 790Mr.EventSource = void 0; 791const gh = x, mh = oe; 792class Sh { 793 constructor(e) { 794 this.privEventListeners = {}, this.privIsDisposed = !1, this.privConsoleListener = void 0, this.privMetadata = e; 795 } 796 onEvent(e) { 797 if (this.isDisposed()) 798 throw new gh.ObjectDisposedError("EventSource"); 799 if (this.metadata) 800 for (const r in this.metadata) 801 r && e.metadata && (e.metadata[r] || (e.metadata[r] = this.metadata[r])); 802 for (const r in this.privEventListeners) 803 r && this.privEventListeners[r] && this.privEventListeners[r](e); 804 } 805 attach(e) { 806 const r = (0, mh.createNoDashGuid)(); 807 return this.privEventListeners[r] = e, { 808 detach: () => (delete this.privEventListeners[r], Promise.resolve()) 809 }; 810 } 811 attachListener(e) { 812 return this.attach((r) => e.onEvent(r)); 813 } 814 attachConsoleListener(e) { 815 return this.privConsoleListener && this.privConsoleListener.detach(), this.privConsoleListener = this.attach((r) => e.onEvent(r)), this.privConsoleListener; 816 } 817 isDisposed() { 818 return this.privIsDisposed; 819 } 820 dispose() { 821 this.privEventListeners = null, this.privIsDisposed = !0; 822 } 823 get metadata() { 824 return this.privMetadata; 825 } 826} 827Mr.EventSource = Sh; 828Object.defineProperty(ai, "__esModule", { value: !0 }); 829ai.Events = void 0; 830const Ch = x, yh = Mr; 831class Ar { 832 static setEventSource(e) { 833 if (!e) 834 throw new Ch.ArgumentNullError("eventSource"); 835 Ar.privInstance = e; 836 } 837 static get instance() { 838 return Ar.privInstance; 839 } 840} 841ai.Events = Ar; 842Ar.privInstance = new yh.EventSource(); 843var wa = {}; 844Object.defineProperty(wa, "__esModule", { value: !0 }); 845var _a = {}; 846(function(t) { 847 Object.defineProperty(t, "__esModule", { value: !0 }), t.ConnectionState = void 0, function(e) { 848 e[e.None = 0] = "None", e[e.Connected = 1] = "Connected", e[e.Connecting = 2] = "Connecting", e[e.Disconnected = 3] = "Disconnected"; 849 }(t.ConnectionState || (t.ConnectionState = {})); 850})(_a); 851var ba = {}; 852Object.defineProperty(ba, "__esModule", { value: !0 }); 853var Ma = {}; 854Object.defineProperty(Ma, "__esModule", { value: !0 }); 855var Oa = {}; 856Object.defineProperty(Oa, "__esModule", { value: !0 }); 857var Da = {}; 858Object.defineProperty(Da, "__esModule", { value: !0 }); 859var ka = {}; 860Object.defineProperty(ka, "__esModule", { value: !0 }); 861var Na = {}; 862Object.defineProperty(Na, "__esModule", { value: !0 }); 863var za = {}; 864Object.defineProperty(za, "__esModule", { value: !0 }); 865var ja = {}; 866Object.defineProperty(ja, "__esModule", { value: !0 }); 867var Or = {}; 868Object.defineProperty(Or, "__esModule", { value: !0 }); 869Or.List = void 0; 870const Ph = x; 871class Ce { 872 constructor(e) { 873 if (this.privSubscriptionIdCounter = 0, this.privAddSubscriptions = {}, this.privRemoveSubscriptions = {}, this.privDisposedSubscriptions = {}, this.privDisposeReason = null, this.privList = [], e) 874 for (const r of e) 875 this.privList.push(r); 876 } 877 get(e) { 878 return this.throwIfDisposed(), this.privList[e]; 879 } 880 first() { 881 return this.get(0); 882 } 883 last() { 884 return this.get(this.length() - 1); 885 } 886 add(e) { 887 this.throwIfDisposed(), this.insertAt(this.privList.length, e); 888 } 889 insertAt(e, r) { 890 this.throwIfDisposed(), e === 0 ? this.privList.unshift(r) : e === this.privList.length ? this.privList.push(r) : this.privList.splice(e, 0, r), this.triggerSubscriptions(this.privAddSubscriptions); 891 } 892 removeFirst() { 893 return this.throwIfDisposed(), this.removeAt(0); 894 } 895 removeLast() { 896 return this.throwIfDisposed(), this.removeAt(this.length() - 1); 897 } 898 removeAt(e) { 899 return this.throwIfDisposed(), this.remove(e, 1)[0]; 900 } 901 remove(e, r) { 902 this.throwIfDisposed(); 903 const s = this.privList.splice(e, r); 904 return this.triggerSubscriptions(this.privRemoveSubscriptions), s; 905 } 906 clear() { 907 this.throwIfDisposed(), this.remove(0, this.length()); 908 } 909 length() { 910 return this.throwIfDisposed(), this.privList.length; 911 } 912 onAdded(e) { 913 this.throwIfDisposed(); 914 const r = this.privSubscriptionIdCounter++; 915 return this.privAddSubscriptions[r] = e, { 916 detach: () => (delete this.privAddSubscriptions[r], Promise.resolve()) 917 }; 918 } 919 onRemoved(e) { 920 this.throwIfDisposed(); 921 const r = this.privSubscriptionIdCounter++; 922 return this.privRemoveSubscriptions[r] = e, { 923 detach: () => (delete this.privRemoveSubscriptions[r], Promise.resolve()) 924 }; 925 } 926 onDisposed(e) { 927 this.throwIfDisposed(); 928 const r = this.privSubscriptionIdCounter++; 929 return this.privDisposedSubscriptions[r] = e, { 930 detach: () => (delete this.privDisposedSubscriptions[r], Promise.resolve()) 931 }; 932 } 933 join(e) { 934 return this.throwIfDisposed(), this.privList.join(e); 935 } 936 toArray() { 937 const e = Array(); 938 return this.privList.forEach((r) => { 939 e.push(r); 940 }), e; 941 } 942 any(e) { 943 return this.throwIfDisposed(), e ? this.where(e).length() > 0 : this.length() > 0; 944 } 945 all(e) { 946 return this.throwIfDisposed(), this.where(e).length() === this.length(); 947 } 948 forEach(e) { 949 this.throwIfDisposed(); 950 for (let r = 0; r < this.length(); r++) 951 e(this.privList[r], r); 952 } 953 select(e) { 954 this.throwIfDisposed(); 955 const r = []; 956 for (let s = 0; s < this.privList.length; s++) 957 r.push(e(this.privList[s], s)); 958 return new Ce(r); 959 } 960 where(e) { 961 this.throwIfDisposed(); 962 const r = new Ce(); 963 for (let s = 0; s < this.privList.length; s++) 964 e(this.privList[s], s) && r.add(this.privList[s]); 965 return r; 966 } 967 orderBy(e) { 968 this.throwIfDisposed(); 969 const s = this.toArray().sort(e); 970 return new Ce(s); 971 } 972 orderByDesc(e) { 973 return this.throwIfDisposed(), this.orderBy((r, s) => e(s, r)); 974 } 975 clone() { 976 return this.throwIfDisposed(), new Ce(this.toArray()); 977 } 978 concat(e) { 979 return this.throwIfDisposed(), new Ce(this.privList.concat(e.toArray())); 980 } 981 concatArray(e) { 982 return this.throwIfDisposed(), new Ce(this.privList.concat(e)); 983 } 984 isDisposed() { 985 return this.privList == null; 986 } 987 dispose(e) { 988 this.isDisposed() || (this.privDisposeReason = e, this.privList = null, this.privAddSubscriptions = null, this.privRemoveSubscriptions = null, this.triggerSubscriptions(this.privDisposedSubscriptions)); 989 } 990 throwIfDisposed() { 991 if (this.isDisposed()) 992 throw new Ph.ObjectDisposedError("List", this.privDisposeReason); 993 } 994 triggerSubscriptions(e) { 995 if (e) 996 for (const r in e) 997 r && e[r](); 998 } 999} 1000Or.List = Ce; 1001var kn = {}; 1002(function(t) { 1003 Object.defineProperty(t, "__esModule", { value: !0 }), t.marshalPromiseToCallbacks = t.Sink = t.Deferred = t.PromiseResultEventSource = t.PromiseResult = t.PromiseState = void 0; 1004 var e; 1005 (function(i) { 1006 i[i.None = 0] = "None", i[i.Resolved = 1] = "Resolved", i[i.Rejected = 2] = "Rejected"; 1007 })(e = t.PromiseState || (t.PromiseState = {})); 1008 class r { 1009 constructor(o) { 1010 this.throwIfError = () => { 1011 if (this.isError) 1012 throw this.error; 1013 }, o.on((c) => { 1014 this.privIsCompleted || (this.privIsCompleted = !0, this.privIsError = !1, this.privResult = c); 1015 }, (c) => { 1016 this.privIsCompleted || (this.privIsCompleted = !0, this.privIsError = !0, this.privError = c); 1017 }); 1018 } 1019 get isCompleted() { 1020 return this.privIsCompleted; 1021 } 1022 get isError() { 1023 return this.privIsError; 1024 } 1025 get error() { 1026 return this.privError; 1027 } 1028 get result() { 1029 return this.privResult; 1030 } 1031 } 1032 t.PromiseResult = r; 1033 class s { 1034 constructor() { 1035 this.setResult = (o) => { 1036 this.privOnSetResult(o); 1037 }, this.setError = (o) => { 1038 this.privOnSetError(o); 1039 }, this.on = (o, c) => { 1040 this.privOnSetResult = o, this.privOnSetError = c; 1041 }; 1042 } 1043 } 1044 t.PromiseResultEventSource = s; 1045 class p { 1046 constructor() { 1047 this.resolve = (o) => (this.privResolve(o), this), this.reject = (o) => (this.privReject(o), this), this.privPromise = new Promise((o, c) => { 1048 this.privResolve = o, this.privReject = c; 1049 }); 1050 } 1051 get promise() { 1052 return this.privPromise; 1053 } 1054 } 1055 t.Deferred = p; 1056 class a { 1057 constructor() { 1058 this.privState = e.None, this.privPromiseResult = null, this.privPromiseResultEvents = null, this.privSuccessHandlers = [], this.privErrorHandlers = [], this.privPromiseResultEvents = new s(), this.privPromiseResult = new r(this.privPromiseResultEvents); 1059 } 1060 get state() { 1061 return this.privState; 1062 } 1063 get result() { 1064 return this.privPromiseResult; 1065 } 1066 resolve(o) { 1067 if (this.privState !== e.None) 1068 throw new Error("'Cannot resolve a completed promise'");
1069 this.privState = e.Resolved, this.privPromiseResultEvents.setResult(o); 1070 for (let c = 0; c < this.privSuccessHandlers.length; c++) 1071 this.executeSuccessCallback(o, this.privSuccessHandlers[c], this.privErrorHandlers[c]); 1072 this.detachHandlers(); 1073 } 1074 reject(o) { 1075 if (this.privState !== e.None) 1076 throw new Error("'Cannot reject a completed promise'"); 1077 this.privState = e.Rejected, this.privPromiseResultEvents.setError(o); 1078 for (const c of this.privErrorHandlers) 1079 this.executeErrorCallback(o, c); 1080 this.detachHandlers(); 1081 } 1082 on(o, c) { 1083 o == null && (o = () => { 1084 }), this.privState === e.None ? (this.privSuccessHandlers.push(o), this.privErrorHandlers.push(c)) : (this.privState === e.Resolved ? this.executeSuccessCallback(this.privPromiseResult.result, o, c) : this.privState === e.Rejected && this.executeErrorCallback(this.privPromiseResult.error, c), this.detachHandlers()); 1085 } 1086 executeSuccessCallback(o, c, u) { 1087 try { 1088 c(o); 1089 } catch (h) { 1090 this.executeErrorCallback(`'Unhandled callback error: ${h}'`, u); 1091 } 1092 } 1093 executeErrorCallback(o, c) { 1094 if (c) 1095 try { 1096 c(o); 1097 } catch (u) { 1098 throw new Error(`'Unhandled callback error: ${u}. InnerError: ${o}'`); 1099 } 1100 else 1101 throw new Error(`'Unhandled error: ${o}'`); 1102 } 1103 detachHandlers() { 1104 this.privErrorHandlers = [], this.privSuccessHandlers = []; 1105 } 1106 } 1107 t.Sink = a; 1108 function n(i, o, c) { 1109 i.then((u) => { 1110 try { 1111 o && o(u); 1112 } catch (h) { 1113 if (c) 1114 try { 1115 if (h instanceof Error) { 1116 const d = h; 1117 c(d.name + ": " + d.message); 1118 } else 1119 c(h); 1120 } catch { 1121 } 1122 } 1123 }, (u) => { 1124 if (c) 1125 try { 1126 if (u instanceof Error) { 1127 const h = u; 1128 c(h.name + ": " + h.message); 1129 } else 1130 c(u); 1131 } catch { 1132 } 1133 }); 1134 } 1135 t.marshalPromiseToCallbacks = n; 1136})(kn); 1137var Dr = {}; 1138Object.defineProperty(Dr, "__esModule", { value: !0 }); 1139Dr.Queue = void 0; 1140const dn = x, vn = Or, ps = kn; 1141var Tr; 1142(function(t) { 1143 t[t.Dequeue = 0] = "Dequeue", t[t.Peek = 1] = "Peek"; 1144})(Tr || (Tr = {})); 1145class Rh { 1146 constructor(e) { 1147 this.privPromiseStore = new vn.List(), this.privIsDrainInProgress = !1, this.privIsDisposing = !1, this.privDisposeReason = null, this.privList = e || new vn.List(), this.privDetachables = [], this.privSubscribers = new vn.List(), this.privDetachables.push(this.privList.onAdded(() => this.drain())); 1148 } 1149 enqueue(e) { 1150 this.throwIfDispose(), this.enqueueFromPromise(new Promise((r) => r(e))); 1151 } 1152 enqueueFromPromise(e) { 1153 this.throwIfDispose(), e.then((r) => { 1154 this.privList.add(r); 1155 }, () => { 1156 }); 1157 } 1158 dequeue() { 1159 this.throwIfDispose(); 1160 const e = new ps.Deferred(); 1161 return this.privSubscribers && (this.privSubscribers.add({ deferral: e, type: Tr.Dequeue }), this.drain()), e.promise; 1162 } 1163 peek() { 1164 this.throwIfDispose(); 1165 const e = new ps.Deferred(); 1166 return this.privSubscribers && (this.privSubscribers.add({ deferral: e, type: Tr.Peek }), this.drain()), e.promise; 1167 } 1168 length() { 1169 return this.throwIfDispose(), this.privList.length(); 1170 } 1171 isDisposed() { 1172 return this.privSubscribers == null; 1173 } 1174 async drainAndDispose(e, r) { 1175 if (!this.isDisposed() && !this.privIsDisposing) { 1176 this.privDisposeReason = r, this.privIsDisposing = !0; 1177 const s = this.privSubscribers; 1178 if (s) { 1179 for (; s.length() > 0; ) 1180 s.removeFirst().deferral.resolve(void 0); 1181 this.privSubscribers === s && (this.privSubscribers = s); 1182 } 1183 for (const p of this.privDetachables) 1184 await p.detach(); 1185 if (this.privPromiseStore.length() > 0 && e) { 1186 const p = []; 1187 return this.privPromiseStore.toArray().forEach((a) => { 1188 p.push(a); 1189 }), Promise.all(p).finally(() => { 1190 this.privSubscribers = null, this.privList.forEach((a) => { 1191 e(a); 1192 }), this.privList = null; 1193 }).then(); 1194 } else 1195 this.privSubscribers = null, this.privList = null; 1196 } 1197 } 1198 async dispose(e) { 1199 await this.drainAndDispose(null, e); 1200 } 1201 drain() { 1202 if (!this.privIsDrainInProgress && !this.privIsDisposing) { 1203 this.privIsDrainInProgress = !0; 1204 const e = this.privSubscribers, r = this.privList; 1205 if (e && r) { 1206 for (; r.length() > 0 && e.length() > 0 && !this.privIsDisposing; ) { 1207 const s = e.removeFirst(); 1208 if (s.type === Tr.Peek) 1209 s.deferral.resolve(r.first()); 1210 else { 1211 const p = r.removeFirst(); 1212 s.deferral.resolve(p); 1213 } 1214 } 1215 this.privSubscribers === e && (this.privSubscribers = e), this.privList === r && (this.privList = r); 1216 } 1217 this.privIsDrainInProgress = !1; 1218 } 1219 } 1220 throwIfDispose() { 1221 if (this.isDisposed()) 1222 throw this.privDisposeReason ? new dn.InvalidOperationError(this.privDisposeReason) : new dn.ObjectDisposedError("Queue"); 1223 if (this.privIsDisposing) 1224 throw new dn.InvalidOperationError("Queue disposing"); 1225 } 1226} 1227Dr.Queue = Rh; 1228var ci = {}; 1229Object.defineProperty(ci, "__esModule", { value: !0 }); 1230ci.RawWebsocketMessage = void 0; 1231const Ur = Dn, Ze = x, Eh = oe; 1232class Th { 1233 constructor(e, r, s) { 1234 if (this.privPayload = null, !r) 1235 throw new Ze.ArgumentNullError("payload"); 1236 if (e === Ur.MessageType.Binary && Object.getPrototypeOf(r).constructor.name !== "ArrayBuffer") 1237 throw new Ze.InvalidOperationError("Payload must be ArrayBuffer"); 1238 if (e === Ur.MessageType.Text && typeof r != "string") 1239 throw new Ze.InvalidOperationError("Payload must be a string");
1240 this.privMessageType = e, this.privPayload = r, this.privId = s || (0, Eh.createNoDashGuid)(); 1241 } 1242 get messageType() { 1243 return this.privMessageType; 1244 } 1245 get payload() { 1246 return this.privPayload; 1247 } 1248 get textContent() { 1249 if (this.privMessageType === Ur.MessageType.Binary) 1250 throw new Ze.InvalidOperationError("Not supported for binary message"); 1251 return this.privPayload; 1252 } 1253 get binaryContent() { 1254 if (this.privMessageType === Ur.MessageType.Text) 1255 throw new Ze.InvalidOperationError("Not supported for text message"); 1256 return this.privPayload; 1257 } 1258 get id() { 1259 return this.privId; 1260 } 1261} 1262ci.RawWebsocketMessage = Th; 1263var pi = {}; 1264Object.defineProperty(pi, "__esModule", { value: !0 }); 1265pi.RiffPcmEncoder = void 0; 1266class Ah { 1267 constructor(e, r) { 1268 this.privActualSampleRate = e, this.privDesiredSampleRate = r; 1269 } 1270 encode(e) { 1271 const r = this.downSampleAudioFrame(e, this.privActualSampleRate, this.privDesiredSampleRate); 1272 if (!r) 1273 return null; 1274 const s = r.length * 2, p = new ArrayBuffer(s), a = new DataView(p); 1275 return this.floatTo16BitPCM(a, 0, r), p; 1276 } 1277 setString(e, r, s) { 1278 for (let p = 0; p < s.length; p++) 1279 e.setUint8(r + p, s.charCodeAt(p)); 1280 } 1281 floatTo16BitPCM(e, r, s) { 1282 for (let p = 0; p < s.length; p++, r += 2) { 1283 const a = Math.max(-1, Math.min(1, s[p])); 1284 e.setInt16(r, a < 0 ? a * 32768 : a * 32767, !0); 1285 } 1286 } 1287 downSampleAudioFrame(e, r, s) { 1288 if (!e) 1289 return null; 1290 if (s === r || s > r) 1291 return e; 1292 const p = r / s, a = Math.round(e.length / p), n = new Float32Array(a); 1293 let i = 0, o = 0; 1294 for (; o < a; ) { 1295 const c = Math.round((o + 1) * p); 1296 let u = 0, h = 0; 1297 for (; i < c && i < e.length; ) 1298 u += e[i++], h++; 1299 n[o++] = u / h; 1300 } 1301 return n; 1302 } 1303} 1304pi.RiffPcmEncoder = Ah; 1305var ui = {}; 1306Object.defineProperty(ui, "__esModule", { value: !0 }); 1307ui.Stream = void 0; 1308const us = x, Ih = oe, hs = Dr; 1309class wh { 1310 constructor(e) { 1311 this.privIsWriteEnded = !1, this.privIsReadEnded = !1, this.privId = e || (0, Ih.createNoDashGuid)(), this.privReaderQueue = new hs.Queue(); 1312 } 1313 get isClosed() { 1314 return this.privIsWriteEnded; 1315 } 1316 get isReadEnded() { 1317 return this.privIsReadEnded; 1318 } 1319 get id() { 1320 return this.privId; 1321 } 1322 close() { 1323 this.privIsWriteEnded || (this.writeStreamChunk({ 1324 buffer: null, 1325 isEnd: !0, 1326 timeReceived: Date.now() 1327 }), this.privIsWriteEnded = !0); 1328 } 1329 writeStreamChunk(e) { 1330 if (this.throwIfClosed(), !this.privReaderQueue.isDisposed()) 1331 try { 1332 this.privReaderQueue.enqueue(e); 1333 } catch { 1334 } 1335 } 1336 read() { 1337 if (this.privIsReadEnded) 1338 throw new us.InvalidOperationError("Stream read has already finished"); 1339 return this.privReaderQueue.dequeue().then(async (e) => ((e === void 0 || e.isEnd) && await this.privReaderQueue.dispose("End of stream reached"), e)); 1340 } 1341 readEnded() { 1342 this.privIsReadEnded || (this.privIsReadEnded = !0, this.privReaderQueue = new hs.Queue()); 1343 } 1344 throwIfClosed() { 1345 if (this.privIsWriteEnded) 1346 throw new us.InvalidOperationError("Stream closed"); 1347 } 1348} 1349ui.Stream = wh; 1350var hi = {}; 1351(function(t) { 1352 Object.defineProperty(t, "__esModule", { value: !0 }), t.TranslationStatus = void 0, function(e) { 1353 e[e.Success = 0] = "Success", e[e.Error = 1] = "Error"; 1354 }(t.TranslationStatus || (t.TranslationStatus = {})); 1355})(hi); 1356var $e = {}, ds; 1357function _h() { 1358 if (ds) return $e; 1359 ds = 1, Object.defineProperty($e, "__esModule", { value: !0 }), $e.ChunkedArrayBufferStream = void 0; 1360 const t = I(); 1361 let e = class extends t.Stream { 1362 constructor(s, p) { 1363 super(p), this.privTargetChunkSize = Math.round(s), this.privNextBufferReadyBytes = 0; 1364 } 1365 writeStreamChunk(s) { 1366 if (s.isEnd || this.privNextBufferReadyBytes === 0 && s.buffer.byteLength === this.privTargetChunkSize) { 1367 super.writeStreamChunk(s); 1368 return; 1369 } 1370 let p = 0; 1371 for (; p < s.buffer.byteLength; ) { 1372 this.privNextBufferToWrite === void 0 && (this.privNextBufferToWrite = new ArrayBuffer(this.privTargetChunkSize), this.privNextBufferStartTime = s.timeReceived); 1373 const a = Math.min(s.buffer.byteLength - p, this.privTargetChunkSize - this.privNextBufferReadyBytes), n = new Uint8Array(this.privNextBufferToWrite), i = new Uint8Array(s.buffer.slice(p, a + p)); 1374 n.set(i, this.privNextBufferReadyBytes), this.privNextBufferReadyBytes += a, p += a, this.privNextBufferReadyBytes === this.privTargetChunkSize && (super.writeStreamChunk({ 1375 buffer: this.privNextBufferToWrite, 1376 isEnd: !1, 1377 timeReceived: this.privNextBufferStartTime 1378 }), this.privNextBufferReadyBytes = 0, this.privNextBufferToWrite = void 0); 1379 } 1380 } 1381 close() { 1382 this.privNextBufferReadyBytes !== 0 && !this.isClosed && super.writeStreamChunk({ 1383 buffer: this.privNextBufferToWrite.slice(0, this.privNextBufferReadyBytes), 1384 isEnd: !1, 1385 timeReceived: this.privNextBufferStartTime 1386 }), super.close(); 1387 } 1388 }; 1389 return $e.ChunkedArrayBufferStream = e, $e; 1390} 1391var La = {}; 1392Object.defineProperty(La, "__esModule", { value: !0 }); 1393var di = {}; 1394Object.defineProperty(di, "__esModule", { value: !0 }); 1395di.Timeout = void 0; 1396class Q { 1397 static load() { 1398 const e = /* @__PURE__ */ new Map([[0, () => { 1399 }]]), r = /* @__PURE__ */ new Map(), p = "data:text/javascript;base64," + btoa(`!function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}
1399),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=14)}([function(e,t,n){"use strict";n.d(t,"a",(function(){return i})),n.d(t,"b",(function(){return u})),n.d(t,"c",(function(){return a})),n.d(t,"d",(function(){return d}));const r=new Map,o=new Map,i=e=>{const t=r.get(e);if(void 0===t)throw new Error('There is no interval scheduled with the given id "'.concat(e,'".'));clearTimeout(t),r.delete(e)},u=e=>{const t=o.get(e);if(void 0===t)throw new Error('There is no timeout scheduled with the given id "'.concat(e,'".'));clearTimeout(t),o.delete(e)},f=(e,t)=>{let n,r;if("performance"in self){const o=performance.now();n=o,r=e-Math.max(0,o-t)}else n=Date.now(),r=e;return{expected:n+r,remainingDelay:r}},c=(e,t,n,r)=>{const o="performance"in self?performance.now():Date.now();o>n?postMessage({id:null,method:"call",params:{timerId:t}}):e.set(t,setTimeout(c,n-o,e,t,n))},a=(e,t,n)=>{const{expected:o,remainingDelay:i}=f(e,n);r.set(t,setTimeout(c,i,r,t,o))},d=(e,t,n)=>{const{expected:r,remainingDelay:i}=f(e,n);o.set(t,setTimeout(c,i,o,t,r))}},function(e,t,n){"use strict";n.r(t);var r=n(2);for(var o in r)"default"!==o&&function(e){n.d(t,e,(function(){return r[e]}))}(o);var i=n(3);for(var o in i)"default"!==o&&function(e){n.d(t,e,(function(){return i[e]}))}(o);var u=n(4);for(var o in u)"default"!==o&&function(e){n.d(t,e,(function(){return u[e]}))}(o);var f=n(5);for(var o in f)"default"!==o&&function(e){n.d(t,e,(function(){return f[e]}))}(o);var c=n(6);for(var o in c)"default"!==o&&function(e){n.d(t,e,(function(){return c[e]}))}(o);var a=n(7);for(var o in a)"default"!==o&&function(e){n.d(t,e,(function(){return a[e]}))}(o);var d=n(8);for(var o in d)"default"!==o&&function(e){n.d(t,e,(function(){return d[e]}))}(o);var s=n(9);for(var o in s)"default"!==o&&function(e){n.d(t,e,(function(){return s[e]}))}(o)},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t,n){"use strict";n.r(t);var r=n(11);for(var o in r)"default"!==o&&function(e){n.d(t,e,(function(){return r[e]}))}(o);var i=n(12);for(var o in i)"default"!==o&&function(e){n.d(t,e,(function(){return i[e]}))}(o);var u=n(13);for(var o in u)"default"!==o&&function(e){n.d(t,e,(function(){return u[e]}))}(o)},function(e,t){},function(e,t){},function(e,t){},function(e,t,n){"use strict";n.r(t);var r=n(0),o=n(1);for(var i in o)"default"!==i&&function(e){n.d(t,e,(function(){return o[e]}))}(i);var u=n(10);for(var i in u)"default"!==i&&function(e){n.d(t,e,(function(){return u[e]}))}(i);addEventListener("message",({data:e})=>{try{if("clear"===e.method){const{id:t,params:{timerId:n}}=e;Object(r.b)(n),postMessage({error:null,id:t})}else{if("set"!==e.method)throw new Error('The given method "'.concat(e.method,'" is not supported'));{const{params:{delay:t,now:n,timerId:o}}=e;Object(r.d)(t,o,n)}}}catch(t){postMessage({error:{message:t.message},id:e.id,result:null})}})}]);`), a = new Worker(p); 1400 return a.addEventListener("message", ({ data: o }) => { 1401 if (Q.isCallNotification(o)) { 1402 const { params: { timerId: c } } = o, u = e.get(c); 1403 if (typeof u == "number") { 1404 const h = r.get(u); 1405 if (h === void 0 || h !== c) 1406 throw new Error("The timer is in an undefined state."); 1407 } else if (typeof u < "u") 1408 u(), e.delete(c); 1409 else 1410 throw new Error("The timer is in an undefined state."); 1411 } else if (Q.isClearResponse(o)) { 1412 const { id: c } = o, u = r.get(c); 1413 if (u === void 0) 1414 throw new Error("The timer is in an undefined state."); 1415 r.delete(c), e.delete(u); 1416 } else { 1417 const { error: { message: c } } = o; 1418 throw new Error(c); 1419 } 1420 }), { 1421 clearTimeout: (o) => { 1422 const c = Math.random(); 1423 r.set(c, o), e.set(o, c), a.postMessage({ 1424 id: c, 1425 method: "clear", 1426 params: { timerId: o } 1427 }); 1428 }, 1429 setTimeout: (o, c) => { 1430 const u = Math.random(); 1431 return e.set(u, o), a.postMessage({ 1432 id: null, 1433 method: "set", 1434 params: { 1435 delay: c, 1436 now: performance.now(), 1437 timerId: u 1438 } 1439 }), u; 1440 } 1441 }; 1442 } 1443 static loadWorkerTimers() { 1444 return () => (Q.workerTimers !== null || (Q.workerTimers = Q.load()), Q.workerTimers); 1445 } 1446 static isCallNotification(e) { 1447 return e.method !== void 0 && e.method === "call"; 1448 } 1449 static isClearResponse(e) { 1450 return e.error === null && typeof e.id == "number"; 1451 } 1452} 1453di.Timeout = Q; 1454Q.workerTimers = null; 1455Q.clearTimeout = (t) => Q.timers().clearTimeout(t); 1456Q.setTimeout = (t, e) => Q.timers().setTimeout(t, e); 1457Q.timers = Q.loadWorkerTimers(); 1458var N = {}; 1459Object.defineProperty(N, "__esModule", { value: !0 }); 1460N.OCSPCacheUpdateErrorEvent = N.OCSPResponseRetrievedEvent = N.OCSPCacheFetchErrorEvent = N.OCSPVerificationFailedEvent = N.OCSPCacheHitEvent = N.OCSPCacheEntryNeedsRefreshEvent = N.OCSPCacheEntryExpiredEvent = N.OCSPWSUpgradeStartedEvent = N.OCSPStapleReceivedEvent = N.OCSPCacheUpdateCompleteEvent = N.OCSPDiskCacheStoreEvent = N.OCSPMemoryCacheStoreEvent = N.OCSPCacheUpdateNeededEvent = N.OCSPDiskCacheHitEvent = N.OCSPCacheMissEvent = N.OCSPMemoryCacheHitEvent = N.OCSPEvent = void 0; 1461const W = Ge; 1462class H extends W.PlatformEvent { 1463 constructor(e, r, s) { 1464 super(e, r), this.privSignature = s; 1465 } 1466} 1467N.OCSPEvent = H; 1468class bh extends H { 1469 constructor(e) { 1470 super("OCSPMemoryCacheHitEvent", W.EventType.Debug, e); 1471 } 1472} 1473N.OCSPMemoryCacheHitEvent = bh; 1474class Mh extends H { 1475 constructor(e) { 1476 super("OCSPCacheMissEvent", W.EventType.Debug, e); 1477 } 1478} 1479N.OCSPCacheMissEvent = Mh; 1480class Oh extends H { 1481 constructor(e) { 1482 super("OCSPDiskCacheHitEvent", W.EventType.Debug, e); 1483 } 1484} 1485N.OCSPDiskCacheHitEvent = Oh; 1486class Dh extends H { 1487 constructor(e) { 1488 super("OCSPCacheUpdateNeededEvent", W.EventType.Debug, e); 1489 } 1490} 1491N.OCSPCacheUpdateNeededEvent = Dh; 1492class kh extends H { 1493 constructor(e) { 1494 super("OCSPMemoryCacheStoreEvent", W.EventType.Debug, e); 1495 } 1496} 1497N.OCSPMemoryCacheStoreEvent = kh; 1498class Nh extends H { 1499 constructor(e) { 1500 super("OCSPDiskCacheStoreEvent", W.EventType.Debug, e); 1501 } 1502} 1503N.OCSPDiskCacheStoreEvent = Nh; 1504class zh extends H { 1505 constructor(e) { 1506 super("OCSPCacheUpdateCompleteEvent", W.EventType.Debug, e); 1507 } 1508} 1509N.OCSPCacheUpdateCompleteEvent = zh; 1510class jh extends H { 1511 constructor() { 1512 super("OCSPStapleReceivedEvent", W.EventType.Debug, ""); 1513 } 1514} 1515N.OCSPStapleReceivedEvent = jh; 1516class Lh extends H { 1517 constructor(e) { 1518 super("OCSPWSUpgradeStartedEvent", W.EventType.Debug, e); 1519 } 1520} 1521N.OCSPWSUpgradeStartedEvent = Lh; 1522class Bh extends H { 1523 constructor(e, r) { 1524 super("OCSPCacheEntryExpiredEvent", W.EventType.Debug, e), this.privExpireTime = r; 1525 } 1526} 1527N.OCSPCacheEntryExpiredEvent = Bh; 1528class qh extends H { 1529 constructor(e, r, s) { 1530 super("OCSPCacheEntryNeedsRefreshEvent", W.EventType.Debug, e), this.privExpireTime = s, this.privStartTime = r; 1531 } 1532} 1533N.OCSPCacheEntryNeedsRefreshEvent = qh; 1534class Fh extends H { 1535 constructor(e, r, s) { 1536 super("OCSPCacheHitEvent", W.EventType.Debug, e), this.privExpireTime = s, this.privExpireTimeString = new Date(s).toLocaleDateString(), this.privStartTime = r, this.privStartTimeString = new Date(r).toLocaleTimeString(); 1537 } 1538} 1539N.OCSPCacheHitEvent = Fh; 1540class Uh extends H { 1541 constructor(e, r) { 1542 super("OCSPVerificationFailedEvent", W.EventType.Debug, e), this.privError = r; 1543 } 1544} 1545N.OCSPVerificationFailedEvent = Uh; 1546class xh extends H { 1547 constructor(e, r) { 1548 super("OCSPCacheFetchErrorEvent", W.EventType.Debug, e), this.privError = r; 1549 } 1550} 1551N.OCSPCacheFetchErrorEvent = xh; 1552class Wh extends H { 1553 constructor(e) { 1554 super("OCSPResponseRetrievedEvent", W.EventType.Debug, e); 1555 } 1556} 1557N.OCSPResponseRetrievedEvent = Wh; 1558class Hh extends H { 1559 constructor(e, r) { 1560 super("OCSPCacheUpdateErrorEvent", W.EventType.Debug, e), this.privError = r; 1561 } 1562} 1563N.OCSPCacheUpdateErrorEvent = Hh; 1564var et = {}, vs; 1565function Kh() { 1566 if (vs) return et; 1567 vs = 1, Object.defineProperty(et, "__esModule", { value: !0 }
1567), et.BackgroundEvent = void 0; 1568 const t = I(); 1569 class e extends t.PlatformEvent { 1570 constructor(s) { 1571 super("BackgroundEvent", t.EventType.Error), this.privError = s; 1572 } 1573 get error() { 1574 return this.privError; 1575 } 1576 } 1577 return et.BackgroundEvent = e, et; 1578} 1579var ls; 1580function I() { 1581 return ls || (ls = 1, function(t) { 1582 var e = k && k.__createBinding || (Object.create ? function(p, a, n, i) { 1583 i === void 0 && (i = n), Object.defineProperty(p, i, { enumerable: !0, get: function() { 1584 return a[n]; 1585 } }); 1586 } : function(p, a, n, i) { 1587 i === void 0 && (i = n), p[i] = a[n]; 1588 }), r = k && k.__exportStar || function(p, a) { 1589 for (var n in p) n !== "default" && !Object.prototype.hasOwnProperty.call(a, n) && e(a, p, n); 1590 }; 1591 Object.defineProperty(t, "__esModule", { value: !0 }), t.TranslationStatus = void 0, r(B, t), r(q, t), r(Dn, t), r(si, t), r(oi, t), r(qe, t), r(x, t), r(ai, t), r(Mr, t), r(oe, t), r(wa, t), r(_a, t), r(ba, t), r(Ma, t), r(Oa, t), r(Da, t), r(ka, t), r(Na, t), r(za, t), r(ja, t), r(Or, t), r(Ge, t), r(kn, t), r(Dr, t), r(ci, t), r(pi, t), r(ui, t); 1592 var s = hi; 1593 Object.defineProperty(t, "TranslationStatus", { enumerable: !0, get: function() { 1594 return s.TranslationStatus; 1595 } }), r(_h(), t), r(La, t), r(di, t), r(N, t), r(Kh(), t); 1596 }(an)), an; 1597} 1598var Y = {}; 1599Object.defineProperty(Y, "__esModule", { value: !0 }); 1600Y.HeaderNames = void 0; 1601class ce { 1602} 1603Y.HeaderNames = ce; 1604ce.AuthKey = "Ocp-Apim-Subscription-Key"; 1605ce.Authorization = "Authorization"; 1606ce.SpIDAuthKey = "Apim-Subscription-Id"; 1607ce.ConnectionId = "X-ConnectionId"; 1608ce.ContentType = "Content-Type"; 1609ce.CustomCommandsAppId = "X-CommandsAppId"; 1610ce.Path = "Path"; 1611ce.RequestId = "X-RequestId"; 1612ce.RequestStreamId = "X-StreamId"; 1613ce.RequestTimestamp = "X-Timestamp"; 1614var Xe = {}; 1615Object.defineProperty(Xe, "__esModule", { value: !0 }); 1616Xe.AuthInfo = void 0; 1617class Jh { 1618 constructor(e, r) { 1619 this.privHeaderName = e, this.privToken = r; 1620 } 1621 get headerName() { 1622 return this.privHeaderName; 1623 } 1624 get token() { 1625 return this.privToken; 1626 } 1627} 1628Xe.AuthInfo = Jh; 1629Object.defineProperty(Jr, "__esModule", { value: !0 }); 1630Jr.CognitiveSubscriptionKeyAuthentication = void 0; 1631const Vh = I(), Gh = Y, Qh = Xe; 1632class Xh { 1633 /** 1634 * Creates and initializes an instance of the CognitiveSubscriptionKeyAuthentication class. 1635 * @constructor 1636 * @param {string} subscriptionKey - The subscription key 1637 */ 1638 constructor(e) { 1639 if (!e) 1640 throw new Vh.ArgumentNullError("subscriptionKey"); 1641 this.privAuthInfo = new Qh.AuthInfo(Gh.HeaderNames.AuthKey, e); 1642 } 1643 /** 1644 * Fetches the subscription key. 1645 * @member 1646 * @function 1647 * @public 1648 * @param {string} authFetchEventId - The id to fetch. 1649 */ 1650 // eslint-disable-next-line @typescript-eslint/no-unused-vars 1651 fetch(e) { 1652 return Promise.resolve(this.privAuthInfo); 1653 } 1654 /** 1655 * Fetches the subscription key. 1656 * @member 1657 * @function 1658 * @public 1659 * @param {string} authFetchEventId - The id to fetch. 1660 */ 1661 // eslint-disable-next-line @typescript-eslint/no-unused-vars 1662 fetchOnExpiry(e) { 1663 return Promise.resolve(this.privAuthInfo); 1664 } 1665} 1666Jr.CognitiveSubscriptionKeyAuthentication = Xh; 1667var vi = {}; 1668Object.defineProperty(vi, "__esModule", { value: !0 }); 1669vi.CognitiveTokenAuthentication = void 0; 1670const fs = I(), gs = Xe, ms = Y; 1671class Ir { 1672 constructor(e, r) { 1673 if (!e) 1674 throw new fs.ArgumentNullError("fetchCallback"); 1675 if (!r) 1676 throw new fs.ArgumentNullError("fetchOnExpiryCallback"); 1677 this.privFetchCallback = e, this.privFetchOnExpiryCallback = r; 1678 } 1679 fetch(e) { 1680 return this.privFetchCallback(e).then((r) => new gs.AuthInfo(ms.HeaderNames.Authorization, r === void 0 ? void 0 : Ir.privTokenPrefix + r)); 1681 } 1682 fetchOnExpiry(e) { 1683 return this.privFetchOnExpiryCallback(e).then((r) => new gs.AuthInfo(ms.HeaderNames.Authorization, r === void 0 ? void 0 : Ir.privTokenPrefix + r)); 1684 } 1685} 1686vi.CognitiveTokenAuthentication = Ir; 1687Ir.privTokenPrefix = "Bearer "; 1688var Ba = {}; 1689Object.defineProperty(Ba, "__esModule", { value: !0 }); 1690var qa = {}; 1691Object.defineProperty(qa, "__esModule", { value: !0 }); 1692var li = {}; 1693(function(t) { 1694 Object.defineProperty(t, "__esModule", { value: !0 }), t.RecognitionEndedEvent = t.RecognitionCompletionStatus = t.RecognitionStartedEvent = t.ConnectingToServiceEvent = t.ListeningStartedEvent = t.RecognitionTriggeredEvent = t.SpeechRecognitionEvent = void 0; 1695 const e = I(); 1696 class r extends e.PlatformEvent { 1697 constructor(u, h, d, v = e.EventType.Info) { 1698 super(u, v), this.privRequestId = h, this.privSessionId = d; 1699 } 1700 get requestId() { 1701 return this.privRequestId; 1702 } 1703 get sessionId() { 1704 return this.privSessionId; 1705 } 1706 } 1707 t.SpeechRecognitionEvent = r; 1708 class s extends r { 1709 constructor(u, h, d, v) { 1710 super("RecognitionTriggeredEvent", u, h), this.privAudioSourceId = d, this.privAudioNodeId = v; 1711 } 1712 get audioSourceId() { 1713 return this.privAudioSourceId; 1714 } 1715 get audioNodeId() { 1716 return this.privAudioNodeId; 1717 } 1718 } 1719 t.RecognitionTriggeredEvent = s; 1720 class p extends r { 1721 constructor(u, h, d, v) { 1722 super("ListeningStartedEvent", u, h), this.privAudioSourceId = d, this.privAudioNodeId = v; 1723 } 1724 get audioSourceId() { 1725 return this.privAudioSourceId; 1726 } 1727 get audioNodeId() { 1728 return this.privAudioNodeId; 1729 } 1730 } 1731 t.ListeningStartedEvent = p; 1732 class a extends r { 1733 constructor(u, h, d) { 1734 super("ConnectingToServiceEvent", u, d), this.privAuthFetchEventid = h; 1735 } 1736 get authFetchEventid() { 1737 return this.privAuthFetchEventid; 1738 } 1739 } 1740 t.ConnectingToServiceEvent = a; 1741 class n extends r { 1742 constructor(u, h, d, v, f) { 1743 super("RecognitionStartedEvent", u, f), this.privAudioSourceId = h, this.privAudioNodeId = d, this.privAuthFetchEventId = v; 1744 } 1745 get audioSourceId() { 1746 return this.privAudioSourceId; 1747 } 1748 get audioNodeId() { 1749 return this.privAudioNodeId; 1750 } 1751 get authFetchEventId() { 1752 return this.privAuthFetchEventId; 1753 } 1754 } 1755 t.RecognitionStartedEvent = n; 1756 var i; 1757 (function(c) { 1758 c[c.Success = 0] = "Success", c[c.AudioSourceError = 1] = "AudioSourceError", c[c.AudioSourceTimeout = 2] = "AudioSourceTimeout", c[c.AuthTokenFetchError = 3] = "AuthTokenFetchError", c[c.AuthTokenFetchTimeout = 4] = "AuthTokenFetchTimeout", c[c.UnAuthorized = 5] = "UnAuthorized", c[c.ConnectTimeout = 6] = "ConnectTimeout", c[c.ConnectError = 7] = "ConnectError", c[c.ClientRecognitionActivityTimeout = 8] = "ClientRecognitionActivityTimeout", c[c.UnknownError = 9] = "UnknownError"; 1759 })(i = t.RecognitionCompletionStatus || (t.RecognitionCompletionStatus = {})); 1760 class o extends r { 1761 constructor(u, h, d, v, f, m, S, l) { 1762 super("RecognitionEndedEvent", u, f, S === i.Success ? e.EventType.Info : e.EventType.Error), this.privAudioSourceId = h, this.privAudioNodeId = d, this.privAuthFetchEventId = v, this.privStatus = S, this.privError = l, this.privServiceTag = m; 1763 } 1764 get audioSourceId() { 1765 return this.privAudioSourceId; 1766 } 1767 get audioNodeId() { 1768 return this.privAudioNodeId; 1769 } 1770 get authFetchEventId() { 1771 return this.privAuthFetchEventId; 1772 } 1773 get serviceTag() { 1774 return this.privServiceTag; 1775 } 1776 get status() { 1777 return this.privStatus; 1778 } 1779 get error() { 1780 return this.privError; 1781 } 1782 } 1783 t.RecognitionEndedEvent = o; 1784})(li); 1785var tt = {}, ln = {}, fi = {}; 1786const Yh = {}, Zh = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ 1787 __proto__: null, 1788 default: Yh 1789}, Symbol.toStringTag, { value: "Module" })), Ue = /* @__PURE__ */ Wp(Zh); 1790var Nn = {}; 1791(function(t) { 1792 Object.defineProperty(t, "__esModule", { value: !0 }), t.LogLevel = void 0; 1793 const e = I(); 1794 Object.defineProperty(t, "LogLevel", { enumerable: !0, get: function() { 1795 return e.EventType; 1796 } }); 1797})(Nn); 1798var O = {}; 1799Object.defineProperty(O, "__esModule", { value: !0 }); 1800O.Contracts = void 0; 1801class fe { 1802 static throwIfNullOrUndefined(e, r) { 1803 if (e == null) 1804 throw new Error("throwIfNullOrUndefined:" + r); 1805 } 1806 static throwIfNull(e, r) { 1807 if (e === null) 1808 throw new Error("throwIfNull:" + r); 1809 } 1810 static throwIfNullOrWhitespace(e, r) { 1811 if (fe.throwIfNullOrUndefined(e, r), ("" + e).trim().length < 1) 1812 throw new Error("throwIfNullOrWhitespace:" + r); 1813 } 1814 static throwIfNullOrTooLong(e, r, s) { 1815 if (fe.throwIfNullOrUndefined(e, r), ("" + e).length > s) 1816 throw new Error("throwIfNullOrTooLong:" + r + " (more than " + s.toString() + " characters)"); 1817 } 1818 static throwIfNullOrTooShort(e, r, s) { 1819 if (fe.throwIfNullOrUndefined(e, r), ("" + e).length < s) 1820 throw new Error("throwIfNullOrTooShort:" + r + " (less than " + s.toString() + " characters)"); 1821 } 1822 static throwIfDisposed(e) { 1823 if (e) 1824 throw new Error("the object is already disposed"); 1825 } 1826 static throwIfArrayEmptyOrWhitespace(e, r) { 1827 if (fe.throwIfNullOrUndefined(e, r), e.length === 0) 1828 throw new Error("throwIfArrayEmptyOrWhitespace:" + r); 1829 for (const s of e) 1830 fe.throwIfNullOrWhitespace(s, r); 1831 } 1832 static throwIfFileDoesNotExist(e, r) { 1833 fe.throwIfNullOrWhitespace(e, r); 1834 } 1835 static throwIfNotUndefined(e, r) { 1836 if (e !== void 0) 1837 throw new Error("throwIfNotUndefined:" + r); 1838 } 1839 static throwIfNumberOutOfRange(e, r, s, p) { 1840 if (fe.throwIfNullOrUndefined(e, r), e < s || e > p) 1841 throw new Error("throwIfNumberOutOfRange:" + r + " (must be between " + s.toString() + " and " + p.toString() + ")"); 1842 } 1843} 1844O.Contracts = fe; 1845var $h = k && k.__createBinding || (Object.create ? function(t, e, r, s) { 1846 s === void 0 && (s = r), Object.defineProperty(t, s, { enumerable: !0, get: function() { 1847 return e[r]; 1848 } }); 1849} : function(t, e, r, s) { 1850 s === void 0 && (s = r), t[s] = e[r]; 1851}), ed = k && k.__setModuleDefault || (Object.create ? function(t, e) { 1852 Object.defineProperty(t, "default", { enumerable: !0, value: e }); 1853} : function(t, e) { 1854 t.default = e; 1855}), td = k && k.__importStar || function(t) { 1856 if (t && t.__esModule) return t; 1857 var e = {}; 1858 if (t != null) for (var r in t) r !== "default" && Object.prototype.hasOwnProperty.call(t, r) && $h(e, t, r); 1859 return ed(e, t), e; 1860}; 1861Object.defineProperty(fi, "__esModule", { value: !0 }); 1862fi.ConsoleLoggingListener = void 0; 1863const Ss = td(Ue), rt = Nn, rd = O;
1864class id { 1865 constructor(e = rt.LogLevel.None) { 1866 this.privLogPath = void 0, this.privEnableConsoleOutput = !0, this.privLogLevelFilter = e; 1867 } 1868 set logPath(e) { 1869 rd.Contracts.throwIfNullOrUndefined(Ss.openSync, ` 1870File System access not available`), this.privLogPath = e; 1871 } 1872 set enableConsoleOutput(e) { 1873 this.privEnableConsoleOutput = e; 1874 } 1875 onEvent(e) { 1876 if (e.eventType >= this.privLogLevelFilter) { 1877 const r = this.toString(e); 1878 if (this.logCallback && this.logCallback(r), this.privLogPath && Ss.writeFileSync(this.privLogPath, r + ` 1879`, { flag: "a+" }), this.privEnableConsoleOutput) 1880 switch (e.eventType) { 1881 case rt.LogLevel.Debug: 1882 console.debug(r); 1883 break; 1884 case rt.LogLevel.Info: 1885 console.info(r); 1886 break; 1887 case rt.LogLevel.Warning: 1888 console.warn(r); 1889 break; 1890 case rt.LogLevel.Error: 1891 console.error(r); 1892 break; 1893 default: 1894 console.log(r); 1895 break; 1896 } 1897 } 1898 } 1899 toString(e) { 1900 const r = [ 1901 `${e.eventTime}`, 1902 `${e.name}` 1903 ], s = e; 1904 for (const p in s) 1905 if (p && e.hasOwnProperty(p) && p !== "eventTime" && p !== "eventType" && p !== "eventId" && p !== "name" && p !== "constructor") { 1906 const a = s[p]; 1907 let n = "<NULL>"; 1908 a != null && (typeof a == "number" || typeof a == "string" ? n = a.toString() : n = JSON.stringify(a)), r.push(`${p}: ${n}`); 1909 } 1910 return r.join(" | "); 1911 } 1912} 1913fi.ConsoleLoggingListener = id; 1914var Fa = {}; 1915Object.defineProperty(Fa, "__esModule", { value: !0 }); 1916var fn = {}, Ae = {}; 1917(function(t) { 1918 Object.defineProperty(t, "__esModule", { value: !0 }), t.AudioStreamFormatImpl = t.AudioStreamFormat = t.AudioFormatTag = void 0; 1919 var e; 1920 (function(p) { 1921 p[p.PCM = 1] = "PCM", p[p.MuLaw = 2] = "MuLaw", p[p.Siren = 3] = "Siren", p[p.MP3 = 4] = "MP3", p[p.SILKSkype = 5] = "SILKSkype", p[p.OGG_OPUS = 6] = "OGG_OPUS", p[p.WEBM_OPUS = 7] = "WEBM_OPUS", p[p.ALaw = 8] = "ALaw", p[p.FLAC = 9] = "FLAC", p[p.OPUS = 10] = "OPUS", p[p.AMR_WB = 11] = "AMR_WB", p[p.G722 = 12] = "G722"; 1922 })(e = t.AudioFormatTag || (t.AudioFormatTag = {})); 1923 class r { 1924 /** 1925 * Creates an audio stream format object representing the default audio stream 1926 * format (16KHz 16bit mono PCM). 1927 * @member AudioStreamFormat.getDefaultInputFormat 1928 * @function 1929 * @public 1930 * @returns {AudioStreamFormat} The audio stream format being created. 1931 */ 1932 static getDefaultInputFormat() { 1933 return s.getDefaultInputFormat(); 1934 } 1935 /** 1936 * Creates an audio stream format object with the specified format characteristics. 1937 * @member AudioStreamFormat.getWaveFormat 1938 * @function 1939 * @public 1940 * @param {number} samplesPerSecond - Sample rate, in samples per second (Hertz). 1941 * @param {number} bitsPerSample - Bits per sample, typically 16. 1942 * @param {number} channels - Number of channels in the waveform-audio data. Monaural data 1943 * uses one channel and stereo data uses two channels. 1944 * @param {AudioFormatTag} format - Audio format (PCM, alaw or mulaw). 1945 * @returns {AudioStreamFormat} The audio stream format being created. 1946 */ 1947 static getWaveFormat(a, n, i, o) { 1948 return new s(a, n, i, o); 1949 } 1950 /** 1951 * Creates an audio stream format object with the specified pcm waveformat characteristics. 1952 * @member AudioStreamFormat.getWaveFormatPCM 1953 * @function 1954 * @public 1955 * @param {number} samplesPerSecond - Sample rate, in samples per second (Hertz). 1956 * @param {number} bitsPerSample - Bits per sample, typically 16. 1957 * @param {number} channels - Number of channels in the waveform-audio data. Monaural data 1958 * uses one channel and stereo data uses two channels. 1959 * @returns {AudioStreamFormat} The audio stream format being created. 1960 */ 1961 static getWaveFormatPCM(a, n, i) { 1962 return new s(a, n, i); 1963 } 1964 } 1965 t.AudioStreamFormat = r; 1966 class s extends r { 1967 /** 1968 * Creates an instance with the given values. 1969 * @constructor 1970 * @param {number} samplesPerSec - Samples per second. 1971 * @param {number} bitsPerSample - Bits per sample. 1972 * @param {number} channels - Number of channels. 1973 * @param {AudioFormatTag} format - Audio format (PCM, alaw or mulaw). 1974 */ 1975 constructor(a = 16e3, n = 16, i = 1, o = e.PCM) { 1976 super(); 1977 let c = !0; 1978 switch (o) { 1979 case e.PCM: 1980 this.formatTag = 1; 1981 break; 1982 case e.ALaw: 1983 this.formatTag = 6; 1984 break; 1985 case e.MuLaw: 1986 this.formatTag = 7; 1987 break; 1988 default: 1989 c = !1; 1990 } 1991 if (this.bitsPerSample = n, this.samplesPerSec = a, this.channels = i, this.avgBytesPerSec = this.samplesPerSec * this.channels * (this.bitsPerSample / 8), this.blockAlign = this.channels * Math.max(this.bitsPerSample, 8), c) { 1992 this.privHeader = new ArrayBuffer(44); 1993 const u = new DataView(this.privHeader); 1994 this.setString(u, 0, "RIFF"), u.setUint32(4, 0, !0), this.setString(u, 8, "WAVEfmt "), u.setUint32(16, 16, !0), u.setUint16(20, this.formatTag, !0), u.setUint16(22, this.channels, !0), u.setUint32(24, this.samplesPerSec, !0), u.setUint32(28, this.avgBytesPerSec, !0), u.setUint16(32, this.channels * (this.bitsPerSample / 8), !0), u.setUint16(34, this.bitsPerSample,
1994!0), this.setString(u, 36, "data"), u.setUint32(40, 0, !0); 1995 } 1996 } 1997 /** 1998 * Retrieves the default input format. 1999 * @member AudioStreamFormatImpl.getDefaultInputFormat 2000 * @function 2001 * @public 2002 * @returns {AudioStreamFormatImpl} The default input format. 2003 */ 2004 static getDefaultInputFormat() { 2005 return new s(); 2006 } 2007 /** 2008 * Creates an audio context appropriate to current browser 2009 * @member AudioStreamFormatImpl.getAudioContext 2010 * @function 2011 * @public 2012 * @returns {AudioContext} An audio context instance 2013 */ 2014 /* eslint-disable */ 2015 static getAudioContext(a) { 2016 const n = window.AudioContext || window.webkitAudioContext || !1; 2017 if (n) 2018 return a !== void 0 && navigator.mediaDevices.getSupportedConstraints().sampleRate ? new n({ sampleRate: a }) : new n(); 2019 throw new Error("Browser does not support Web Audio API (AudioContext is not available)."); 2020 } 2021 /* eslint-enable */ 2022 /** 2023 * Closes the configuration object. 2024 * @member AudioStreamFormatImpl.prototype.close 2025 * @function 2026 * @public 2027 */ 2028 close() { 2029 } 2030 get header() { 2031 return this.privHeader; 2032 } 2033 setString(a, n, i) { 2034 for (let o = 0; o < i.length; o++) 2035 a.setUint8(n + o, i.charCodeAt(o)); 2036 } 2037 } 2038 t.AudioStreamFormatImpl = s; 2039})(Ae); 2040var Cs; 2041function nd() { 2042 return Cs || (Cs = 1, function(t) { 2043 Object.defineProperty(t, "__esModule", { value: !0 }), t.MicAudioSource = t.AudioWorkletSourceURLPropertyName = void 0; 2044 const e = A(), r = I(), s = Ae; 2045 t.AudioWorkletSourceURLPropertyName = "MICROPHONE-WorkletSourceUrl"; 2046 class p { 2047 constructor(n, i, o, c) { 2048 this.privRecorder = n, this.deviceId = i, this.privStreams = {}, this.privOutputChunkSize = p.AUDIOFORMAT.avgBytesPerSec / 10, this.privId = o || (0, r.createNoDashGuid)(), this.privEvents = new r.EventSource(), this.privMediaStream = c || null, this.privIsClosing = !1; 2049 } 2050 get format() { 2051 return Promise.resolve(p.AUDIOFORMAT); 2052 } 2053 turnOn() { 2054 if (this.privInitializeDeferral) 2055 return this.privInitializeDeferral.promise; 2056 this.privInitializeDeferral = new r.Deferred(); 2057 try { 2058 this.createAudioContext(); 2059 } catch (o) { 2060 if (o instanceof Error) { 2061 const c = o; 2062 this.privInitializeDeferral.reject(c.name + ": " + c.message); 2063 } else 2064 this.privInitializeDeferral.reject(o); 2065 return this.privInitializeDeferral.promise; 2066 } 2067 const n = window.navigator; 2068 let i = ( 2069 // eslint-disable-next-line 2070 n.getUserMedia || n.webkitGetUserMedia || n.mozGetUserMedia || n.msGetUserMedia 2071 ); 2072 if (n.mediaDevices && (i = (o, c, u) => { 2073 n.mediaDevices.getUserMedia(o).then(c).catch(u); 2074 }), i) { 2075 const o = () => { 2076 this.onEvent(new r.AudioSourceInitializingEvent(this.privId)), this.privMediaStream && this.privMediaStream.active ? (this.onEvent(new r.AudioSourceReadyEvent(this.privId)), this.privInitializeDeferral.resolve()) : i({ audio: this.deviceId ? { deviceId: this.deviceId } : !0, video: !1 }, (c) => { 2077 this.privMediaStream = c, this.onEvent(new r.AudioSourceReadyEvent(this.privId)), this.privInitializeDeferral.resolve(); 2078 }, (c) => { 2079 const u = `Error occurred during microphone initialization: ${c}`; 2080 this.privInitializeDeferral.reject(u), this.onEvent(new r.AudioSourceErrorEvent(this.privId, u)); 2081 }); 2082 }; 2083 this.privContext.state === "suspended" ? this.privContext.resume().then(o).catch((c) => { 2084 this.privInitializeDeferral.reject(`Failed to initialize audio context: ${c}`); 2085 }) : o(); 2086 } else { 2087 const o = "Browser does not support getUserMedia."; 2088 this.privInitializeDeferral.reject(o), this.onEvent(new r.AudioSourceErrorEvent(o, "")); 2089 } 2090 return this.privInitializeDeferral.promise; 2091 } 2092 id() { 2093 return this.privId; 2094 } 2095 attach(n) { 2096 return this.onEvent(new r.AudioStreamNodeAttachingEvent(this.privId, n)), this.listen(n).then((i) => (this.onEvent(new r.AudioStreamNodeAttachedEvent(this.privId, n)), { 2097 detach: async () => (i.readEnded(), delete this.privStreams[n], this.onEvent(new r.AudioStreamNodeDetachedEvent(this.privId, n)), this.turnOff()), 2098 id: () => n, 2099 read: () => i.read() 2100 })); 2101 } 2102 detach(n) { 2103 n && this.privStreams[n] && (this.privStreams[n].close(), delete this.privStreams[n], this.onEvent(new r.AudioStreamNodeDetachedEvent(this.privId, n))); 2104 } 2105 async turnOff() { 2106 for (const n in this.privStreams) 2107 if (n) { 2108 const i = this.privStreams[n]; 2109 i && i.close(); 2110 }
2111 this.onEvent(new r.AudioSourceOffEvent(this.privId)), this.privInitializeDeferral && (await this.privInitializeDeferral, this.privInitializeDeferral = null), await this.destroyAudioContext(); 2112 } 2113 get events() { 2114 return this.privEvents; 2115 } 2116 get deviceInfo() { 2117 return this.getMicrophoneLabel().then((n) => ({ 2118 bitspersample: p.AUDIOFORMAT.bitsPerSample, 2119 channelcount: p.AUDIOFORMAT.channels, 2120 connectivity: e.connectivity.Unknown, 2121 manufacturer: "Speech SDK", 2122 model: n, 2123 samplerate: p.AUDIOFORMAT.samplesPerSec, 2124 type: e.type.Microphones 2125 })); 2126 } 2127 setProperty(n, i) { 2128 if (n === t.AudioWorkletSourceURLPropertyName) 2129 this.privRecorder.setWorkletUrl(i); 2130 else 2131 throw new Error("Property '" + n + "' is not supported on Microphone."); 2132 } 2133 getMicrophoneLabel() { 2134 const n = "microphone"; 2135 if (this.privMicrophoneLabel !== void 0) 2136 return Promise.resolve(this.privMicrophoneLabel); 2137 if (this.privMediaStream === void 0 || !this.privMediaStream.active) 2138 return Promise.resolve(n); 2139 this.privMicrophoneLabel = n; 2140 const i = this.privMediaStream.getTracks()[0].getSettings().deviceId; 2141 if (i === void 0) 2142 return Promise.resolve(this.privMicrophoneLabel); 2143 const o = new r.Deferred(); 2144 return navigator.mediaDevices.enumerateDevices().then((c) => { 2145 for (const u of c) 2146 if (u.deviceId === i) { 2147 this.privMicrophoneLabel = u.label; 2148 break; 2149 } 2150 o.resolve(this.privMicrophoneLabel); 2151 }, () => o.resolve(this.privMicrophoneLabel)), o.promise; 2152 } 2153 async listen(n) { 2154 await this.turnOn(); 2155 const i = new r.ChunkedArrayBufferStream(this.privOutputChunkSize, n); 2156 this.privStreams[n] = i; 2157 try { 2158 this.privRecorder.record(this.privContext, this.privMediaStream, i); 2159 } catch (c) { 2160 throw this.onEvent(new r.AudioStreamNodeErrorEvent(this.privId, n, c)), c; 2161 } 2162 return i; 2163 } 2164 onEvent(n) { 2165 this.privEvents.onEvent(n), r.Events.instance.onEvent(n); 2166 } 2167 createAudioContext() { 2168 this.privContext || (this.privContext = s.AudioStreamFormatImpl.getAudioContext(p.AUDIOFORMAT.samplesPerSec)); 2169 } 2170 async destroyAudioContext() { 2171 if (!this.privContext) 2172 return; 2173 this.privRecorder.releaseMediaResources(this.privContext); 2174 let n = !1; 2175 "close" in this.privContext && (n = !0), n ? this.privIsClosing || (this.privIsClosing = !0, await this.privContext.close(), this.privContext = null, this.privIsClosing = !1) : this.privContext !== null && this.privContext.state === "running" && await this.privContext.suspend(); 2176 } 2177 } 2178 t.MicAudioSource = p, p.AUDIOFORMAT = s.AudioStreamFormat.getDefaultInputFormat(); 2179 }(fn)), fn; 2180} 2181var it = {}, ys; 2182function sd() { 2183 if (ys) return it; 2184 ys = 1, Object.defineProperty(it, "__esModule", { value: !0 }), it.FileAudioSource = void 0; 2185 const t = A(), e = I(), r = Ae; 2186 let s = class { 2187 constructor(a, n, i) { 2188 this.privStreams = {}, this.privHeaderEnd = 44, this.privId = i || (0, e.createNoDashGuid)(), this.privEvents = new e.EventSource(), this.privSource = a, typeof window < "u" && typeof Blob < "u" && this.privSource instanceof Blob ? this.privFilename = a.name : this.privFilename = n || "unknown.wav", this.privAudioFormatPromise = this.readHeader(); 2189 } 2190 get format() { 2191 return this.privAudioFormatPromise; 2192 } 2193 turnOn() { 2194 if (this.privFilename.lastIndexOf(".wav") !== this.privFilename.length - 4) { 2195 const a = this.privFilename + " is not supported. Only WAVE files are allowed at the moment."; 2196 return this.onEvent(new e.AudioSourceErrorEvent(a, "")), Promise.reject(a); 2197 } 2198 this.onEvent(new e.AudioSourceInitializingEvent(this.privId)), this.onEvent(new e.AudioSourceReadyEvent(this.privId)); 2199 } 2200 id() { 2201 return this.privId; 2202 } 2203 async attach(a) { 2204 this.onEvent(new e.AudioStreamNodeAttachingEvent(this.privId, a)); 2205 const n = await this.upload(a); 2206 return this.onEvent(new e.AudioStreamNodeAttachedEvent(this.privId, a)), Promise.resolve({ 2207 detach: async () => { 2208 n.readEnded(), delete this.privStreams[a], this.onEvent(new e.AudioStreamNodeDetachedEvent(this.privId, a)), await this.turnOff(); 2209 }, 2210 id: () => a, 2211 read: () => n.read() 2212 }); 2213 } 2214 detach(a) { 2215 a && this.privStreams[a] && (this.privStreams[a].close(), delete this.privStreams[a], this.onEvent(new e.AudioStreamNodeDetachedEvent(this.privId, a))); 2216 } 2217 turnOff() { 2218 for (const a in this.privStreams) 2219 if (a) { 2220 const n = this.privStreams[a]; 2221 n && !n.isClosed && n.close(); 2222 } 2223 return this.onEvent(new e.AudioSourceOffEvent(this.privId)
2223), Promise.resolve(); 2224 } 2225 get events() { 2226 return this.privEvents; 2227 } 2228 get deviceInfo() { 2229 return this.privAudioFormatPromise.then((a) => Promise.resolve({ 2230 bitspersample: a.bitsPerSample, 2231 channelcount: a.channels, 2232 connectivity: t.connectivity.Unknown, 2233 manufacturer: "Speech SDK", 2234 model: "File", 2235 samplerate: a.samplesPerSec, 2236 type: t.type.File 2237 })); 2238 } 2239 readHeader() { 2240 const n = this.privSource.slice(0, 4296), i = new e.Deferred(), o = (c) => { 2241 const u = new DataView(c), h = (l) => String.fromCharCode(u.getUint8(l), u.getUint8(l + 1), u.getUint8(l + 2), u.getUint8(l + 3)); 2242 if (h(0) !== "RIFF") { 2243 i.reject("Invalid WAV header in file, RIFF was not found"); 2244 return; 2245 } 2246 if (h(8) !== "WAVE" || h(12) !== "fmt ") { 2247 i.reject("Invalid WAV header in file, WAVEfmt was not found"); 2248 return; 2249 } 2250 const d = u.getInt32(16, !0), v = u.getUint16(22, !0), f = u.getUint32(24, !0), m = u.getUint16(34, !0); 2251 let S = 36 + Math.max(d - 16, 0); 2252 for (; h(S) !== "data"; S += 2) 2253 if (S > 4288) { 2254 i.reject("Invalid WAV header in file, data block was not found"); 2255 return; 2256 } 2257 this.privHeaderEnd = S + 8, i.resolve(r.AudioStreamFormat.getWaveFormatPCM(f, m, v)); 2258 }; 2259 if (typeof window < "u" && typeof Blob < "u" && n instanceof Blob) { 2260 const c = new FileReader(); 2261 c.onload = (u) => { 2262 const h = u.target.result; 2263 o(h); 2264 }, c.readAsArrayBuffer(n); 2265 } else { 2266 const c = n; 2267 o(c.buffer.slice(c.byteOffset, c.byteOffset + c.byteLength)); 2268 } 2269 return i.promise; 2270 } 2271 async upload(a) { 2272 const n = (i) => { 2273 const o = `Error occurred while processing '${this.privFilename}'. ${i}`; 2274 throw this.onEvent(new e.AudioStreamNodeErrorEvent(this.privId, a, o)), new Error(o); 2275 }; 2276 try { 2277 await this.turnOn(); 2278 const i = await this.privAudioFormatPromise, o = new e.ChunkedArrayBufferStream(i.avgBytesPerSec / 10, a); 2279 this.privStreams[a] = o; 2280 const c = this.privSource.slice(this.privHeaderEnd), u = (h) => { 2281 o.isClosed || (o.writeStreamChunk({ 2282 buffer: h, 2283 isEnd: !1, 2284 timeReceived: Date.now() 2285 }), o.close()); 2286 }; 2287 if (typeof window < "u" && typeof Blob < "u" && c instanceof Blob) { 2288 const h = new FileReader(); 2289 h.onerror = (d) => n(d.toString()), h.onload = (d) => { 2290 const v = d.target.result; 2291 u(v); 2292 }, h.readAsArrayBuffer(c); 2293 } else { 2294 const h = c; 2295 u(h.buffer.slice(h.byteOffset, h.byteOffset + h.byteLength)); 2296 } 2297 return o; 2298 } catch (i) { 2299 n(i); 2300 } 2301 } 2302 onEvent(a) { 2303 this.privEvents.onEvent(a), e.Events.instance.onEvent(a); 2304 } 2305 }; 2306 return it.FileAudioSource = s, it; 2307} 2308var gi = {}; 2309Object.defineProperty(gi, "__esModule", { value: !0 }); 2310gi.PcmRecorder = void 0; 2311const od = I(); 2312class ad { 2313 constructor(e) { 2314 this.privStopInputOnRelease = e; 2315 } 2316 record(e, r, s) { 2317 const a = new od.RiffPcmEncoder(e.sampleRate, 16e3), n = e.createMediaStreamSource(r), i = () => { 2318 const c = (() => { 2319 let u = 0; 2320 try { 2321 return e.createScriptProcessor(u, 1, 1); 2322 } catch { 2323 u = 2048; 2324 let d = e.sampleRate; 2325 for (; u < 16384 && d >= 32e3; ) 2326 u <<= 1, d >>= 1; 2327 return e.createScriptProcessor(u, 1, 1); 2328 } 2329 })(); 2330 c.onaudioprocess = (u) => { 2331 const h = u.inputBuffer.getChannelData(0); 2332 if (s && !s.isClosed) { 2333 const d = a.encode(h); 2334 d && s.writeStreamChunk({ 2335 buffer: d, 2336 isEnd: !1, 2337 timeReceived: Date.now() 2338 }); 2339 } 2340 }, n.connect(c), c.connect(e.destination), this.privMediaResources = { 2341 scriptProcessorNode: c, 2342 source: n, 2343 stream: r 2344 }; 2345 }, o = !!this.privSpeechProcessorScript && this.privSpeechProcessorScript.toLowerCase() === "ignore"; 2346 if (e.audioWorklet && !o) { 2347 if (!this.privSpeechProcessorScript) { 2348 const c = `class SP extends AudioWorkletProcessor { 2349 constructor(options) { 2350 super(options); 2351 } 2352 process(inputs, outputs) { 2353 const input = inputs[0]; 2354 const output = []; 2355 for (let channel = 0; channel < input.length; channel += 1) { 2356 output[channel] = input[channel]; 2357 } 2358 this.port.postMessage(output[0]); 2359 return true; 2360 } 2361 } 2362 registerProcessor('speech-processor', SP);`, u = new Blob([c], { type: "application/javascript; charset=utf-8" }); 2363 this.privSpeechProcessorScript = URL.createObjectURL(u); 2364 } 2365 e.audioWorklet.addModule(this.privSpeechProcessorScript).then(() => { 2366 const c = new AudioWorkletNode(e, "speech-processor"); 2367 c.port.onmessage = (u) => { 2368 const h = u.data; 2369 if (s && !s.isClosed) { 2370 const d = a.encode(h); 2371 d && s.writeStreamChunk({ 2372 buffer: d, 2373 isEnd: !1, 2374 timeReceived: Date.now() 2375 }); 2376 } 2377 }, n.connect(c), c.connect(e.destination), this.privMediaResources = { 2378 scriptProcessorNode: c, 2379 source: n, 2380 stream: r 2381 }; 2382 }).catch(() => { 2383 i(); 2384 }); 2385 } else
2386 try { 2387 i(); 2388 } catch (c) { 2389 throw new Error(`Unable to start audio worklet node for PCMRecorder: ${c}`); 2390 } 2391 } 2392 releaseMediaResources(e) { 2393 this.privMediaResources && (this.privMediaResources.scriptProcessorNode && (this.privMediaResources.scriptProcessorNode.disconnect(e.destination), this.privMediaResources.scriptProcessorNode = null), this.privMediaResources.source && (this.privMediaResources.source.disconnect(), this.privStopInputOnRelease && this.privMediaResources.stream.getTracks().forEach((r) => r.stop()), this.privMediaResources.source = null)); 2394 } 2395 setWorkletUrl(e) { 2396 this.privSpeechProcessorScript = e; 2397 } 2398} 2399gi.PcmRecorder = ad; 2400var mi = {}, kr = {}, cd = k && k.__createBinding || (Object.create ? function(t, e, r, s) { 2401 s === void 0 && (s = r), Object.defineProperty(t, s, { enumerable: !0, get: function() { 2402 return e[r]; 2403 } }); 2404} : function(t, e, r, s) { 2405 s === void 0 && (s = r), t[s] = e[r]; 2406}), pd = k && k.__setModuleDefault || (Object.create ? function(t, e) { 2407 Object.defineProperty(t, "default", { enumerable: !0, value: e }); 2408} : function(t, e) { 2409 t.default = e; 2410}), Ua = k && k.__importStar || function(t) { 2411 if (t && t.__esModule) return t; 2412 var e = {}; 2413 if (t != null) for (var r in t) r !== "default" && Object.prototype.hasOwnProperty.call(t, r) && cd(e, t, r); 2414 return pd(e, t), e; 2415}, zn = k && k.__importDefault || function(t) { 2416 return t && t.__esModule ? t : { default: t }; 2417}; 2418Object.defineProperty(kr, "__esModule", { value: !0 }); 2419kr.WebsocketMessageAdapter = void 0; 2420const ud = Ua(Ue), hd = Ua(Ue), dd = zn(Ue), vd = zn(Ue), ld = zn(Ue), fd = Y, b = I(); 2421class wr { 2422 constructor(e, r, s, p, a, n) { 2423 if (!e) 2424 throw new b.ArgumentNullError("uri"); 2425 if (!s) 2426 throw new b.ArgumentNullError("messageFormatter"); 2427 this.proxyInfo = p, this.privConnectionEvents = new b.EventSource(), this.privConnectionId = r, this.privMessageFormatter = s, this.privConnectionState = b.ConnectionState.None, this.privUri = e, this.privHeaders = a, this.privEnableCompression = n, this.privHeaders[fd.HeaderNames.ConnectionId] = this.privConnectionId, this.privHeaders.connectionId = this.privConnectionId, this.privLastErrorReceived = ""; 2428 } 2429 get state() { 2430 return this.privConnectionState; 2431 } 2432 open() { 2433 if (this.privConnectionState === b.ConnectionState.Disconnected) 2434 return Promise.reject(`Cannot open a connection that is in ${this.privConnectionState} state`); 2435 if (this.privConnectionEstablishDeferral) 2436 return this.privConnectionEstablishDeferral.promise; 2437 this.privConnectionEstablishDeferral = new b.Deferred(), this.privCertificateValidatedDeferral = new b.Deferred(), this.privConnectionState = b.ConnectionState.Connecting; 2438 try { 2439 if (typeof WebSocket < "u" && !wr.forceNpmWebSocket) 2440 this.privCertificateValidatedDeferral.resolve(), this.privWebsocketClient = new WebSocket(this.privUri); 2441 else { 2442 let r = new URL(this.privUri).protocol; 2443 (r == null ? void 0 : r.toLocaleLowerCase()) === "wss:" ? r = "https:" : (r == null ? void 0 : r.toLocaleLowerCase()) === "ws:" && (r = "http:"); 2444 const s = { headers: this.privHeaders, perMessageDeflate: this.privEnableCompression, followRedirects: r.toLocaleLowerCase() === "https:" }; 2445 this.privCertificateValidatedDeferral.resolve(), s.agent = this.getAgent(), s.agent.protocol = r, this.privWebsocketClient = new ld.default(this.privUri, s), this.privWebsocketClient.on("redirect", (p) => { 2446 const a = new b.ConnectionRedirectEvent(this.privConnectionId, p, this.privUri, `Getting redirect URL from endpoint ${this.privUri} with redirect URL '${p}'`); 2447 b.Events.instance.onEvent(a); 2448 }); 2449 } 2450 this.privWebsocketClient.binaryType = "arraybuffer", this.privReceivingMessageQueue = new b.Queue(), this.privDisconnectDeferral = new b.Deferred(), this.privSendMessageQueue = new b.Queue(), this.processSendQueue().catch((e) => { 2451 b.Events.instance.onEvent(new b.BackgroundEvent(e)); 2452 }); 2453 } catch (e) { 2454 return this.privConnectionEstablishDeferral.resolve(new b.ConnectionOpenResponse(500, e)), this.privConnectionEstablishDeferral.promise; 2455 } 2456 return this.onEvent(new b.ConnectionStartEvent(this.privConnectionId, this.privUri)), this.privWebsocketClient.onopen = () => { 2457 this.privCertificateValidatedDeferral.promise.then(() => { 2458 this.privConnectionState = b.ConnectionState.Connected, this.onEvent(new b.ConnectionEstablishedEvent(this.privConnectionId)), this.privConnectionEstablishDeferral.resolve(new b.ConnectionOpenResponse(200, "")); 2459 }, (e) => { 2460 this.privConnectionEstablishDeferral.reject(e); 2461 }); 2462 }, this.privWebsocketClient.onerror = (e) => { 2463 this.onEvent(new b.ConnectionErrorEvent(this.privConnectionId, e.message, e.type)), this.privLastErrorReceived = e.message; 2464 }, this.privWebsocketClient.onclose = (e) => { 2465 this.privConnectionState === b.ConnectionState.Connecting ? (this.privConnectionState = b.ConnectionState.Disconnected, this.privConnectionEstablishDeferral.resolve(new b.ConnectionOpenResponse(e.code, e.reason + " " + this.privLastErrorReceived))) : (this.privConnectionState = b.ConnectionState.Disconnected, this.privWebsocketClient = null, this.onEvent(new b.ConnectionClosedEvent(this.privConnectionId, e.code, e.reason))), this.onClose(e.code, e.reason).catch((r) => {
2466 b.Events.instance.onEvent(new b.BackgroundEvent(r)); 2467 }); 2468 }, this.privWebsocketClient.onmessage = (e) => { 2469 const r = (/* @__PURE__ */ new Date()).toISOString(); 2470 if (this.privConnectionState === b.ConnectionState.Connected) { 2471 const s = new b.Deferred(); 2472 if (this.privReceivingMessageQueue.enqueueFromPromise(s.promise), e.data instanceof ArrayBuffer) { 2473 const p = new b.RawWebsocketMessage(b.MessageType.Binary, e.data); 2474 this.privMessageFormatter.toConnectionMessage(p).then((a) => { 2475 this.onEvent(new b.ConnectionMessageReceivedEvent(this.privConnectionId, r, a)), s.resolve(a); 2476 }, (a) => { 2477 s.reject(`Invalid binary message format. Error: ${a}`); 2478 }); 2479 } else { 2480 const p = new b.RawWebsocketMessage(b.MessageType.Text, e.data); 2481 this.privMessageFormatter.toConnectionMessage(p).then((a) => { 2482 this.onEvent(new b.ConnectionMessageReceivedEvent(this.privConnectionId, r, a)), s.resolve(a); 2483 }, (a) => { 2484 s.reject(`Invalid text message format. Error: ${a}`); 2485 }); 2486 } 2487 } 2488 }, this.privConnectionEstablishDeferral.promise; 2489 } 2490 send(e) { 2491 if (this.privConnectionState !== b.ConnectionState.Connected) 2492 return Promise.reject(`Cannot send on connection that is in ${b.ConnectionState[this.privConnectionState]} state`); 2493 const r = new b.Deferred(), s = new b.Deferred(); 2494 return this.privSendMessageQueue.enqueueFromPromise(s.promise), this.privMessageFormatter.fromConnectionMessage(e).then((p) => { 2495 s.resolve({ 2496 Message: e, 2497 RawWebsocketMessage: p, 2498 sendStatusDeferral: r 2499 }); 2500 }, (p) => { 2501 s.reject(`Error formatting the message. ${p}`); 2502 }), r.promise; 2503 } 2504 read() { 2505 return this.privConnectionState !== b.ConnectionState.Connected ? Promise.reject(`Cannot read on connection that is in ${this.privConnectionState} state`) : this.privReceivingMessageQueue.dequeue(); 2506 } 2507 close(e) { 2508 if (this.privWebsocketClient) 2509 this.privConnectionState !== b.ConnectionState.Disconnected && this.privWebsocketClient.close(1e3, e || "Normal closure by client"); 2510 else 2511 return Promise.resolve(); 2512 return this.privDisconnectDeferral.promise; 2513 } 2514 get events() { 2515 return this.privConnectionEvents; 2516 } 2517 sendRawMessage(e) { 2518 try { 2519 if (!e) 2520 return Promise.resolve(); 2521 if (this.onEvent(new b.ConnectionMessageSentEvent(this.privConnectionId, (/* @__PURE__ */ new Date()).toISOString(), e.Message)), this.isWebsocketOpen) 2522 this.privWebsocketClient.send(e.RawWebsocketMessage.payload); 2523 else 2524 return Promise.reject("websocket send error: Websocket not ready " + this.privConnectionId + " " + e.Message.id + " " + new Error().stack); 2525 return Promise.resolve(); 2526 } catch (r) { 2527 return Promise.reject(`websocket send error: ${r}`); 2528 } 2529 } 2530 async onClose(e, r) { 2531 const s = `Connection closed. ${e}: ${r}`; 2532 this.privConnectionState = b.ConnectionState.Disconnected, this.privDisconnectDeferral.resolve(), await this.privReceivingMessageQueue.drainAndDispose(() => { 2533 }, s), await this.privSendMessageQueue.drainAndDispose((p) => { 2534 p.sendStatusDeferral.reject(s); 2535 }, s); 2536 } 2537 async processSendQueue() { 2538 for (; ; ) { 2539 const r = await this.privSendMessageQueue.dequeue(); 2540 if (!r) 2541 return; 2542 try { 2543 await this.sendRawMessage(r), r.sendStatusDeferral.resolve(); 2544 } catch (s) { 2545 r.sendStatusDeferral.reject(s); 2546 } 2547 } 2548 } 2549 onEvent(e) { 2550 this.privConnectionEvents.onEvent(e), b.Events.instance.onEvent(e); 2551 } 2552 // eslint-disable-next-line @typescript-eslint/no-unused-vars 2553 getAgent() { 2554 const e = new dd.default.Agent(this.createConnection); 2555 return this.proxyInfo !== void 0 && this.proxyInfo.HostName !== void 0 && this.proxyInfo.Port > 0 && (e.proxyInfo = this.proxyInfo), e; 2556 } 2557 static GetProxyAgent(e) { 2558 const r = { 2559 host: e.HostName, 2560 port: e.Port 2561 }; 2562 return e.UserName ? r.headers = { 2563 "Proxy-Authentication": "Basic " + Buffer.from(`${e.UserName}:${e.Password === void 0 ? "" : e.Password}`).toString("base64") 2564 } : r.headers = {}, r.headers.requestOCSP = "true", new vd.default(r); 2565 } 2566 createConnection(e, r) { 2567 let s; 2568 if (r = { 2569 ...r, 2570 requestOCSP: !0, 2571 servername: r.host 2572 }, this.proxyInfo) { 2573 const a = wr.GetProxyAgent(this.proxyInfo); 2574 s = new Promise((n, i) => { 2575 a.callback(e, r, (o, c) => { 2576 o ? i(o) : n(c); 2577 }); 2578 }); 2579 } else 2580 r.secureEndpoint ? s = Promise.resolve(hd.connect(r)) : s = Promise.resolve(ud.connect(r)); 2581 return s; 2582 } 2583 get isWebsocketOpen() { 2584 return this.privWebsocketClient && this.privWebsocketClient.readyState === this.privWebsocketClient.OPEN; 2585 } 2586} 2587kr.WebsocketMessageAdapter = wr; 2588wr.forceNpmWebSocket = !1;
2589Object.defineProperty(mi, "__esModule", { value: !0 }); 2590mi.WebsocketConnection = void 0; 2591const gn = I(), gd = kr; 2592class md { 2593 constructor(e, r, s, p, a, n = !1, i) { 2594 if (this.privIsDisposed = !1, !e) 2595 throw new gn.ArgumentNullError("uri"); 2596 if (!p) 2597 throw new gn.ArgumentNullError("messageFormatter"); 2598 this.privMessageFormatter = p; 2599 let o = "", c = 0; 2600 if (r) { 2601 for (const u in r) 2602 if (u) { 2603 o += c === 0 && e.indexOf("?") === -1 ? "?" : "&"; 2604 const h = encodeURIComponent(u); 2605 o += h; 2606 let d = r[u]; 2607 d && (d = encodeURIComponent(d), o += `=${d}`), c++; 2608 } 2609 } 2610 if (s) { 2611 for (const u in s) 2612 if (u) { 2613 o += c === 0 && e.indexOf("?") === -1 ? "?" : "&"; 2614 const h = encodeURIComponent(s[u]); 2615 o += `${u}=${h}`, c++; 2616 } 2617 } 2618 this.privUri = e + o, this.privId = i || (0, gn.createNoDashGuid)(), this.privConnectionMessageAdapter = new gd.WebsocketMessageAdapter(this.privUri, this.id, this.privMessageFormatter, a, s, n); 2619 } 2620 async dispose() { 2621 this.privIsDisposed = !0, this.privConnectionMessageAdapter && await this.privConnectionMessageAdapter.close(); 2622 } 2623 isDisposed() { 2624 return this.privIsDisposed; 2625 } 2626 get id() { 2627 return this.privId; 2628 } 2629 get uri() { 2630 return this.privUri; 2631 } 2632 state() { 2633 return this.privConnectionMessageAdapter.state; 2634 } 2635 open() { 2636 return this.privConnectionMessageAdapter.open(); 2637 } 2638 send(e) { 2639 return this.privConnectionMessageAdapter.send(e); 2640 } 2641 read() { 2642 return this.privConnectionMessageAdapter.read(); 2643 } 2644 get events() { 2645 return this.privConnectionMessageAdapter.events; 2646 } 2647} 2648mi.WebsocketConnection = md; 2649var Si = {}; 2650Object.defineProperty(Si, "__esModule", { value: !0 }); 2651Si.ReplayableAudioNode = void 0; 2652class Sd { 2653 constructor(e, r) { 2654 this.privBuffers = [], this.privReplayOffset = 0, this.privLastShrinkOffset = 0, this.privBufferStartOffset = 0, this.privBufferSerial = 0, this.privBufferedBytes = 0, this.privReplay = !1, this.privLastChunkAcquiredTime = 0, this.privAudioNode = e, this.privBytesPerSecond = r; 2655 } 2656 id() { 2657 return this.privAudioNode.id(); 2658 } 2659 // Reads and returns the next chunk of audio buffer. 2660 // If replay of existing buffers are needed, read() will first seek and replay 2661 // existing content, and upoin completion it will read new content from the underlying 2662 // audio node, saving that content into the replayable buffers. 2663 read() { 2664 if (this.privReplay && this.privBuffers.length !== 0) { 2665 const e = this.privReplayOffset - this.privBufferStartOffset; 2666 let r = Math.round(e * this.privBytesPerSecond * 1e-7); 2667 r % 2 !== 0 && r++; 2668 let s = 0; 2669 for (; s < this.privBuffers.length && r >= this.privBuffers[s].chunk.buffer.byteLength; ) 2670 r -= this.privBuffers[s++].chunk.buffer.byteLength; 2671 if (s < this.privBuffers.length) { 2672 const p = this.privBuffers[s].chunk.buffer.slice(r); 2673 return this.privReplayOffset += p.byteLength / this.privBytesPerSecond * 1e7, s === this.privBuffers.length - 1 && (this.privReplay = !1), Promise.resolve({ 2674 buffer: p, 2675 isEnd: !1, 2676 timeReceived: this.privBuffers[s].chunk.timeReceived 2677 }); 2678 } 2679 } 2680 return this.privAudioNode.read().then((e) => (e && e.buffer && this.privBuffers && (this.privBuffers.push(new Cd(e, this.privBufferSerial++, this.privBufferedBytes)), this.privBufferedBytes += e.buffer.byteLength), e)); 2681 } 2682 detach() { 2683 return this.privBuffers = void 0, this.privAudioNode.detach(); 2684 } 2685 replay() { 2686 this.privBuffers && this.privBuffers.length !== 0 && (this.privReplay = !0, this.privReplayOffset = this.privLastShrinkOffset); 2687 } 2688 // Shrinks the existing audio buffers to start at the new offset, or at the 2689 // beginning of the buffer closest to the requested offset. 2690 // A replay request will start from the last shrink point. 2691 shrinkBuffers(e) { 2692 if (this.privBuffers === void 0 || this.privBuffers.length === 0) 2693 return; 2694 this.privLastShrinkOffset = e; 2695 const r = e - this.privBufferStartOffset; 2696 let s = Math.round(r * this.privBytesPerSecond * 1e-7), p = 0; 2697 for (; p < this.privBuffers.length && s >
2697= this.privBuffers[p].chunk.buffer.byteLength; ) 2698 s -= this.privBuffers[p++].chunk.buffer.byteLength; 2699 this.privBufferStartOffset = Math.round(e - s / this.privBytesPerSecond * 1e7), this.privBuffers = this.privBuffers.slice(p); 2700 } 2701 // Finds the time a buffer of audio was first seen by offset. 2702 findTimeAtOffset(e) { 2703 if (e < this.privBufferStartOffset || this.privBuffers === void 0) 2704 return 0; 2705 for (const r of this.privBuffers) { 2706 const s = r.byteOffset / this.privBytesPerSecond * 1e7, p = s + r.chunk.buffer.byteLength / this.privBytesPerSecond * 1e7; 2707 if (e >= s && e <= p) 2708 return r.chunk.timeReceived; 2709 } 2710 return 0; 2711 } 2712} 2713Si.ReplayableAudioNode = Sd; 2714class Cd { 2715 constructor(e, r, s) { 2716 this.chunk = e, this.serial = r, this.byteOffset = s; 2717 } 2718} 2719var nt = {}, mn = {}, he = {}, Nr = {}, yd = k && k.__createBinding || (Object.create ? function(t, e, r, s) { 2720 s === void 0 && (s = r), Object.defineProperty(t, s, { enumerable: !0, get: function() { 2721 return e[r]; 2722 } }); 2723} : function(t, e, r, s) { 2724 s === void 0 && (s = r), t[s] = e[r]; 2725}), Pd = k && k.__setModuleDefault || (Object.create ? function(t, e) { 2726 Object.defineProperty(t, "default", { enumerable: !0, value: e }); 2727} : function(t, e) { 2728 t.default = e; 2729}), Rd = k && k.__importStar || function(t) { 2730 if (t && t.__esModule) return t; 2731 var e = {}; 2732 if (t != null) for (var r in t) r !== "default" && Object.prototype.hasOwnProperty.call(t, r) && yd(e, t, r); 2733 return Pd(e, t), e; 2734}; 2735Object.defineProperty(Nr, "__esModule", { value: !0 }); 2736Nr.AudioFileWriter = void 0; 2737const st = Rd(Ue), Sn = O; 2738class Ed { 2739 constructor(e) { 2740 Sn.Contracts.throwIfNullOrUndefined(st.openSync, ` 2741File System access not available, please use Push or PullAudioOutputStream`), this.privFd = st.openSync(e, "w"); 2742 } 2743 set format(e) { 2744 Sn.Contracts.throwIfNotUndefined(this.privAudioFormat, "format is already set"), this.privAudioFormat = e; 2745 let r = 0; 2746 this.privAudioFormat.hasHeader && (r = this.privAudioFormat.header.byteLength), this.privFd !== void 0 && (this.privWriteStream = st.createWriteStream("", { fd: this.privFd, start: r, autoClose: !1 })); 2747 } 2748 write(e) { 2749 Sn.Contracts.throwIfNullOrUndefined(this.privAudioFormat, "must set format before writing."), this.privWriteStream !== void 0 && this.privWriteStream.write(new Uint8Array(e.slice(0))); 2750 } 2751 close() { 2752 this.privFd !== void 0 && (this.privWriteStream.on("finish", () => { 2753 this.privAudioFormat.hasHeader && (this.privAudioFormat.updateHeader(this.privWriteStream.bytesWritten), st.writeSync(this.privFd, new Int8Array(this.privAudioFormat.header), 0, this.privAudioFormat.header.byteLength, 0)), st.closeSync(this.privFd), this.privFd = void 0; 2754 }), this.privWriteStream.end()); 2755 } 2756 id() { 2757 return this.privId; 2758 } 2759} 2760Nr.AudioFileWriter = Ed; 2761var ie = {}, Ps; 2762function xa() { 2763 if (Ps) return ie; 2764 Ps = 1, Object.defineProperty(ie, "__esModule", { value: !0 }), ie.PullAudioInputStreamImpl = ie.PullAudioInputStream = ie.PushAudioInputStreamImpl = ie.PushAudioInputStream = ie.AudioInputStream = void 0; 2765 const t = A(), e = I(), r = oe, s = R(), p = Ae; 2766 let a = class { 2767 /** 2768 * Creates and initializes an instance. 2769 * @constructor 2770 */ 2771 constructor() { 2772 } 2773 /** 2774 * Creates a memory backed PushAudioInputStream with the specified audio format. 2775 * @member AudioInputStream.createPushStream 2776 * @function 2777 * @public 2778 * @param {AudioStreamFormat} format - The audio data format in which audio will be 2779 * written to the push audio stream's write() method (Required if format is not 16 kHz 16bit mono PCM). 2780 * @returns {PushAudioInputStream} The audio input stream being created. 2781 */ 2782 static createPushStream(h) { 2783 return n.create(h); 2784 } 2785 /** 2786 * Creates a PullAudioInputStream that delegates to the specified callback interface for read() 2787 * and close() methods. 2788 * @member AudioInputStream.createPullStream 2789 * @function 2790 * @public 2791 * @param {PullAudioInputStreamCallback} callback - The custom audio input object, derived from 2792 * PullAudioInputStreamCallback 2793 * @param {AudioStreamFormat} format - The audio data format in which audio will be returned from 2794 * the callback's read() method (Required if format is not 16 kHz 16bit mono PCM). 2795 * @returns {PullAudioInputStream} The audio input stream being created. 2796 */ 2797 static createPullStream(h, d) { 2798 return o.create(h, d); 2799 } 2800 }; 2801 ie.AudioInputStream = a; 2802 class n extends a { 2803 /** 2804 * Creates a memory backed PushAudioInputStream with the specified audio format. 2805 * @member PushAudioInputStream.create 2806 * @function 2807 * @public 2808 * @param {AudioStreamFormat} format - The audio data format in which audio will be written to the 2809 * push audio stream's write() method (Required if format is not 16 kHz 16bit mono PCM). 2810 * @returns {PushAudioInputStream} The push audio input stream being created. 2811 */ 2812 static create(h) { 2813 return new i(h); 2814 } 2815 } 2816 ie.PushAudioInputStream = n; 2817 class i extends n { 2818 /** 2819 * Creates and initalizes an instance with the given values. 2820 * @constructor 2821 * @param {AudioStreamFormat} format - The audio stream format. 2822 */ 2823 constructor(h) { 2824 super(), h === void 0 ? this.privFormat = p.AudioStreamFormatImpl.getDefaultInputFormat() : this.privFormat = h, this.privEvents = new e.EventSource(), this.privId = (0, r.createNoDashGuid)(), this.privStream = new e.ChunkedArrayBufferStream(this.privFormat.avgBytesPerSec / 10); 2825 } 2826 /** 2827 * Format information for the audio 2828 */ 2829 get format() { 2830 return Promise.resolve(this.privFormat); 2831 } 2832 /**
2833 * Writes the audio data specified by making an internal copy of the data. 2834 * @member PushAudioInputStreamImpl.prototype.write 2835 * @function 2836 * @public 2837 * @param {ArrayBuffer} dataBuffer - The audio buffer of which this function will make a copy. 2838 */ 2839 write(h) { 2840 this.privStream.writeStreamChunk({ 2841 buffer: h, 2842 isEnd: !1, 2843 timeReceived: Date.now() 2844 }); 2845 } 2846 /** 2847 * Closes the stream. 2848 * @member PushAudioInputStreamImpl.prototype.close 2849 * @function 2850 * @public 2851 */ 2852 close() { 2853 this.privStream.close(); 2854 } 2855 id() { 2856 return this.privId; 2857 } 2858 turnOn() { 2859 this.onEvent(new e.AudioSourceInitializingEvent(this.privId)), this.onEvent(new e.AudioSourceReadyEvent(this.privId)); 2860 } 2861 async attach(h) { 2862 this.onEvent(new e.AudioStreamNodeAttachingEvent(this.privId, h)), await this.turnOn(); 2863 const d = this.privStream; 2864 return this.onEvent(new e.AudioStreamNodeAttachedEvent(this.privId, h)), { 2865 detach: async () => (this.onEvent(new e.AudioStreamNodeDetachedEvent(this.privId, h)), this.turnOff()), 2866 id: () => h, 2867 read: () => d.read() 2868 }; 2869 } 2870 detach(h) { 2871 this.onEvent(new e.AudioStreamNodeDetachedEvent(this.privId, h)); 2872 } 2873 turnOff() { 2874 } 2875 get events() { 2876 return this.privEvents; 2877 } 2878 get deviceInfo() { 2879 return Promise.resolve({ 2880 bitspersample: this.privFormat.bitsPerSample, 2881 channelcount: this.privFormat.channels, 2882 connectivity: t.connectivity.Unknown, 2883 manufacturer: "Speech SDK", 2884 model: "PushStream", 2885 samplerate: this.privFormat.samplesPerSec, 2886 type: t.type.Stream 2887 }); 2888 } 2889 onEvent(h) { 2890 this.privEvents.onEvent(h), e.Events.instance.onEvent(h); 2891 } 2892 toBuffer(h) { 2893 const d = Buffer.alloc(h.byteLength), v = new Uint8Array(h); 2894 for (let f = 0; f < d.length; ++f) 2895 d[f] = v[f]; 2896 return d; 2897 } 2898 } 2899 ie.PushAudioInputStreamImpl = i; 2900 class o extends a { 2901 /** 2902 * Creates and initializes and instance. 2903 * @constructor 2904 */ 2905 constructor() { 2906 super(); 2907 } 2908 /** 2909 * Creates a PullAudioInputStream that delegates to the specified callback interface for 2910 * read() and close() methods, using the default format (16 kHz 16bit mono PCM). 2911 * @member PullAudioInputStream.create 2912 * @function 2913 * @public 2914 * @param {PullAudioInputStreamCallback} callback - The custom audio input object, 2915 * derived from PullAudioInputStreamCustomCallback 2916 * @param {AudioStreamFormat} format - The audio data format in which audio will be 2917 * returned from the callback's read() method (Required if format is not 16 kHz 16bit mono PCM). 2918 * @returns {PullAudioInputStream} The push audio input stream being created. 2919 */ 2920 static create(h, d) { 2921 return new c(h, d); 2922 } 2923 } 2924 ie.PullAudioInputStream = o; 2925 class c extends o { 2926 /** 2927 * Creates a PullAudioInputStream that delegates to the specified callback interface for 2928 * read() and close() methods, using the default format (16 kHz 16bit mono PCM). 2929 * @constructor 2930 * @param {PullAudioInputStreamCallback} callback - The custom audio input object, 2931 * derived from PullAudioInputStreamCustomCallback 2932 * @param {AudioStreamFormat} format - The audio data format in which audio will be 2933 * returned from the callback's read() method (Required if format is not 16 kHz 16bit mono PCM). 2934 */ 2935 constructor(h, d) { 2936 super(), d === void 0 ? this.privFormat = s.AudioStreamFormat.getDefaultInputFormat() : this.privFormat = d, this.privEvents = new e.EventSource(), this.privId = (0, r.createNoDashGuid)(), this.privCallback = h, this.privIsClosed = !1, this.privBufferSize = this.privFormat.avgBytesPerSec / 10; 2937 } 2938 /** 2939 * Format information for the audio 2940 */ 2941 get format() { 2942 return Promise.resolve(this.privFormat); 2943 } 2944 /** 2945 * Closes the stream. 2946 * @member PullAudioInputStreamImpl.prototype.close 2947 * @function 2948 * @public 2949 */ 2950 close() { 2951 this.privIsClosed = !0, this.privCallback.close(); 2952 } 2953 id() { 2954 return this.privId; 2955 } 2956 turnOn() { 2957 this.onEvent(new e.AudioSourceInitializingEvent(this.privId)
2957), this.onEvent(new e.AudioSourceReadyEvent(this.privId)); 2958 } 2959 async attach(h) { 2960 return this.onEvent(new e.AudioStreamNodeAttachingEvent(this.privId, h)), await this.turnOn(), this.onEvent(new e.AudioStreamNodeAttachedEvent(this.privId, h)), { 2961 detach: () => (this.privCallback.close(), this.onEvent(new e.AudioStreamNodeDetachedEvent(this.privId, h)), this.turnOff()), 2962 id: () => h, 2963 read: () => { 2964 let d = 0, v; 2965 for (; d < this.privBufferSize; ) { 2966 const f = new ArrayBuffer(this.privBufferSize - d), m = this.privCallback.read(f); 2967 if (v === void 0 ? v = f : new Int8Array(v).set(new Int8Array(f), d), m === 0) 2968 break; 2969 d += m; 2970 } 2971 return Promise.resolve({ 2972 buffer: v.slice(0, d), 2973 isEnd: this.privIsClosed || d === 0, 2974 timeReceived: Date.now() 2975 }); 2976 } 2977 }; 2978 } 2979 detach(h) { 2980 this.onEvent(new e.AudioStreamNodeDetachedEvent(this.privId, h)); 2981 } 2982 turnOff() { 2983 } 2984 get events() { 2985 return this.privEvents; 2986 } 2987 get deviceInfo() { 2988 return Promise.resolve({ 2989 bitspersample: this.privFormat.bitsPerSample, 2990 channelcount: this.privFormat.channels, 2991 connectivity: t.connectivity.Unknown, 2992 manufacturer: "Speech SDK", 2993 model: "PullStream", 2994 samplerate: this.privFormat.samplesPerSec, 2995 type: t.type.Stream 2996 }); 2997 } 2998 onEvent(h) { 2999 this.privEvents.onEvent(h), e.Events.instance.onEvent(h); 3000 } 3001 } 3002 return ie.PullAudioInputStreamImpl = c, ie; 3003} 3004var U = {}, Ie = {}, jn = {}; 3005(function(t) { 3006 Object.defineProperty(t, "__esModule", { value: !0 }), t.SpeechSynthesisOutputFormat = void 0, function(e) { 3007 e[e.Raw8Khz8BitMonoMULaw = 0] = "Raw8Khz8BitMonoMULaw", e[e.Riff16Khz16KbpsMonoSiren = 1] = "Riff16Khz16KbpsMonoSiren", e[e.Audio16Khz16KbpsMonoSiren = 2] = "Audio16Khz16KbpsMonoSiren", e[e.Audio16Khz32KBitRateMonoMp3 = 3] = "Audio16Khz32KBitRateMonoMp3", e[e.Audio16Khz128KBitRateMonoMp3 = 4] = "Audio16Khz128KBitRateMonoMp3", e[e.Audio16Khz64KBitRateMonoMp3 = 5] = "Audio16Khz64KBitRateMonoMp3", e[e.Audio24Khz48KBitRateMonoMp3 = 6] = "Audio24Khz48KBitRateMonoMp3", e[e.Audio24Khz96KBitRateMonoMp3 = 7] = "Audio24Khz96KBitRateMonoMp3", e[e.Audio24Khz160KBitRateMonoMp3 = 8] = "Audio24Khz160KBitRateMonoMp3", e[e.Raw16Khz16BitMonoTrueSilk = 9] = "Raw16Khz16BitMonoTrueSilk", e[e.Riff16Khz16BitMonoPcm = 10] = "Riff16Khz16BitMonoPcm", e[e.Riff8Khz16BitMonoPcm = 11] = "Riff8Khz16BitMonoPcm", e[e.Riff24Khz16BitMonoPcm = 12] = "Riff24Khz16BitMonoPcm", e[e.Riff8Khz8BitMonoMULaw = 13] = "Riff8Khz8BitMonoMULaw", e[e.Raw16Khz16BitMonoPcm = 14] = "Raw16Khz16BitMonoPcm", e[e.Raw24Khz16BitMonoPcm = 15] = "Raw24Khz16BitMonoPcm", e[e.Raw8Khz16BitMonoPcm = 16] = "Raw8Khz16BitMonoPcm", e[e.Ogg16Khz16BitMonoOpus = 17] = "Ogg16Khz16BitMonoOpus", e[e.Ogg24Khz16BitMonoOpus = 18] = "Ogg24Khz16BitMonoOpus", e[e.Raw48Khz16BitMonoPcm = 19] = "Raw48Khz16BitMonoPcm", e[e.Riff48Khz16BitMonoPcm = 20] = "Riff48Khz16BitMonoPcm", e[e.Audio48Khz96KBitRateMonoMp3 = 21] = "Audio48Khz96KBitRateMonoMp3", e[e.Audio48Khz192KBitRateMonoMp3 = 22] = "Audio48Khz192KBitRateMonoMp3", e[e.Ogg48Khz16BitMonoOpus = 23] = "Ogg48Khz16BitMonoOpus", e[e.Webm16Khz16BitMonoOpus = 24] = "Webm16Khz16BitMonoOpus", e[e.Webm24Khz16BitMonoOpus = 25] = "Webm24Khz16BitMonoOpus", e[e.Raw24Khz16BitMonoTrueSilk = 26] = "Raw24Khz16BitMonoTrueSilk", e[e.Raw8Khz8BitMonoALaw = 27] = "Raw8Khz8BitMonoALaw", e[e.Riff8Khz8BitMonoALaw = 28] = "Riff8Khz8BitMonoALaw", e[e.Webm24Khz16Bit24KbpsMonoOpus = 29] = "Webm24Khz16Bit24KbpsMonoOpus", e[e.Audio16Khz16Bit32KbpsMonoOpus = 30] = "Audio16Khz16Bit32KbpsMonoOpus", e[e.Audio24Khz16Bit48KbpsMonoOpus = 31] = "Audio24Khz16Bit48KbpsMonoOpus", e[e.Audio24Khz16Bit24KbpsMonoOpus = 32] = "Audio24Khz16Bit24KbpsMonoOpus", e[e.Raw22050Hz16BitMonoPcm = 33] = "Raw22050Hz16BitMonoPcm", e[e.Riff22050Hz16BitMonoPcm = 34] = "Riff22050Hz16BitMonoPcm", e[e.Raw44100Hz16BitMonoPcm = 35] = "Raw44100Hz16BitMonoPcm", e[e.Riff44100Hz16BitMonoPcm = 36] = "Riff44100Hz16BitMonoPcm", e[e.AmrWb16000Hz = 37] = "AmrWb16000Hz", e[e.G72216Khz64Kbps
3007= 38] = "G72216Khz64Kbps"; 3008 }(t.SpeechSynthesisOutputFormat || (t.SpeechSynthesisOutputFormat = {})); 3009})(jn); 3010Object.defineProperty(Ie, "__esModule", { value: !0 }); 3011Ie.AudioOutputFormatImpl = void 0; 3012const D = jn, M = Ae; 3013class w extends M.AudioStreamFormatImpl { 3014 /** 3015 * Creates an instance with the given values. 3016 * @constructor 3017 * @param formatTag 3018 * @param {number} channels - Number of channels. 3019 * @param {number} samplesPerSec - Samples per second. 3020 * @param {number} avgBytesPerSec - Average bytes per second. 3021 * @param {number} blockAlign - Block alignment. 3022 * @param {number} bitsPerSample - Bits per sample. 3023 * @param {string} audioFormatString - Audio format string 3024 * @param {string} requestAudioFormatString - Audio format string sent to service. 3025 * @param {boolean} hasHeader - If the format has header or not. 3026 */ 3027 constructor(e, r, s, p, a, n, i, o, c) { 3028 super(s, n, r, e), this.formatTag = e, this.avgBytesPerSec = p, this.blockAlign = a, this.priAudioFormatString = i, this.priRequestAudioFormatString = o, this.priHasHeader = c; 3029 } 3030 static fromSpeechSynthesisOutputFormat(e) { 3031 return e === void 0 ? w.getDefaultOutputFormat() : w.fromSpeechSynthesisOutputFormatString(w.SpeechSynthesisOutputFormatToString[e]); 3032 } 3033 static fromSpeechSynthesisOutputFormatString(e) { 3034 switch (e) { 3035 case "raw-8khz-8bit-mono-mulaw": 3036 return new w(M.AudioFormatTag.MuLaw, 1, 8e3, 8e3, 1, 8, e, e, !1); 3037 case "riff-16khz-16kbps-mono-siren": 3038 return new w(M.AudioFormatTag.Siren, 1, 16e3, 2e3, 40, 0, e, "audio-16khz-16kbps-mono-siren", !0); 3039 case "audio-16khz-16kbps-mono-siren": 3040 return new w(M.AudioFormatTag.Siren, 1, 16e3, 2e3, 40, 0, e, e, !1); 3041 case "audio-16khz-32kbitrate-mono-mp3": 3042 return new w(M.AudioFormatTag.MP3, 1, 16e3, 4096, 2, 16, e, e, !1); 3043 case "audio-16khz-128kbitrate-mono-mp3": 3044 return new w(M.AudioFormatTag.MP3, 1, 16e3, 16384, 2, 16, e, e, !1); 3045 case "audio-16khz-64kbitrate-mono-mp3": 3046 return new w(M.AudioFormatTag.MP3, 1, 16e3, 8192, 2, 16, e, e, !1); 3047 case "audio-24khz-48kbitrate-mono-mp3": 3048 return new w(M.AudioFormatTag.MP3, 1, 24e3, 6144, 2, 16, e, e, !1); 3049 case "audio-24khz-96kbitrate-mono-mp3": 3050 return new w(M.AudioFormatTag.MP3, 1, 24e3, 12288, 2, 16, e, e, !1); 3051 case "audio-24khz-160kbitrate-mono-mp3": 3052 return new w(M.AudioFormatTag.MP3, 1, 24e3, 20480, 2, 16, e, e, !1); 3053 case "raw-16khz-16bit-mono-truesilk": 3054 return new w(M.AudioFormatTag.SILKSkype, 1, 16e3, 32e3, 2, 16, e, e, !1); 3055 case "riff-8khz-16bit-mono-pcm": 3056 return new w(M.AudioFormatTag.PCM, 1, 8e3, 16e3, 2, 16, e, "raw-8khz-16bit-mono-pcm", !0); 3057 case "riff-24khz-16bit-mono-pcm": 3058 return new w(M.AudioFormatTag.PCM, 1, 24e3, 48e3, 2, 16, e, "raw-24khz-16bit-mono-pcm", !0); 3059 case "riff-8khz-8bit-mono-mulaw": 3060 return new w(M.AudioFormatTag.MuLaw, 1, 8e3, 8e3, 1, 8, e, "raw-8khz-8bit-mono-mulaw", !0); 3061 case "raw-16khz-16bit-mono-pcm": 3062 return new w(M.AudioFormatTag.PCM, 1, 16e3, 32e3, 2, 16, e, "raw-16khz-16bit-mono-pcm", !1); 3063 case "raw-24khz-16bit-mono-pcm": 3064 return new w(M.AudioFormatTag.PCM, 1, 24e3, 48e3, 2, 16, e, "raw-24khz-16bit-mono-pcm", !1); 3065 case "raw-8khz-16bit-mono-pcm": 3066 return new w(M.AudioFormatTag.PCM, 1, 8e3, 16e3, 2, 16, e, "raw-8khz-16bit-mono-pcm", !1); 3067 case "ogg-16khz-16bit-mono-opus": 3068 return new w(M.AudioFormatTag.OGG_OPUS, 1, 16e3, 8192, 2, 16, e, e, !1); 3069 case "ogg-24khz-16bit-mono-opus": 3070 return new w(M.AudioFormatTag.OGG_OPUS, 1, 24e3, 8192, 2, 16, e, e, !1); 3071 case "raw-48khz-16bit-mono-pcm": 3072 return new w(M.AudioFormatTag.PCM, 1, 48e3, 96e3, 2, 16, e, "raw-48khz-16bit-mono-pcm", !1); 3073 case "riff-48khz-16bit-mono-pcm": 3074 return new w(M.AudioFormatTag.PCM, 1, 48e3, 96e3, 2, 16, e, "raw-48khz-16bit-mono-pcm", !0); 3075 case "audio-48khz-96kbitrate-mono-mp3": 3076 return new w(M.AudioFormatTag.MP3, 1, 48e3, 12288, 2, 16, e, e, !1); 3077 case "audio-48khz-192kbitrate-mono-mp3": 3078 return new w(M.AudioFormatTag.MP3, 1, 48e3, 24576, 2, 16, e, e, !1); 3079 case "ogg-48khz-16bit-mono-opus": 3080 return new w(M.AudioFormatTag.OGG_OPUS, 1, 48e3, 12e3, 2, 16, e, e, !1); 3081 case "webm-16khz-16bit-mono-opus": 3082 return new w(M.AudioFormatTag.WEBM_OPUS, 1, 16e3, 4e3, 2, 16, e, e, !1); 3083 case "webm-24khz-16bit-mono-opus": 3084 return new w(M.AudioFormatTag.WEBM_OPUS, 1, 24e3, 6e3, 2, 16, e, e, !1); 3085 case "webm-24khz-16bit-24kbps-mono-opus": 3086 return new w(M.AudioFormatTag.WEBM_OPUS, 1, 24e3, 3e3, 2, 16, e, e, !1); 3087 case "audio-16khz-16bit-32kbps-mono-opus": 3088 return new w(M.AudioFormatTag.OPUS, 1, 16e3, 4e3, 2, 16, e, e, !1); 3089 case "audio-24khz-16bit-48kbps-mono-opus": 3090 return new w(M.AudioFormatTag.OPUS, 1, 24e3, 6e3, 2, 16, e, e, !1); 3091 case "audio-24khz-16bit-24kbps-mono-opus": 3092 return new w(M.AudioFormatTag.OPUS, 1, 24e3, 3e3, 2, 16, e, e, !1); 3093 case "audio-24khz-16bit-mono-flac": 3094 return new w(M.AudioFormatTag.FLAC, 1, 24e3, 24e3, 2, 16, e, e, !1); 3095 case "audio-48khz-16bit-mono-flac": 3096 return new w(M.AudioFormatTag.FLAC, 1, 48e3, 3e4, 2, 16, e, e, !1); 3097 case "raw-24khz-16bit-mono-truesilk": 3098 return new w(M.AudioFormatTag.SILKSkype, 1, 24e3, 48e3, 2, 16, e, e, !1); 3099 case "raw-8khz-8bit-mono-alaw": 3100 return new w(M.AudioFormatTag.ALaw, 1, 8e3, 8e3, 1, 8, e, e, !1); 3101 case "riff-8khz-8bit-mono-alaw": 3102 return new w(M.AudioFormatTag.ALaw, 1, 8e3, 8e3, 1, 8, e, "raw-8khz-8bit-mono-alaw", !0); 3103 case "raw-22050hz-16bit-mono-pcm": 3104 return new w(M.AudioFormatTag.PCM, 1, 22050, 44100, 2, 16, e, e, !1); 3105 case "riff-22050hz-16bit-mono-pcm": 3106 return new w(M.AudioFormatTag.PCM, 1, 22050, 44100, 2, 16, e, "raw-22050hz-16bit-mono-pcm", !0); 3107 case "raw-44100hz-16bit-mono-pcm": 3108 return new w(M.AudioFormatTag.PCM, 1, 44100, 88200, 2, 16, e, e, !1); 3109 case "riff-44100hz-16bit-mono-pcm": 3110 return new w(M.AudioFormatTag.PCM, 1, 44100, 88200, 2, 16, e, "raw-44100hz-16bit-mono-pcm", !0); 3111 case "amr-wb-16000h": 3112 return new w(M.AudioFormatTag.AMR_WB, 1, 16e3, 3052, 2, 16, e, e, !1); 3113 case "g722-16khz-64kbps": 3114 return new w(M.AudioFormatTag.G722, 1, 16e3, 8e3, 2, 16, e, e, !1); 3115 case "riff-16khz-16bit-mono-pcm": 3116 default: 3117 return new w(M.AudioFormatTag.PCM, 1, 16e3, 32e3, 2, 16, "riff-16khz-16bit-mono-pcm", "raw-16khz-16bit-mono-pcm", !0); 3118 } 3119 } 3120 static getDefaultOutputFormat() { 3121 return w.fromSpeechSynthesisOutputFormatString(typeof window < "u" ? "audio-24khz-48kbitrate-mono-mp3" : "riff-16khz-16bit-mono-pcm"); 3122 } 3123 /** 3124 * Specifies if this audio output format has a header 3125 * @boolean AudioOutputFormatImpl.prototype.hasHeader 3126 * @function 3127 * @public 3128 */ 3129 get hasHeader() { 3130 return this.priHasHeader; 3131 } 3132 /** 3133 * Specifies the header of this format 3134 * @ArrayBuffer AudioOutputFormatImpl.prototype.header 3135 * @function 3136 * @public 3137 */ 3138 get header() { 3139 if (this.hasHeader) 3140 return this.privHeader; 3141 } 3142 /** 3143 * Updates the header based on the audio length 3144 * @member AudioOutputFormatImpl.updateHeader 3145 * @function 3146 * @public 3147 * @param {number} audioLength - the audio length 3148 */ 3149 updateHeader(e) { 3150 if (this.priHasHeader) { 3151 const r = new DataView(this.privHeader); 3152 r.setUint32(4, e + this.privHeader.byteLength - 8, !0), r.setUint32(40, e, !0); 3153 } 3154 } 3155 /**
3156 * Specifies the audio format string to be sent to the service 3157 * @string AudioOutputFormatImpl.prototype.requestAudioFormatString 3158 * @function 3159 * @public 3160 */ 3161 get requestAudioFormatString() { 3162 return this.priRequestAudioFormatString; 3163 } 3164 /** 3165 * Adds audio header 3166 * @param audio the raw audio without header 3167 * @returns the audio with header if applicable 3168 */ 3169 addHeader(e) { 3170 if (!this.hasHeader) 3171 return e; 3172 this.updateHeader(e.byteLength); 3173 const r = new Uint8Array(e.byteLength + this.header.byteLength); 3174 return r.set(new Uint8Array(this.header), 0), r.set(new Uint8Array(e), this.header.byteLength), r.buffer; 3175 } 3176} 3177Ie.AudioOutputFormatImpl = w; 3178w.SpeechSynthesisOutputFormatToString = { 3179 [D.SpeechSynthesisOutputFormat.Raw8Khz8BitMonoMULaw]: "raw-8khz-8bit-mono-mulaw", 3180 [D.SpeechSynthesisOutputFormat.Riff16Khz16KbpsMonoSiren]: "riff-16khz-16kbps-mono-siren", 3181 [D.SpeechSynthesisOutputFormat.Audio16Khz16KbpsMonoSiren]: "audio-16khz-16kbps-mono-siren", 3182 [D.SpeechSynthesisOutputFormat.Audio16Khz32KBitRateMonoMp3]: "audio-16khz-32kbitrate-mono-mp3", 3183 [D.SpeechSynthesisOutputFormat.Audio16Khz128KBitRateMonoMp3]: "audio-16khz-128kbitrate-mono-mp3", 3184 [D.SpeechSynthesisOutputFormat.Audio16Khz64KBitRateMonoMp3]: "audio-16khz-64kbitrate-mono-mp3", 3185 [D.SpeechSynthesisOutputFormat.Audio24Khz48KBitRateMonoMp3]: "audio-24khz-48kbitrate-mono-mp3", 3186 [D.SpeechSynthesisOutputFormat.Audio24Khz96KBitRateMonoMp3]: "audio-24khz-96kbitrate-mono-mp3", 3187 [D.SpeechSynthesisOutputFormat.Audio24Khz160KBitRateMonoMp3]: "audio-24khz-160kbitrate-mono-mp3", 3188 [D.SpeechSynthesisOutputFormat.Raw16Khz16BitMonoTrueSilk]: "raw-16khz-16bit-mono-truesilk", 3189 [D.SpeechSynthesisOutputFormat.Riff16Khz16BitMonoPcm]: "riff-16khz-16bit-mono-pcm", 3190 [D.SpeechSynthesisOutputFormat.Riff8Khz16BitMonoPcm]: "riff-8khz-16bit-mono-pcm", 3191 [D.SpeechSynthesisOutputFormat.Riff24Khz16BitMonoPcm]: "riff-24khz-16bit-mono-pcm", 3192 [D.SpeechSynthesisOutputFormat.Riff8Khz8BitMonoMULaw]: "riff-8khz-8bit-mono-mulaw", 3193 [D.SpeechSynthesisOutputFormat.Raw16Khz16BitMonoPcm]: "raw-16khz-16bit-mono-pcm", 3194 [D.SpeechSynthesisOutputFormat.Raw24Khz16BitMonoPcm]: "raw-24khz-16bit-mono-pcm", 3195 [D.SpeechSynthesisOutputFormat.Raw8Khz16BitMonoPcm]: "raw-8khz-16bit-mono-pcm", 3196 [D.SpeechSynthesisOutputFormat.Ogg16Khz16BitMonoOpus]: "ogg-16khz-16bit-mono-opus", 3197 [D.SpeechSynthesisOutputFormat.Ogg24Khz16BitMonoOpus]: "ogg-24khz-16bit-mono-opus", 3198 [D.SpeechSynthesisOutputFormat.Raw48Khz16BitMonoPcm]: "raw-48khz-16bit-mono-pcm", 3199 [D.SpeechSynthesisOutputFormat.Riff48Khz16BitMonoPcm]: "riff-48khz-16bit-mono-pcm", 3200 [D.SpeechSynthesisOutputFormat.Audio48Khz96KBitRateMonoMp3]: "audio-48khz-96kbitrate-mono-mp3", 3201 [D.SpeechSynthesisOutputFormat.Audio48Khz192KBitRateMonoMp3]: "audio-48khz-192kbitrate-mono-mp3", 3202 [D.SpeechSynthesisOutputFormat.Ogg48Khz16BitMonoOpus]: "ogg-48khz-16bit-mono-opus", 3203 [D.SpeechSynthesisOutputFormat.Webm16Khz16BitMonoOpus]: "webm-16khz-16bit-mono-opus", 3204 [D.SpeechSynthesisOutputFormat.Webm24Khz16BitMonoOpus]: "webm-24khz-16bit-mono-opus", 3205 [D.SpeechSynthesisOutputFormat.Webm24Khz16Bit24KbpsMonoOpus]: "webm-24khz-16bit-24kbps-mono-opus", 3206 [D.SpeechSynthesisOutputFormat.Raw24Khz16BitMonoTrueSilk]: "raw-24khz-16bit-mono-truesilk", 3207 [D.SpeechSynthesisOutputFormat.Raw8Khz8BitMonoALaw]: "raw-8khz-8bit-mono-alaw", 3208 [D.SpeechSynthesisOutputFormat.Riff8Khz8BitMonoALaw]: "riff-8khz-8bit-mono-alaw", 3209 [D.SpeechSynthesisOutputFormat.Audio16Khz16Bit32KbpsMonoOpus]: "audio-16khz-16bit-32kbps-mono-opus", 3210 [D.SpeechSynthesisOutputFormat.Audio24Khz16Bit48KbpsMonoOpus]: "audio-24khz-16bit-48kbps-mono-opus", 3211 [D.SpeechSynthesisOutputFormat.Audio24Khz16Bit24KbpsMonoOpus]: "audio-24khz-16bit-24kbps-mono-opus", 3212 [D.SpeechSynthesisOutputFormat.Raw22050Hz16BitMonoPcm]: "raw-22050hz-16bit-mono-pcm", 3213 [D.SpeechSynthesisOutputFormat.Riff22050Hz16BitMonoPcm]: "riff-22050hz-16bit-mono-pcm", 3214 [D.SpeechSynthesisOutputFormat.Raw44100Hz16BitMonoPcm]: "raw-44100hz-16bit-mono-pcm", 3215 [D.SpeechSynthesisOutputFormat.Riff44100Hz16BitMonoPcm]: "riff-44100hz-16bit-mono-pcm", 3216 [D.SpeechSynthesisOutputFormat.AmrWb16000Hz]: "amr-wb-16000hz", 3217 [D.SpeechSynthesisOutputFormat.G72216Khz64Kbps]: "g722-16khz-64kbps" 3218}; 3219Object.defineProperty(U, "__esModule", { value: !0 }); 3220U.PushAudioOutputStreamImpl = U.PushAudioOutputStream = U.PullAudioOutputStreamImpl = U.PullAudioOutputStream = U.AudioOutputStream = void 0; 3221const wn = I(), Td = O, Ad = Ie; 3222class Ln { 3223 /** 3224 * Creates and initializes an instance. 3225 * @constructor 3226 */ 3227 constructor() { 3228 } 3229 /** 3230 * Creates a memory backed PullAudioOutputStream with the specified audio format. 3231 * @member AudioOutputStream.createPullStream 3232 * @function 3233 * @public 3234 * @returns {PullAudioOutputStream} The audio output stream being created. 3235 */ 3236 static createPullStream() { 3237 return Bn.create(); 3238 } 3239} 3240U.AudioOutputStream = Ln; 3241class Bn extends Ln { 3242 /** 3243 * Creates a memory backed PullAudioOutputStream with the specified audio format. 3244 * @member PullAudioOutputStream.create 3245 * @function 3246 * @public 3247 * @returns {PullAudioOutputStream} The push audio output stream being created. 3248 */ 3249 static create() { 3250 return new Wa(); 3251 } 3252} 3253U.PullAudioOutputStream = Bn; 3254class Wa extends Bn { 3255 /** 3256 * Creates and initializes an instance with the given values. 3257 * @constructor 3258 */ 3259 constructor() { 3260 super(), this.privId = (0, wn.createNoDashGuid)(), this.privStream = new wn.Stream(); 3261 } 3262 /** 3263 * Sets the format information to the stream. For internal use only. 3264 * @param {AudioStreamFormat} format - the format to be set. 3265 */ 3266 set format(e) { 3267 e == null && (this.privFormat = Ad.AudioOutputFormatImpl.getDefaultOutputFormat()), this.privFormat = e; 3268 } 3269 /** 3270 * Format information for the audio 3271 */ 3272 get format() { 3273 return this.privFormat; 3274 } 3275 /** 3276 * Checks if the stream is closed 3277 * @member PullAudioOutputStreamImpl.prototype.isClosed 3278 * @property 3279 * @public 3280 */ 3281 get isClosed() { 3282 return this.privStream.isClosed; 3283 } 3284 /** 3285 * Gets the id of the stream 3286 * @member PullAudioOutputStreamImpl.prototype.id 3287 * @property 3288 * @public 3289 */ 3290 id() { 3291 return this.privId; 3292 } 3293 /** 3294 * Reads audio data from the internal buffer. 3295 * @member PullAudioOutputStreamImpl.prototype.read 3296 * @function 3297 * @public 3298 * @param {ArrayBuffer} dataBuffer - An ArrayBuffer to store the read data. 3299 * @returns {Promise<number>} - Audio buffer length has been read. 3300 */ 3301 async read(e) { 3302 const r = new Int8Array(e); 3303 let s = 0; 3304 if (this.privLastChunkView !== void 0) { 3305 if (this.privLastChunkView.length > e.byteLength) 3306 return r.set(this.privLastChunkView.slice(0, e.byteLength)), this.privLastChunkView = this.privLastChunkView.slice(e.byteLength), Promise.resolve(e.byteLength); 3307 r.set(this.privLastChunkView), s = this.privLastChunkView.length, this.privLastChunkView = void 0; 3308 } 3309 for (; s < e.byteLength && !this.privStream.isReadEnded; ) { 3310 const p = await this.privStream.read(); 3311 if (p !== void 0 && !p.isEnd) { 3312 let a; 3313 p.buffer.byteLength > e.byteLength - s ? (a = p.buffer.slice(0, e.byteLength - s), this.privLastChunkView = new Int8Array(p.buffer.slice(e.byteLength - s))) : a = p.buffer, r.set(new Int8Array(a), s), s += a.byteLength; 3314 } else 3315 this.privStream.readEnded(); 3316 } 3317 return s; 3318 } 3319 /**
3320 * Writes the audio data specified by making an internal copy of the data. 3321 * @member PullAudioOutputStreamImpl.prototype.write 3322 * @function 3323 * @public 3324 * @param {ArrayBuffer} dataBuffer - The audio buffer of which this function will make a copy. 3325 */ 3326 write(e) { 3327 Td.Contracts.throwIfNullOrUndefined(this.privStream, "must set format before writing"), this.privStream.writeStreamChunk({ 3328 buffer: e, 3329 isEnd: !1, 3330 timeReceived: Date.now() 3331 }); 3332 } 3333 /** 3334 * Closes the stream. 3335 * @member PullAudioOutputStreamImpl.prototype.close 3336 * @function 3337 * @public 3338 */ 3339 close() { 3340 this.privStream.close(); 3341 } 3342} 3343U.PullAudioOutputStreamImpl = Wa; 3344class Ha extends Ln { 3345 /** 3346 * Creates and initializes and instance. 3347 * @constructor 3348 */ 3349 constructor() { 3350 super(); 3351 } 3352 /** 3353 * Creates a PushAudioOutputStream that delegates to the specified callback interface for 3354 * write() and close() methods. 3355 * @member PushAudioOutputStream.create 3356 * @function 3357 * @public 3358 * @param {PushAudioOutputStreamCallback} callback - The custom audio output object, 3359 * derived from PushAudioOutputStreamCallback 3360 * @returns {PushAudioOutputStream} The push audio output stream being created. 3361 */ 3362 static create(e) { 3363 return new Ka(e); 3364 } 3365} 3366U.PushAudioOutputStream = Ha; 3367class Ka extends Ha { 3368 /** 3369 * Creates a PushAudioOutputStream that delegates to the specified callback interface for 3370 * read() and close() methods. 3371 * @constructor 3372 * @param {PushAudioOutputStreamCallback} callback - The custom audio output object, 3373 * derived from PushAudioOutputStreamCallback 3374 */ 3375 constructor(e) { 3376 super(), this.privId = (0, wn.createNoDashGuid)(), this.privCallback = e; 3377 } 3378 // eslint-disable-next-line @typescript-eslint/no-empty-function 3379 set format(e) { 3380 } 3381 write(e) { 3382 this.privCallback.write && this.privCallback.write(e); 3383 } 3384 close() { 3385 this.privCallback.close && this.privCallback.close(); 3386 } 3387 id() { 3388 return this.privId; 3389 } 3390} 3391U.PushAudioOutputStreamImpl = Ka; 3392var Rs; 3393function Id() { 3394 if (Rs) return he; 3395 Rs = 1, Object.defineProperty(he, "__esModule", { value: !0 }), he.AudioOutputConfigImpl = he.AudioConfigImpl = he.AudioConfig = void 0; 3396 const t = re(), e = O, r = R(), s = Nr, p = xa(), a = U; 3397 let n = class Ja { 3398 /** 3399 * Creates an AudioConfig object representing the default microphone on the system. 3400 * @member AudioConfig.fromDefaultMicrophoneInput 3401 * @function 3402 * @public 3403 * @returns {AudioConfig} The audio input configuration being created. 3404 */ 3405 static fromDefaultMicrophoneInput() { 3406 const u = new t.PcmRecorder(!0); 3407 return new i(new t.MicAudioSource(u)); 3408 } 3409 /** 3410 * Creates an AudioConfig object representing a microphone with the specified device ID. 3411 * @member AudioConfig.fromMicrophoneInput 3412 * @function 3413 * @public 3414 * @param {string | undefined} deviceId - Specifies the device ID of the microphone to be used. 3415 * Default microphone is used the value is omitted. 3416 * @returns {AudioConfig} The audio input configuration being created. 3417 */ 3418 static fromMicrophoneInput(u) { 3419 const h = new t.PcmRecorder(!0); 3420 return new i(new t.MicAudioSource(h, u)); 3421 } 3422 /** 3423 * Creates an AudioConfig object representing the specified file. 3424 * @member AudioConfig.fromWavFileInput 3425 * @function 3426 * @public 3427 * @param {File} fileName - Specifies the audio input file. Currently, only WAV / PCM is supported. 3428 * @returns {AudioConfig} The audio input configuration being created. 3429 */ 3430 static fromWavFileInput(u, h = "unnamedBuffer.wav") { 3431 return new i(new t.FileAudioSource(u, h)); 3432 } 3433 /** 3434 * Creates an AudioConfig object representing the specified stream. 3435 * @member AudioConfig.fromStreamInput 3436 * @function 3437 * @public 3438 * @param {AudioInputStream | PullAudioInputStreamCallback | MediaStream} audioStream - Specifies the custom audio input 3439 * stream. Currently, only WAV / PCM is supported. 3440 * @returns {AudioConfig} The audio input configuration being created. 3441 */ 3442 static fromStreamInput(u) { 3443 if (u instanceof r.PullAudioInputStreamCallback) 3444 return new i(new p.PullAudioInputStreamImpl(u)); 3445 if (u instanceof r.AudioInputStream) 3446 return new i(u); 3447 if (typeof MediaStream < "u" && u instanceof MediaStream) { 3448 const h = new t.PcmRecorder(!1); 3449 return new i(new t.MicAudioSource(h, null, null, u)); 3450 } 3451 throw new Error("Not Supported Type"); 3452 } 3453 /** 3454 * Creates an AudioConfig object representing the default speaker. 3455 * @member AudioConfig.fromDefaultSpeakerOutput 3456 * @function 3457 * @public 3458 * @returns {AudioConfig} The audio output configuration being created.
3459 * Added in version 1.11.0 3460 */ 3461 static fromDefaultSpeakerOutput() { 3462 return new o(new r.SpeakerAudioDestination()); 3463 } 3464 /** 3465 * Creates an AudioConfig object representing the custom IPlayer object. 3466 * You can use the IPlayer object to control pause, resume, etc. 3467 * @member AudioConfig.fromSpeakerOutput 3468 * @function 3469 * @public 3470 * @param {IPlayer} player - the IPlayer object for playback. 3471 * @returns {AudioConfig} The audio output configuration being created. 3472 * Added in version 1.12.0 3473 */ 3474 static fromSpeakerOutput(u) { 3475 if (u === void 0) 3476 return Ja.fromDefaultSpeakerOutput(); 3477 if (u instanceof r.SpeakerAudioDestination) 3478 return new o(u); 3479 throw new Error("Not Supported Type"); 3480 } 3481 /** 3482 * Creates an AudioConfig object representing a specified output audio file 3483 * @member AudioConfig.fromAudioFileOutput 3484 * @function 3485 * @public 3486 * @param {PathLike} filename - the filename of the output audio file 3487 * @returns {AudioConfig} The audio output configuration being created. 3488 * Added in version 1.11.0 3489 */ 3490 static fromAudioFileOutput(u) { 3491 return new o(new s.AudioFileWriter(u)); 3492 } 3493 /** 3494 * Creates an AudioConfig object representing a specified audio output stream 3495 * @member AudioConfig.fromStreamOutput 3496 * @function 3497 * @public 3498 * @param {AudioOutputStream | PushAudioOutputStreamCallback} audioStream - Specifies the custom audio output 3499 * stream. 3500 * @returns {AudioConfig} The audio output configuration being created. 3501 * Added in version 1.11.0 3502 */ 3503 static fromStreamOutput(u) { 3504 if (u instanceof r.PushAudioOutputStreamCallback) 3505 return new o(new a.PushAudioOutputStreamImpl(u)); 3506 if (u instanceof r.PushAudioOutputStream) 3507 return new o(u); 3508 if (u instanceof r.PullAudioOutputStream) 3509 return new o(u); 3510 throw new Error("Not Supported Type"); 3511 } 3512 }; 3513 he.AudioConfig = n; 3514 class i extends n { 3515 /** 3516 * Creates and initializes an instance of this class. 3517 * @constructor 3518 * @param {IAudioSource} source - An audio source. 3519 */ 3520 constructor(u) { 3521 super(), this.privSource = u; 3522 } 3523 /** 3524 * Format information for the audio 3525 */ 3526 get format() { 3527 return this.privSource.format; 3528 } 3529 /** 3530 * @member AudioConfigImpl.prototype.close 3531 * @function 3532 * @public 3533 */ 3534 close(u, h) { 3535 this.privSource.turnOff().then(() => { 3536 u && u(); 3537 }, (d) => { 3538 h && h(d); 3539 }); 3540 } 3541 /** 3542 * @member AudioConfigImpl.prototype.id 3543 * @function 3544 * @public 3545 */ 3546 id() { 3547 return this.privSource.id(); 3548 } 3549 /** 3550 * @member AudioConfigImpl.prototype.turnOn 3551 * @function 3552 * @public 3553 * @returns {Promise<void>} A promise. 3554 */ 3555 turnOn() { 3556 return this.privSource.turnOn(); 3557 } 3558 /** 3559 * @member AudioConfigImpl.prototype.attach 3560 * @function 3561 * @public 3562 * @param {string} audioNodeId - The audio node id. 3563 * @returns {Promise<IAudioStreamNode>} A promise. 3564 */ 3565 attach(u) { 3566 return this.privSource.attach(u); 3567 } 3568 /** 3569 * @member AudioConfigImpl.prototype.detach 3570 * @function 3571 * @public 3572 * @param {string} audioNodeId - The audio node id. 3573 */ 3574 detach(u) { 3575 return this.privSource.detach(u); 3576 } 3577 /** 3578 * @member AudioConfigImpl.prototype.turnOff 3579 * @function 3580 * @public 3581 * @returns {Promise<void>} A promise. 3582 */ 3583 turnOff() { 3584 return this.privSource.turnOff(); 3585 } 3586 /** 3587 * @member AudioConfigImpl.prototype.events 3588 * @function 3589 * @public 3590 * @returns {EventSource<AudioSourceEvent>} An event source for audio events. 3591 */ 3592 get events() { 3593 return this.privSource.events; 3594 } 3595 setProperty(u, h) { 3596 if (e.Contracts.throwIfNull(h, "value"), this.privSource.setProperty !== void 0) 3597 this.privSource.setProperty(u, h); 3598 else 3599 throw new Error("This AudioConfig instance does not support setting properties."); 3600 } 3601 getProperty(u, h) { 3602 if (this.privSource.getProperty !== void 0) 3603 return this.privSource.getProperty(u, h); 3604 throw new Error("This AudioConfig instance does not support getting properties."); 3605 } 3606 get deviceInfo() { 3607 return this.privSource.deviceInfo; 3608 } 3609 } 3610 he.AudioConfigImpl = i; 3611 class o extends n { 3612 /** 3613 * Creates and initializes an instance of this class. 3614 * @constructor 3615 * @param {IAudioDestination} destination - An audio destination. 3616 */ 3617 constructor(u) { 3618 super(), this.privDestination = u; 3619 } 3620 set format(u) { 3621 this.privDestination.format = u; 3622 } 3623 write(u) { 3624 this.privDestination.write(u); 3625 } 3626 close() { 3627 this.privDestination.close(); 3628 } 3629 id() { 3630 return this.privDestination.id(); 3631 } 3632 setProperty() { 3633 throw new Error("This AudioConfig instance does not support setting properties."); 3634 } 3635 getProperty() { 3636 throw new Error("This AudioConfig instance does not support getting properties."); 3637 } 3638 } 3639 return he.AudioOutputConfigImpl = o, he; 3640} 3641var Va = {}; 3642(function(t) { 3643 Object.defineProperty(t, "__esModule", { value: !0 }), t.CancellationReason = void 0, function(e) { 3644 e[e.Error = 0] = "Error", e[e.EndOfStream = 1] = "EndOfStream"; 3645 }(t.CancellationReason || (t.CancellationReason = {})); 3646})(Va); 3647var Ci = {}; 3648Object.defineProperty(Ci, "__esModule", { value: !0 }); 3649Ci.PullAudioInputStreamCallback = void 0; 3650class wd { 3651} 3652Ci.PullAudioInputStreamCallback = wd; 3653var yi = {}; 3654Object.defineProperty(yi, "__esModule", { value: !0 }); 3655yi.PushAudioOutputStreamCallback = void 0; 3656class _d { 3657} 3658yi.PushAudioOutputStreamCallback = _d; 3659var Pi = {}; 3660Object.defineProperty(Pi, "__esModule", { value: !0 }); 3661Pi.KeywordRecognitionModel = void 0; 3662const Es = O; 3663class bd { 3664 /** 3665 * Create and initializes a new instance. 3666 * @constructor 3667 */ 3668 constructor() { 3669 this.privDisposed = !1; 3670 } 3671 /** 3672 * Creates a keyword recognition model using the specified filename. 3673 * @member KeywordRecognitionModel.fromFile 3674 * @function 3675 * @public 3676 * @param {string} fileName - A string that represents file name for the keyword recognition model.
3677 * Note, the file can point to a zip file in which case the model 3678 * will be extracted from the zip. 3679 * @returns {KeywordRecognitionModel} The keyword recognition model being created. 3680 */ 3681 static fromFile(e) { 3682 throw Es.Contracts.throwIfFileDoesNotExist(e, "fileName"), new Error("Not yet implemented."); 3683 } 3684 /** 3685 * Creates a keyword recognition model using the specified filename. 3686 * @member KeywordRecognitionModel.fromStream 3687 * @function 3688 * @public 3689 * @param {string} file - A File that represents file for the keyword recognition model. 3690 * Note, the file can point to a zip file in which case the model will be extracted from the zip. 3691 * @returns {KeywordRecognitionModel} The keyword recognition model being created. 3692 */ 3693 static fromStream(e) { 3694 throw Es.Contracts.throwIfNull(e, "file"), new Error("Not yet implemented."); 3695 } 3696 /** 3697 * Dispose of associated resources. 3698 * @member KeywordRecognitionModel.prototype.close 3699 * @function 3700 * @public 3701 */ 3702 close() { 3703 this.privDisposed || (this.privDisposed = !0); 3704 } 3705} 3706Pi.KeywordRecognitionModel = bd; 3707var Ri = {}; 3708Object.defineProperty(Ri, "__esModule", { value: !0 }); 3709Ri.SessionEventArgs = void 0; 3710class Md { 3711 /** 3712 * Creates and initializes an instance of this class. 3713 * @constructor 3714 * @param {string} sessionId - The session id. 3715 */ 3716 constructor(e) { 3717 this.privSessionId = e; 3718 } 3719 /** 3720 * Represents the session identifier. 3721 * @member SessionEventArgs.prototype.sessionId 3722 * @function 3723 * @public 3724 * @returns {string} Represents the session identifier. 3725 */ 3726 get sessionId() { 3727 return this.privSessionId; 3728 } 3729} 3730Ri.SessionEventArgs = Md; 3731var ot = {}, Ts; 3732function Od() { 3733 if (Ts) return ot; 3734 Ts = 1, Object.defineProperty(ot, "__esModule", { value: !0 }), ot.RecognitionEventArgs = void 0; 3735 const t = R(); 3736 let e = class extends t.SessionEventArgs { 3737 /** 3738 * Creates and initializes an instance of this class. 3739 * @constructor 3740 * @param {number} offset - The offset. 3741 * @param {string} sessionId - The session id. 3742 */ 3743 constructor(s, p) { 3744 super(p), this.privOffset = s; 3745 } 3746 /** 3747 * Represents the message offset 3748 * @member RecognitionEventArgs.prototype.offset 3749 * @function 3750 * @public 3751 */ 3752 get offset() { 3753 return this.privOffset; 3754 } 3755 }; 3756 return ot.RecognitionEventArgs = e, ot; 3757} 3758var Ga = {}; 3759(function(t) { 3760 Object.defineProperty(t, "__esModule", { value: !0 }), t.OutputFormat = void 0, function(e) { 3761 e[e.Simple = 0] = "Simple", e[e.Detailed = 1] = "Detailed"; 3762 }(t.OutputFormat || (t.OutputFormat = {})); 3763})(Ga); 3764var Ei = {}; 3765Object.defineProperty(Ei, "__esModule", { value: !0 }); 3766Ei.RecognitionResult = void 0; 3767class Dd { 3768 /** 3769 * Creates and initializes an instance of this class. 3770 * @constructor 3771 * @param {string} resultId - The result id. 3772 * @param {ResultReason} reason - The reason. 3773 * @param {string} text - The recognized text. 3774 * @param {number} duration - The duration. 3775 * @param {number} offset - The offset into the stream. 3776 * @param {string} language - Primary Language detected, if provided. 3777 * @param {string} languageDetectionConfidence - Primary Language confidence ("Unknown," "Low," "Medium," "High"...), if provided. 3778 * @param {string} errorDetails - Error details, if provided. 3779 * @param {string} json - Additional Json, if provided. 3780 * @param {PropertyCollection} properties - Additional properties, if provided. 3781 */ 3782 constructor(e, r, s, p, a, n, i, o, c, u) { 3783 this.privResultId = e, this.privReason = r, this.privText = s, this.privDuration = p, this.privOffset = a, this.privLanguage = n, this.privLanguageDetectionConfidence = i, this.privErrorDetails = o, this.privJson = c, this.privProperties = u; 3784 } 3785 /** 3786 * Specifies the result identifier. 3787 * @member RecognitionResult.prototype.resultId 3788 * @function 3789 * @public 3790 * @returns {string} Specifies the result identifier. 3791 */ 3792 get resultId() { 3793 return this.privResultId; 3794 } 3795 /** 3796 * Specifies status of the result. 3797 * @member RecognitionResult.prototype.reason 3798 * @function 3799 * @public 3800 * @returns {ResultReason} Specifies status of the result. 3801 */ 3802 get reason() { 3803 return this.privReason; 3804 } 3805 /** 3806 * Presents the recognized text in the result. 3807 * @member RecognitionResult.prototype.text 3808 * @function 3809 * @public 3810 * @returns {string} Presents the recognized text in the result. 3811 */ 3812 get text() { 3813 return this.privText; 3814 } 3815 /** 3816 * Duration of recognized speech in 100 nano second increments. 3817 * @member RecognitionResult.prototype.duration 3818 * @function 3819 * @public 3820 * @returns {number} Duration of recognized speech in 100 nano second increments. 3821 */ 3822 get duration() { 3823 return this.privDuration; 3824 } 3825 /** 3826 * Offset of recognized speech in 100 nano second increments. 3827 * @member RecognitionResult.prototype.offset 3828 * @function 3829 * @public 3830 * @returns {number} Offset of recognized speech in 100 nano second increments. 3831 */ 3832 get offset() { 3833 return this.privOffset; 3834 } 3835 /** 3836 * Primary Language detected. 3837 * @member RecognitionResult.prototype.language 3838 * @function 3839 * @public 3840 * @returns {string} language detected. 3841 */ 3842 get language() { 3843 return this.privLanguage; 3844 } 3845 /** 3846 * Primary Language detection confidence (Unknown, Low, Medium, High). 3847 * @member RecognitionResult.prototype.languageDetectionConfidence 3848 * @function 3849 * @public 3850 * @returns {string} detection confidence strength. 3851 */ 3852 get languageDetectionConfidence() { 3853 return this.privLanguageDetectionConfidence; 3854 } 3855 /** 3856 * In case of an unsuccessful recognition, provides details of the occurred error. 3857 * @member RecognitionResult.prototype.errorDetails 3858 * @function 3859 * @public 3860 * @returns {string} a brief description of an error. 3861 */ 3862 get errorDetails() { 3863 return this.privErrorDetails; 3864 } 3865 /** 3866 * A string containing Json serialized recognition result as it was received from the service. 3867 * @member RecognitionResult.prototype.json 3868 * @function 3869 * @private 3870 * @returns {string} Json serialized representation of the result. 3871 */ 3872 get json() { 3873 return this.privJson; 3874 } 3875 /** 3876 * The set of properties exposed in the result. 3877 * @member RecognitionResult.prototype.properties 3878 * @function 3879 * @public 3880 * @returns {PropertyCollection} The set of properties exposed in the result. 3881 */ 3882 get properties() { 3883 return this.privProperties; 3884 } 3885} 3886Ei.RecognitionResult = Dd; 3887var at = {}, As; 3888function kd() { 3889 if (As) return at; 3890 As = 1, Object.defineProperty(at, "__esModule", { value: !0 }), at.SpeechRecognitionResult = void 0; 3891 const t = R(); 3892 let e = class extends t.RecognitionResult { 3893 /** 3894 * Creates and initializes an instance of this class. 3895 * @constructor 3896 * @public 3897 * @param {string} resultId - The result id. 3898 * @param {ResultReason} reason - The reason. 3899 * @param {string} text - The recognized text. 3900 * @param {number} duration - The duration. 3901 * @param {number} offset - The offset into the stream. 3902 * @param {string} language - Primary Language detected, if provided. 3903 * @param {string} languageDetectionConfidence - Primary Language confidence ("Unknown," "Low," "Medium," "High"...), if provided. 3904 * @param {string} speakerId - speaker id for conversation transcription, if provided. 3905 * @param {string} errorDetails - Error details, if provided. 3906 * @param {string} json - Additional Json, if provided. 3907 * @param {PropertyCollection} properties - Additional properties, if provided. 3908 */ 3909 constructor(s, p, a, n, i, o, c, u, h, d, v) { 3910 super(s, p, a, n, i, o, c, h, d, v), this.privSpeakerId = u; 3911 } 3912 /** 3913 * speaker id from conversation transcription/id scenarios 3914 * @member SpeechRecognitionResult.prototype.speakerId 3915 * @function 3916 * @public 3917 * @returns {string} id of speaker in given result 3918 */ 3919 get speakerId() { 3920 return this.privSpeakerId; 3921 } 3922 }; 3923 return at.SpeechRecognitionResult = e, at; 3924} 3925var de = {}, Is; 3926function Nd() { 3927 if (Is) return de; 3928 Is = 1, Object.defineProperty(de, "__esModule", { value: !0 }), de.MeetingTranscriptionEventArgs = de.ConversationTranscriptionEventArgs = de.SpeechRecognitionEventArgs = void 0; 3929 const t = R(); 3930 let e = class extends t.RecognitionEventArgs { 3931 /** 3932 * Creates and initializes an instance of this class. 3933 * @constructor 3934 * @param {SpeechRecognitionResult} result - The speech recognition result. 3935 * @param {number} offset - The offset. 3936 * @param {string} sessionId - The session id. 3937 */ 3938 constructor(a, n, i) { 3939 super(n, i), this.privResult = a; 3940 } 3941 /** 3942 * Specifies the recognition result. 3943 * @member SpeechRecognitionEventArgs.prototype.result 3944 * @function 3945 * @public 3946 * @returns {SpeechRecognitionResult} the recognition result. 3947 */ 3948 get result() { 3949 return this.privResult; 3950 } 3951 }; 3952 de.SpeechRecognitionEventArgs = e; 3953 class r extends t.RecognitionEventArgs { 3954 /** 3955 * Creates and initializes an instance of this class. 3956 * @constructor 3957 * @param {ConversationTranscriptionResult} result - The conversation transcription result. 3958 * @param {number} offset - The offset. 3959 * @param {string} sessionId - The session id. 3960 */ 3961 constructor(a, n, i) { 3962 super(n, i), this.privResult = a; 3963 } 3964 /** 3965 * Specifies the transcription result. 3966 * @member ConversationTranscription1EventArgs.prototype.result 3967 * @function 3968 * @public 3969 * @returns {ConversationTranscriptionResult} the recognition result. 3970 */ 3971 get result() { 3972 return this.privResult; 3973 } 3974 } 3975 de.ConversationTranscriptionEventArgs = r; 3976 class s extends e { 3977 } 3978 return de.MeetingTranscriptionEventArgs = s, de; 3979} 3980var ct = {}, pt = {}, ws; 3981function zr() { 3982 if (ws) return pt; 3983 ws = 1, Object.defineProperty(pt, "__esModule", { value: !0 }), pt.CancellationEventArgsBase = void 0; 3984 const t = R(); 3985 let e = class extends t.RecognitionEventArgs { 3986 /** 3987 * Creates and initializes an instance of this class. 3988 * @constructor 3989 * @param {CancellationReason} reason - The cancellation reason. 3990 * @param {string} errorDetails - Error details, if provided. 3991 * @param {number} offset - The offset. 3992 * @param {string} sessionId - The session id. 3993 */ 3994 constructor(s, p, a, n, i) { 3995 super(n, i), this.privReason = s, this.privErrorDetails = p, this.privErrorCode = a; 3996 } 3997 /** 3998 * The reason the recognition was canceled. 3999 * @member CancellationEventArgsBase.prototype.reason 4000 * @function 4001 * @public 4002 * @returns {CancellationReason} Specifies the reason canceled. 4003 */ 4004 get reason() { 4005 return this.privReason; 4006 } 4007 /** 4008 * The error code in case of an unsuccessful operation. 4009 * @return An error code that represents the error reason. 4010 */ 4011 get errorCode() { 4012 return this.privErrorCode; 4013 } 4014 /** 4015 * In case of an unsuccessful operation, provides details of the occurred error. 4016 * @member CancellationEventArgsBase.prototype.errorDetails 4017 * @function 4018 * @public 4019 * @returns {string} A String that represents the error details. 4020 */ 4021 get errorDetails() { 4022 return this.privErrorDetails; 4023 } 4024 }; 4025 return pt.CancellationEventArgsBase = e, pt; 4026} 4027var _s; 4028function zd() { 4029 if (_s) return ct; 4030 _s = 1, Object.defineProperty(ct, "__esModule", { value: !0 }), ct.SpeechRecognitionCanceledEventArgs = void 0; 4031 const t = zr(); 4032 let e = class extends t.CancellationEventArgsBase { 4033 }; 4034 return ct.SpeechRecognitionCanceledEventArgs = e, ct; 4035} 4036var ut = {}, bs;
4037function jd() { 4038 if (bs) return ut; 4039 bs = 1, Object.defineProperty(ut, "__esModule", { value: !0 }), ut.TranslationRecognitionEventArgs = void 0; 4040 const t = R(); 4041 let e = class extends t.RecognitionEventArgs { 4042 /** 4043 * Creates and initializes an instance of this class. 4044 * @constructor 4045 * @param {TranslationRecognitionResult} result - The translation recognition result. 4046 * @param {number} offset - The offset. 4047 * @param {string} sessionId - The session id. 4048 */ 4049 constructor(s, p, a) { 4050 super(p, a), this.privResult = s; 4051 } 4052 /** 4053 * Specifies the recognition result. 4054 * @member TranslationRecognitionEventArgs.prototype.result 4055 * @function 4056 * @public 4057 * @returns {TranslationRecognitionResult} the recognition result. 4058 */ 4059 get result() { 4060 return this.privResult; 4061 } 4062 }; 4063 return ut.TranslationRecognitionEventArgs = e, ut; 4064} 4065var ht = {}, Ms; 4066function Ld() { 4067 if (Ms) return ht; 4068 Ms = 1, Object.defineProperty(ht, "__esModule", { value: !0 }), ht.TranslationSynthesisEventArgs = void 0; 4069 const t = R(); 4070 let e = class extends t.SessionEventArgs { 4071 /** 4072 * Creates and initializes an instance of this class. 4073 * @constructor 4074 * @param {TranslationSynthesisResult} result - The translation synthesis result. 4075 * @param {string} sessionId - The session id. 4076 */ 4077 constructor(s, p) { 4078 super(p), this.privResult = s; 4079 } 4080 /** 4081 * Specifies the translation synthesis result. 4082 * @member TranslationSynthesisEventArgs.prototype.result 4083 * @function 4084 * @public 4085 * @returns {TranslationSynthesisResult} Specifies the translation synthesis result. 4086 */ 4087 get result() { 4088 return this.privResult; 4089 } 4090 }; 4091 return ht.TranslationSynthesisEventArgs = e, ht; 4092} 4093var dt = {}, Os; 4094function Xa() { 4095 if (Os) return dt; 4096 Os = 1, Object.defineProperty(dt, "__esModule", { value: !0 }), dt.TranslationRecognitionResult = void 0; 4097 const t = R(); 4098 let e = class Qa extends t.SpeechRecognitionResult { 4099 /** 4100 * Creates and initializes an instance of this class. 4101 * @constructor 4102 * @param {Translations} translations - The translations. 4103 * @param {string} resultId - The result id. 4104 * @param {ResultReason} reason - The reason. 4105 * @param {string} text - The recognized text. 4106 * @param {number} duration - The duration. 4107 * @param {number} offset - The offset into the stream. 4108 * @param {string} language - Primary Language detected, if provided. 4109 * @param {string} languageDetectionConfidence - Primary Language confidence ("Unknown," "Low," "Medium," "High"...), if provided. 4110 * @param {string} errorDetails - Error details, if provided. 4111 * @param {string} json - Additional Json, if provided. 4112 * @param {PropertyCollection} properties - Additional properties, if provided. 4113 */ 4114 constructor(s, p, a, n, i, o, c, u, h, d, v) { 4115 super(p, a, n, i, o, c, u, void 0, h, d, v), this.privTranslations = s; 4116 } 4117 static fromSpeechRecognitionResult(s) { 4118 return new Qa(void 0, s.resultId, s.reason, s.text, s.duration, s.offset, s.language, s.languageDetectionConfidence, s.errorDetails, s.json, s.properties); 4119 } 4120 /** 4121 * Presents the translation results. Each item in the dictionary represents 4122 * a translation result in one of target languages, where the key is the name 4123 * of the target language, in BCP-47 format, and the value is the translation 4124 * text in the specified language. 4125 * @member TranslationRecognitionResult.prototype.translations 4126 * @function 4127 * @public 4128 * @returns {Translations} the current translation map that holds all translations requested. 4129 */ 4130 get translations() { 4131 return this.privTranslations; 4132 } 4133 }; 4134 return dt.TranslationRecognitionResult = e, dt; 4135} 4136var Ti = {}; 4137Object.defineProperty(Ti, "__esModule", { value: !0 }); 4138Ti.TranslationSynthesisResult = void 0; 4139class Bd { 4140 /** 4141 * Creates and initializes an instance of this class. 4142 * @constructor 4143 * @param {ResultReason} reason - The synthesis reason. 4144 * @param {ArrayBuffer} audio - The audio data. 4145 */ 4146 constructor(e, r) { 4147 this.privReason = e, this.privAudio = r; 4148 } 4149 /** 4150 * Translated text in the target language. 4151 * @member TranslationSynthesisResult.prototype.audio 4152 * @function 4153 * @public 4154 * @returns {ArrayBuffer} Translated audio in the target language. 4155 */ 4156 get audio() { 4157 return this.privAudio; 4158 } 4159 /** 4160 * The synthesis status. 4161 * @member TranslationSynthesisResult.prototype.reason 4162 * @function 4163 * @public 4164 * @returns {ResultReason} The synthesis status. 4165 */ 4166 get reason() { 4167 return this.privReason; 4168 } 4169} 4170Ti.TranslationSynthesisResult = Bd; 4171var Ya = {}; 4172(function(t) { 4173 Object.defineProperty(t, "__esModule", { value: !0 }), t.ResultReason = void 0, function(e) { 4174 e[e.NoMatch = 0] = "NoMatch", e[e.Canceled = 1] = "Canceled", e[e.RecognizingSpeech = 2] = "RecognizingSpeech", e[e.RecognizedSpeech = 3] = "RecognizedSpeech", e[e.RecognizedKeyword = 4] = "RecognizedKeyword", e[e.TranslatingSpeech = 5] = "TranslatingSpeech", e[e.TranslatedSpeech = 6] = "TranslatedSpeech", e[e.SynthesizingAudio = 7] = "SynthesizingAudio", e[e.SynthesizingAudioCompleted = 8] = "SynthesizingAudioCompleted", e[e.SynthesizingAudioStarted = 9]
4174= "SynthesizingAudioStarted", e[e.VoicesListRetrieved = 10] = "VoicesListRetrieved", e[e.TranslatingParticipantSpeech = 11] = "TranslatingParticipantSpeech", e[e.TranslatedParticipantSpeech = 12] = "TranslatedParticipantSpeech", e[e.TranslatedInstantMessage = 13] = "TranslatedInstantMessage", e[e.TranslatedParticipantInstantMessage = 14] = "TranslatedParticipantInstantMessage"; 4175 }(t.ResultReason || (t.ResultReason = {})); 4176})(Ya); 4177var we = {}, Ds; 4178function qd() { 4179 if (Ds) return we; 4180 Ds = 1, Object.defineProperty(we, "__esModule", { value: !0 }), we.SpeechConfigImpl = we.SpeechConfig = void 0; 4181 const t = A(), e = O, r = R(); 4182 let s = class { 4183 /** 4184 * Creates and initializes an instance. 4185 * @constructor 4186 */ 4187 constructor() { 4188 } 4189 /** 4190 * Static instance of SpeechConfig returned by passing subscriptionKey and service region. 4191 * @member SpeechConfig.fromSubscription 4192 * @function 4193 * @public 4194 * @param {string} subscriptionKey - The subscription key. 4195 * @param {string} region - The region name (see the <a href="https://aka.ms/csspeech/region">region page</a>). 4196 * @returns {SpeechConfig} The speech factory 4197 */ 4198 static fromSubscription(n, i) { 4199 e.Contracts.throwIfNullOrWhitespace(n, "subscriptionKey"), e.Contracts.throwIfNullOrWhitespace(i, "region"); 4200 const o = new p(); 4201 return o.setProperty(r.PropertyId.SpeechServiceConnection_Region, i), o.setProperty(r.PropertyId.SpeechServiceConnection_Key, n), o; 4202 } 4203 /** 4204 * Internal implementation of fromEndpoint() overloads. Accepts either a subscription key or a TokenCredential. 4205 * @private 4206 */ 4207 static fromEndpoint(n, i) { 4208 e.Contracts.throwIfNull(n, "endpoint"); 4209 const o = typeof i == "string" && i.trim().length > 0, c = typeof i == "object" && i !== null && typeof i.getToken == "function", u = typeof i == "object" && i !== null && typeof i.key == "string"; 4210 if (i !== void 0 && !o && !c && !u) 4211 throw new Error("Invalid 'auth' parameter: expected a non-empty API key string, a TokenCredential, or a KeyCredential."); 4212 let h; 4213 return typeof i == "string" ? (h = new p(), h.setProperty(r.PropertyId.SpeechServiceConnection_Key, i)) : typeof i == "object" && typeof i.getToken == "function" ? h = new p(i) : typeof i == "object" && typeof i.key == "string" ? (h = new p(), h.setProperty(r.PropertyId.SpeechServiceConnection_Key, i.key)) : h = new p(), h.setProperty(r.PropertyId.SpeechServiceConnection_Endpoint, n.href), h; 4214 } 4215 /** 4216 * Creates an instance of the speech config with specified host and subscription key. 4217 * This method is intended only for users who use a non-default service host. Standard resource path will be assumed. 4218 * For services with a non-standard resource path or no path at all, use fromEndpoint instead. 4219 * Note: Query parameters are not allowed in the host URI and must be set by other APIs. 4220 * Note: To use an authorization token with fromHost, use fromHost(URL), 4221 * and then set the AuthorizationToken property on the created SpeechConfig instance. 4222 * Note: Added in version 1.9.0. 4223 * @member SpeechConfig.fromHost 4224 * @function 4225 * @public 4226 * @param {URL} host - The service endpoint to connect to. Format is "protocol://host:port" where ":port" is optional. 4227 * @param {string} subscriptionKey - The subscription key. If a subscription key is not specified, an authorization token must be set. 4228 * @returns {SpeechConfig} A speech factory instance. 4229 */ 4230 static fromHost(n, i) { 4231 e.Contracts.throwIfNull(n, "hostName"); 4232 const o = new p(); 4233 return o.setProperty(r.PropertyId.SpeechServiceConnection_Host, n.protocol + "//" + n.hostname + (n.port === "" ? "" : ":" + n.port)), o.setProperty(r.PropertyId.SpeechServiceConnection_RecognitionEndpointVersion, "1"), i !== void 0 && o.setProperty(r.PropertyId.SpeechServiceConnection_Key, i), o; 4234 } 4235 /** 4236 * Creates an instance of the speech factory with specified initial authorization token and region. 4237 * Note: The caller needs to ensure that the authorization token is valid. Before the authorization token 4238 * expires, the caller needs to refresh it by calling this setter with a new valid token. 4239 * Note: As configuration values are copied when creating a new recognizer, 4240 * the new token value will not apply to recognizers that have already been created. For recognizers 4241 * that have been created before, you need to set authorization token of the corresponding recognizer 4242 * to refresh the token. Otherwise, the recognizers will encounter errors during recognition. 4243 * @member SpeechConfig.fromAuthorizationToken 4244 * @function 4245 * @public 4246 * @param {string} authorizationToken - The initial authorization token. 4247 * @param {string} region - The region name (see the <a href="https://aka.ms/csspeech/region">region page</a>). 4248 * @returns {SpeechConfig} A speech factory instance. 4249 */ 4250 static fromAuthorizationToken(n, i) { 4251 e.Contracts.throwIfNull(n, "authorizationToken"), e.Contracts.throwIfNullOrWhitespace(i, "region"); 4252 const o = new p(); 4253 return o.setProperty(r.PropertyId.SpeechServiceConnection_Region, i), o.authorizationToken = n, o; 4254 } 4255 /** 4256 * Closes the configuration. 4257 * @member SpeechConfig.prototype.close 4258 * @function 4259 * @public 4260 */ 4261 // eslint-disable-next-line @typescript-eslint/no-empty-function 4262 close() { 4263 } 4264 }; 4265 we.SpeechConfig = s; 4266 class p extends s { 4267 constructor(n) { 4268 super(), this.privProperties = new r.PropertyCollection(), this.speechRecognitionLanguage = "en-US", this.outputFormat = r.OutputFormat.Simple, this.privTokenCredential = n; 4269 } 4270 get properties() { 4271 return this.privProperties; 4272 } 4273 get endPoint() { 4274 return new URL(this.privProperties.getProperty(r.PropertyId.SpeechServiceConnection_Endpoint)); 4275 } 4276 get subscriptionKey() { 4277 return this.privProperties.getProperty(r.PropertyId.SpeechServiceConnection_Key); 4278 } 4279 get region() { 4280 return this.privProperties.getProperty(r.PropertyId.SpeechServiceConnection_Region); 4281 } 4282 get authorizationToken() { 4283 return this.privProperties.getProperty(r.PropertyId.SpeechServiceAuthorization_Token); 4284 } 4285 set authorizationToken(n) { 4286 this.privProperties.setProperty(r.PropertyId.SpeechServiceAuthorization_Token, n); 4287 } 4288 get speechRecognitionLanguage() { 4289 return this.privProperties.getProperty(r.PropertyId.SpeechServiceConnection_RecoLanguage); 4290 } 4291 set speechRecognitionLanguage(n) { 4292 this.privProperties.setProperty(r.PropertyId.SpeechServiceConnection_RecoLanguage, n); 4293 } 4294 get autoDetectSourceLanguages() { 4295 return this.privProperties.getProperty(r.PropertyId.SpeechServiceConnection_AutoDetectSourceLanguages); 4296 } 4297 set autoDetectSourceLanguages(n) { 4298 this.privProperties.setProperty(r.PropertyId.SpeechServiceConnection_AutoDetectSourceLanguages, n); 4299 } 4300 get outputFormat() { 4301 return r.OutputFormat[this.privProperties.getProperty(t.OutputFormatPropertyName, void 0)]; 4302 } 4303 set outputFormat(n) { 4304 this.privProperties.setProperty(t.OutputFormatPropertyName, r.OutputFormat[n]); 4305 } 4306 get endpointId() { 4307 return this.privProperties.getProperty(r.PropertyId.SpeechServiceConnection_EndpointId); 4308 } 4309 set endpointId(n) { 4310 this.privProperties.setProperty(r.PropertyId.SpeechServiceConnection_EndpointId, n); 4311 } 4312 get tokenCredential() { 4313 return this.privTokenCredential; 4314 } 4315 setProperty(n, i) { 4316 e.Contracts.throwIfNull(i, "value"), this.privProperties.setProperty(n, i); 4317 } 4318 getProperty(n, i) { 4319 return this.privProperties.getProperty(n, i); 4320 } 4321 setProxy(n, i, o, c) { 4322 this.setProperty(r.PropertyId[r.PropertyId.SpeechServiceConnection_ProxyHostName], n), this.setProperty(r.PropertyId[r.PropertyId.SpeechServiceConnection_ProxyPort], i), this.setProperty(r.PropertyId[r.PropertyId.SpeechServiceConnection_ProxyUserName], o), this.setProperty(r.PropertyId[r.PropertyId.SpeechServiceConnection_ProxyPassword], c); 4323 } 4324 setServiceProperty(n, i) { 4325 const o = JSON.parse(this.privProperties.getProperty(t.ServicePropertiesPropertyName, "{}")); 4326 o[n] = i, this.privProperties.setProperty(t.ServicePropertiesPropertyName, JSON.stringify(o)); 4327 } 4328 setProfanity(n) { 4329 this.privProperties.setProperty(r.PropertyId.SpeechServiceResponse_ProfanityOption, r.ProfanityOption[n]); 4330 } 4331 enableAudioLogging() { 4332 this.privProperties.setProperty(r.PropertyId.SpeechServiceConnection_EnableAudioLogging, "true"); 4333 } 4334 requestWordLevelTimestamps() { 4335 this.privProperties.setProperty(r.PropertyId.SpeechServiceResponse_RequestWordLevelTimestamps, "true"), this.privProperties.setProperty(t.OutputFormatPropertyName, r.OutputFormat[r.OutputFormat.Detailed]); 4336 } 4337 enableDictation() { 4338 this.privProperties.setProperty(t.ForceDictationPropertyName, "true"); 4339 } 4340 clone() { 4341 const n = new p(this.tokenCredential); 4342 return n.privProperties = this.privProperties.clone(), n; 4343 } 4344 get speechSynthesisLanguage() { 4345 return this.privProperties.getProperty(r.PropertyId.SpeechServiceConnection_SynthLanguage); 4346 } 4347 set speechSynthesisLanguage(n) { 4348 this.privProperties.setProperty(r.PropertyId.SpeechServiceConnection_SynthLanguage, n); 4349 } 4350 get speechSynthesisVoiceName() { 4351 return this.privProperties.getProperty(r.PropertyId.SpeechServiceConnection_SynthVoice); 4352 } 4353 set speechSynthesisVoiceName(n) { 4354 this.privProperties.setProperty(r.PropertyId.SpeechServiceConnection_SynthVoice, n); 4355 } 4356 get speechSynthesisOutputFormat() { 4357 return r.SpeechSynthesisOutputFormat[this.privProperties.getProperty(r.PropertyId.SpeechServiceConnection_SynthOutputFormat, void 0)]; 4358 } 4359 set speechSynthesisOutputFormat(n) { 4360 this.privProperties.setProperty(r.PropertyId.SpeechServiceConnection_SynthOutputFormat, r.SpeechSynthesisOutputFormat[n]); 4361 } 4362 } 4363 return we.SpeechConfigImpl = p, we; 4364} 4365var _e = {}, ks; 4366function Fd() { 4367 if (ks) return _e; 4368 ks = 1, Object.defineProperty(_e, "__esModule", { value: !0 }), _e.SpeechTranslationConfigImpl = _e.SpeechTranslationConfig = void 0;
4369 const t = A(), e = O, r = R(); 4370 let s = class extends r.SpeechConfig { 4371 /** 4372 * Creates an instance of recognizer config. 4373 */ 4374 constructor() { 4375 super(); 4376 } 4377 /** 4378 * Static instance of SpeechTranslationConfig returned by passing a subscription key and service region. 4379 * @member SpeechTranslationConfig.fromSubscription 4380 * @function 4381 * @public 4382 * @param {string} subscriptionKey - The subscription key. 4383 * @param {string} region - The region name (see the <a href="https://aka.ms/csspeech/region">region page</a>). 4384 * @returns {SpeechTranslationConfig} The speech translation config. 4385 */ 4386 static fromSubscription(n, i) { 4387 e.Contracts.throwIfNullOrWhitespace(n, "subscriptionKey"), e.Contracts.throwIfNullOrWhitespace(i, "region"); 4388 const o = new p(); 4389 return o.properties.setProperty(r.PropertyId.SpeechServiceConnection_Key, n), o.properties.setProperty(r.PropertyId.SpeechServiceConnection_Region, i), o; 4390 } 4391 /** 4392 * Static instance of SpeechTranslationConfig returned by passing authorization token and service region. 4393 * Note: The caller needs to ensure that the authorization token is valid. Before the authorization token 4394 * expires, the caller needs to refresh it by setting the property authorizationToken with a new 4395 * valid token. Otherwise, all the recognizers created by this SpeechTranslationConfig instance 4396 * will encounter errors during recognition. 4397 * As configuration values are copied when creating a new recognizer, the new token value will not apply 4398 * to recognizers that have already been created. 4399 * For recognizers that have been created before, you need to set authorization token of the corresponding recognizer 4400 * to refresh the token. Otherwise, the recognizers will encounter errors during recognition. 4401 * @member SpeechTranslationConfig.fromAuthorizationToken 4402 * @function 4403 * @public 4404 * @param {string} authorizationToken - The authorization token. 4405 * @param {string} region - The region name (see the <a href="https://aka.ms/csspeech/region">region page</a>). 4406 * @returns {SpeechTranslationConfig} The speech translation config. 4407 */ 4408 static fromAuthorizationToken(n, i) { 4409 e.Contracts.throwIfNullOrWhitespace(n, "authorizationToken"), e.Contracts.throwIfNullOrWhitespace(i, "region"); 4410 const o = new p(); 4411 return o.properties.setProperty(r.PropertyId.SpeechServiceAuthorization_Token, n), o.properties.setProperty(r.PropertyId.SpeechServiceConnection_Region, i), o; 4412 } 4413 /** 4414 * Creates an instance of the speech config with specified host and subscription key. 4415 * This method is intended only for users who use a non-default service host. Standard resource path will be assumed. 4416 * For services with a non-standard resource path or no path at all, use fromEndpoint instead. 4417 * Note: Query parameters are not allowed in the host URI and must be set by other APIs. 4418 * Note: To use an authorization token with fromHost, use fromHost(URL), 4419 * and then set the AuthorizationToken property on the created SpeechConfig instance. 4420 * Note: Added in version 1.9.0. 4421 * @member SpeechConfig.fromHost 4422 * @function 4423 * @public 4424 * @param {URL} host - The service endpoint to connect to. Format is "protocol://host:port" where ":port" is optional. 4425 * @param {string} subscriptionKey - The subscription key. If a subscription key is not specified, an authorization token must be set. 4426 * @returns {SpeechConfig} A speech factory instance. 4427 */ 4428 static fromHost(n, i) { 4429 e.Contracts.throwIfNull(n, "hostName"); 4430 const o = new p(); 4431 return o.setProperty(r.PropertyId.SpeechServiceConnection_Host, n.protocol + "//" + n.hostname + (n.port === "" ? "" : ":" + n.port)), i !== void 0 && o.setProperty(r.PropertyId.SpeechServiceConnection_Key, i), o; 4432 } 4433 /** 4434 * Internal implementation of fromEndpoint() overloads. Accepts either a subscription key or a TokenCredential. 4435 * @private 4436 */ 4437 static fromEndpoint(n, i) { 4438 e.Contracts.throwIfNull(n, "endpoint"); 4439 const o = typeof i == "string" && i.trim().length > 0, c = typeof i == "object" && i !== null && typeof i.getToken == "function", u = typeof i == "object" && i !== null && typeof i.key == "string"; 4440 if (i !== void 0 && !o && !c && !u) 4441 throw new Error("Invalid 'auth' parameter: expected a non-empty API key string, a TokenCredential, or a KeyCredential."); 4442 let h; 4443 return typeof i == "string" ? (h = new p(), h.setProperty(r.PropertyId.SpeechServiceConnection_Key, i)) : typeof i == "object" && typeof i.getToken == "function" ? h = new p(i) : typeof i == "object" && typeof i.key == "string" ? (h = new p(), h.setProperty(r.PropertyId.SpeechServiceConnection_Key, i.key)) : h = new p(), h.setProperty(r.PropertyId.SpeechServiceConnection_Endpoint, n.href), h; 4444 } 4445 }; 4446 _e.SpeechTranslationConfig = s; 4447 class p extends s { 4448 constructor(n) { 4449 super(), this.privSpeechProperties = new r.PropertyCollection(), this.outputFormat = r.OutputFormat.Simple, this.privTokenCredential = n; 4450 } 4451 /** 4452 * Gets/Sets the authorization token. 4453 * If this is set, subscription key is ignored. 4454 * User needs to make sure the provided authorization token is valid and not expired. 4455 * @member SpeechTranslationConfigImpl.prototype.authorizationToken 4456 * @function 4457 * @public 4458 * @param {string} value - The authorization token. 4459 */ 4460 set authorizationToken(n) { 4461 e.Contracts.throwIfNullOrWhitespace(n, "value"), this.privSpeechProperties.setProperty(r.PropertyId.SpeechServiceAuthorization_Token, n); 4462 } 4463 /** 4464 * Sets the speech recognition language. 4465 * @member SpeechTranslationConfigImpl.prototype.speechRecognitionLanguage 4466 * @function 4467 * @public 4468 * @param {string} value - The authorization token. 4469 */ 4470 set speechRecognitionLanguage(n) { 4471 e.Contracts.throwIfNullOrWhitespace(n, "value"), this.privSpeechProperties.setProperty(r.PropertyId.SpeechServiceConnection_RecoLanguage, n); 4472 } 4473 /** 4474 * Gets the speech recognition language. 4475 * @member SpeechTranslationConfigImpl.prototype.speechRecognitionLanguage 4476 * @function 4477 * @public 4478 * @return {string} The speechRecognitionLanguage. 4479 */ 4480 get speechRecognitionLanguage() { 4481 return this.privSpeechProperties.getProperty(r.PropertyId[r.PropertyId.SpeechServiceConnection_RecoLanguage]); 4482 } 4483 /** 4484 * @member SpeechTranslationConfigImpl.prototype.subscriptionKey 4485 * @function 4486 * @public 4487 */ 4488 get subscriptionKey() { 4489 return this.privSpeechProperties.getProperty(r.PropertyId[r.PropertyId.SpeechServiceConnection_Key]); 4490 } 4491 /** 4492 * Gets the output format 4493 * @member SpeechTranslationConfigImpl.prototype.outputFormat 4494 * @function 4495 * @public 4496 */ 4497 get outputFormat() { 4498 return r.OutputFormat[this.privSpeechProperties.getProperty(t.OutputFormatPropertyName, void 0)]; 4499 } 4500 /** 4501 * Gets/Sets the output format 4502 * @member SpeechTranslationConfigImpl.prototype.outputFormat 4503 * @function 4504 * @public 4505 */ 4506 set outputFormat(n) { 4507 this.privSpeechProperties.setProperty(t.OutputFormatPropertyName, r.OutputFormat[n]); 4508 } 4509 /** 4510 * Gets the endpoint id. 4511 * @member SpeechTranslationConfigImpl.prototype.endpointId 4512 * @function 4513 * @public 4514 */ 4515 get endpointId() { 4516 return this.privSpeechProperties.getProperty(r.PropertyId.SpeechServiceConnection_EndpointId); 4517 } 4518 /** 4519 * Gets/Sets the endpoint id. 4520 * @member SpeechTranslationConfigImpl.prototype.endpointId 4521 * @function 4522 * @public 4523 */ 4524 set endpointId(n) { 4525 this.privSpeechProperties.setProperty(r.PropertyId.SpeechServiceConnection_EndpointId, n); 4526 } 4527 /** 4528 * Add a (text) target language to translate into. 4529 * @member SpeechTranslationConfigImpl.prototype.addTargetLanguage 4530 * @function 4531 * @public 4532 * @param {string} value - The language such as de-DE 4533 */ 4534 addTargetLanguage(n) { 4535 e.Contracts.throwIfNullOrWhitespace(n, "value"); 4536 const i = this.targetLanguages; 4537 i.includes(n) || (i.push(n), this.privSpeechProperties.setProperty(r.PropertyId.SpeechServiceConnection_TranslationToLanguages, i.join(","))); 4538 } 4539 /** 4540 * Gets the (text) target language to translate into. 4541 * @member SpeechTranslationConfigImpl.prototype.targetLanguages 4542 * @function 4543 * @public 4544 * @param {string} value - The language such as de-DE 4545 */ 4546 get targetLanguages() { 4547 return this.privSpeechProperties.getProperty(r.PropertyId.SpeechServiceConnection_TranslationToLanguages, void 0) !== void 0 ? this.privSpeechProperties.getProperty(r.PropertyId.SpeechServiceConnection_TranslationToLanguages).split(",") : []; 4548 } 4549 /** 4550 * Gets the voice name. 4551 * @member SpeechTranslationConfigImpl.prototype.voiceName 4552 * @function 4553 * @public 4554 */ 4555 get voiceName() { 4556 return this.getProperty(r.PropertyId[r.PropertyId.SpeechServiceConnection_TranslationVoice]); 4557 } 4558 /** 4559 * Gets/Sets the voice of the translated language, enable voice synthesis output. 4560 * @member SpeechTranslationConfigImpl.prototype.voiceName 4561 * @function 4562 * @public 4563 * @param {string} value - The name of the voice. 4564 */ 4565 set voiceName(n) { 4566 e.Contracts.throwIfNullOrWhitespace(n, "value"), this.privSpeechProperties.setProperty(r.PropertyId.SpeechServiceConnection_TranslationVoice, n); 4567 } 4568 /** 4569 * Provides the region. 4570 * @member SpeechTranslationConfigImpl.prototype.region 4571 * @function 4572 * @public 4573 * @returns {string} The region. 4574 */ 4575 get region() { 4576 return this.privSpeechProperties.getProperty(r.PropertyId.SpeechServiceConnection_Region); 4577 } 4578 get tokenCredential() { 4579 return this.privTokenCredential; 4580 } 4581 setProxy(n, i, o, c) { 4582 this.setProperty(r.PropertyId[r.PropertyId.SpeechServiceConnection_ProxyHostName], n), this.setProperty(r.PropertyId[r.PropertyId.SpeechServiceConnection_ProxyPort], i), this.setProperty(r.PropertyId[r.PropertyId.SpeechServiceConnection_ProxyUserName], o), this.setProperty(r.PropertyId[r.PropertyId.SpeechServiceConnection_ProxyPassword], c); 4583 } 4584 /** 4585 * Gets an arbitrary property value. 4586 * @member SpeechTranslationConfigImpl.prototype.getProperty 4587 * @function 4588 * @public 4589 * @param {string} name - The name of the property. 4590 * @param {string} def - The default value of the property in case it is not set. 4591 * @returns {string} The value of the property. 4592 */ 4593 getProperty(n, i) { 4594 return this.privSpeechProperties.getProperty(n, i); 4595 } 4596 /** 4597 * Gets/Sets an arbitrary property value. 4598 * @member SpeechTranslationConfigImpl.prototype.setProperty 4599 * @function 4600 * @public 4601 * @param {string | PropertyId} name - The name of the property to set. 4602 * @param {string} value - The value of the property. 4603 */ 4604 setProperty(n, i) { 4605 this.privSpeechProperties.setProperty(n, i); 4606 } 4607 /** 4608 * Provides access to custom properties. 4609 * @member SpeechTranslationConfigImpl.prototype.properties 4610 * @function 4611 * @public 4612 * @returns {PropertyCollection} The properties. 4613 */ 4614 get properties() { 4615 return this.privSpeechProperties; 4616 } 4617 /**
4618 * Dispose of associated resources. 4619 * @member SpeechTranslationConfigImpl.prototype.close 4620 * @function 4621 * @public 4622 */ 4623 close() { 4624 } 4625 setServiceProperty(n, i) { 4626 const o = JSON.parse(this.privSpeechProperties.getProperty(t.ServicePropertiesPropertyName, "{}")); 4627 o[n] = i, this.privSpeechProperties.setProperty(t.ServicePropertiesPropertyName, JSON.stringify(o)); 4628 } 4629 setProfanity(n) { 4630 this.privSpeechProperties.setProperty(r.PropertyId.SpeechServiceResponse_ProfanityOption, r.ProfanityOption[n]); 4631 } 4632 enableAudioLogging() { 4633 this.privSpeechProperties.setProperty(r.PropertyId.SpeechServiceConnection_EnableAudioLogging, "true"); 4634 } 4635 requestWordLevelTimestamps() { 4636 this.privSpeechProperties.setProperty(r.PropertyId.SpeechServiceResponse_RequestWordLevelTimestamps, "true"); 4637 } 4638 enableDictation() { 4639 this.privSpeechProperties.setProperty(t.ForceDictationPropertyName, "true"); 4640 } 4641 get speechSynthesisLanguage() { 4642 return this.privSpeechProperties.getProperty(r.PropertyId.SpeechServiceConnection_SynthLanguage); 4643 } 4644 set speechSynthesisLanguage(n) { 4645 this.privSpeechProperties.setProperty(r.PropertyId.SpeechServiceConnection_SynthLanguage, n); 4646 } 4647 get speechSynthesisVoiceName() { 4648 return this.privSpeechProperties.getProperty(r.PropertyId.SpeechServiceConnection_SynthVoice); 4649 } 4650 set speechSynthesisVoiceName(n) { 4651 this.privSpeechProperties.setProperty(r.PropertyId.SpeechServiceConnection_SynthVoice, n); 4652 } 4653 get speechSynthesisOutputFormat() { 4654 return r.SpeechSynthesisOutputFormat[this.privSpeechProperties.getProperty(r.PropertyId.SpeechServiceConnection_SynthOutputFormat, void 0)]; 4655 } 4656 set speechSynthesisOutputFormat(n) { 4657 this.privSpeechProperties.setProperty(r.PropertyId.SpeechServiceConnection_SynthOutputFormat, r.SpeechSynthesisOutputFormat[n]); 4658 } 4659 } 4660 return _e.SpeechTranslationConfigImpl = p, _e; 4661} 4662var vt = {}, Ns; 4663function $a() { 4664 if (Ns) return vt; 4665 Ns = 1, Object.defineProperty(vt, "__esModule", { value: !0 }), vt.PropertyCollection = void 0; 4666 const t = R(); 4667 let e = class Za { 4668 constructor() { 4669 this.privKeys = [], this.privValues = []; 4670 } 4671 /** 4672 * Returns the property value in type String. 4673 * Currently only String, int and bool are allowed. 4674 * If the name is not available, the specified defaultValue is returned. 4675 * @member PropertyCollection.prototype.getProperty 4676 * @function 4677 * @public 4678 * @param {string} key - The parameter name. 4679 * @param {string | number | boolean} def - The default value which is returned if the parameter 4680 * is not available in the collection. 4681 * @returns {string} value of the parameter. 4682 */ 4683 getProperty(s, p) { 4684 let a; 4685 typeof s == "string" ? a = s : a = t.PropertyId[s]; 4686 for (let n = 0; n < this.privKeys.length; n++) 4687 if (this.privKeys[n] === a) 4688 return this.privValues[n]; 4689 if (p !== void 0) 4690 return String(p); 4691 } 4692 /** 4693 * Sets the String value of the parameter specified by name. 4694 * @member PropertyCollection.prototype.setProperty 4695 * @function 4696 * @public 4697 * @param {string} key - The parameter name. 4698 * @param {string} value - The value of the parameter. 4699 */ 4700 setProperty(s, p) { 4701 let a; 4702 typeof s == "string" ? a = s : a = t.PropertyId[s]; 4703 for (let n = 0; n < this.privKeys.length; n++) 4704 if (this.privKeys[n] === a) { 4705 this.privValues[n] = p; 4706 return; 4707 } 4708 this.privKeys.push(a), this.privValues.push(p); 4709 } 4710 /** 4711 * Clones the collection. 4712 * @member PropertyCollection.prototype.clone 4713 * @function 4714 * @public 4715 * @returns {PropertyCollection} A copy of the collection. 4716 */ 4717 clone() { 4718 const s = new Za(); 4719 for (let p = 0; p < this.privKeys.length; p++) 4720 s.privKeys.push(this.privKeys[p]), s.privValues.push(this.privValues[p]); 4721 return s; 4722 } 4723 /** 4724 * Merges this set of properties into another, no overwrites. 4725 * @member PropertyCollection.prototype.mergeTo 4726 * @function 4727 * @public 4728 * @param {PropertyCollection} destinationCollection - The collection to merge into. 4729 */ 4730 mergeTo(s) { 4731 this.privKeys.forEach((p) => { 4732 if (s.getProperty(p, void 0) === void 0) { 4733 const a = this.getProperty(p); 4734 s.setProperty(p, a); 4735 } 4736 }); 4737 } 4738 /** 4739 * Get the keys in Property Collection. 4740 * @member PropertyCollection.prototype.keys 4741 * @function 4742 * @public 4743 * @returns {string []} Keys in the collection. 4744 */ 4745 get keys() { 4746 return this.privKeys; 4747 } 4748 }; 4749 return vt.PropertyCollection = e, vt; 4750} 4751var Ai = {}; 4752(function(t) { 4753 Object.defineProperty(t, "__esModule", { value: !0 }), t.PropertyId = void 0, function(e) { 4754 e[e.SpeechServiceConnection_Key = 0] = "SpeechServiceConnection_Key", e[e.SpeechServiceConnection_Endpoint = 1] = "SpeechServiceConnection_Endpoint", e[e.SpeechServiceConnection_Region = 2] = "SpeechServiceConnection_Region", e[e.SpeechServiceAuthorization_Token = 3] = "SpeechServiceAuthorization_Token", e[e.SpeechServiceAuthorization_Type = 4] = "SpeechServiceAuthorization_Type", e[e.SpeechServiceConnection_EndpointId = 5] = "SpeechServiceConnection_EndpointId", e[e.SpeechServiceConnection_TranslationToLanguages = 6] = "SpeechServiceConnection_TranslationToLanguages", e[e.SpeechServiceConnection_TranslationVoice = 7] = "SpeechServiceConnection_TranslationVoice", e[e.SpeechServiceConnection_TranslationFeatures = 8] = "SpeechServiceConnection_TranslationFeatures", e[e.SpeechServiceConnection_TranslationCategoryId = 9] = "SpeechServiceConnection_TranslationCategoryId", e[e.SpeechServiceConnection_ProxyHostName = 10] = "SpeechServiceConnection_ProxyHostName", e[e.SpeechServiceConnection_ProxyPort = 11] = "SpeechServiceConnection_ProxyPort", e[e.SpeechServiceConnection_ProxyUserName = 12] = "SpeechServiceConnection_ProxyUserName", e[e.SpeechServiceConnection_ProxyPassword = 13] = "SpeechServiceConnection_ProxyPassword", e[e.SpeechServiceConnection_RecoMode = 14] = "SpeechServiceConnection_RecoMode", e[e.SpeechServiceConnection_RecoLanguage = 15] = "SpeechServiceConnection_RecoLanguage", e[e.Speech_SessionId = 16] = "Speech_SessionId", e[e.SpeechServiceConnection_SynthLanguage = 17] = "SpeechServiceConnection_SynthLanguage", e[e.SpeechServiceConnection_SynthVoice = 18] = "SpeechServiceConnection_SynthVoice", e[e.SpeechServiceConnection_SynthOutputFormat = 19] = "SpeechServiceConnection_SynthOutputFormat", e[e.SpeechServiceConnection_AutoDetectSourceLanguages = 20] = "SpeechServiceConnection_AutoDetectSourceLanguages", e[e.SpeechServiceResponse_RequestDetailedResultTrueFalse = 21] = "SpeechServiceResponse_RequestDetailedResultTrueFalse", e[e.SpeechServiceResponse_RequestProfanityFilterTrueFalse = 22] = "SpeechServiceResponse_RequestProfanityFilterTrueFalse", e[e.SpeechServiceResponse_JsonResult = 23] = "SpeechServiceResponse_JsonResult", e[e.SpeechServiceResponse_JsonErrorDetails = 24] = "SpeechServiceResponse_JsonErrorDetails", e[e.CancellationDetail
4754s_Reason = 25] = "CancellationDetails_Reason", e[e.CancellationDetails_ReasonText = 26] = "CancellationDetails_ReasonText", e[e.CancellationDetails_ReasonDetailedText = 27] = "CancellationDetails_ReasonDetailedText", e[e.SpeechServiceConnection_Url = 28] = "SpeechServiceConnection_Url", e[e.SpeechServiceConnection_InitialSilenceTimeoutMs = 29] = "SpeechServiceConnection_InitialSilenceTimeoutMs", e[e.SpeechServiceConnection_EndSilenceTimeoutMs = 30] = "SpeechServiceConnection_EndSilenceTimeoutMs", e[e.Speech_SegmentationSilenceTimeoutMs = 31] = "Speech_SegmentationSilenceTimeoutMs", e[e.Speech_SegmentationMaximumTimeMs = 32] = "Speech_SegmentationMaximumTimeMs", e[e.Speech_SegmentationStrategy = 33] = "Speech_SegmentationStrategy", e[e.Speech_StartEventSensitivity = 34] = "Speech_StartEventSensitivity", e[e.SpeechServiceConnection_EnableAudioLogging = 35] = "SpeechServiceConnection_EnableAudioLogging", e[e.SpeechServiceConnection_LanguageIdMode = 36] = "SpeechServiceConnection_LanguageIdMode", e[e.SpeechServiceConnection_RecognitionEndpointVersion = 37] = "SpeechServiceConnection_RecognitionEndpointVersion", e[e.SpeechServiceResponse_ProfanityOption = 38] = "SpeechServiceResponse_ProfanityOption", e[e.SpeechServiceResponse_PostProcessingOption = 39] = "SpeechServiceResponse_PostProcessingOption", e[e.SpeechServiceResponse_RequestWordLevelTimestamps = 40] = "SpeechServiceResponse_RequestWordLevelTimestamps", e[e.SpeechServiceResponse_StablePartialResultThreshold = 41] = "SpeechServiceResponse_StablePartialResultThreshold", e[e.SpeechServiceResponse_OutputFormatOption = 42] = "SpeechServiceResponse_OutputFormatOption", e[e.SpeechServiceResponse_TranslationRequestStablePartialResult = 43] = "SpeechServiceResponse_TranslationRequestStablePartialResult", e[e.SpeechServiceResponse_RequestWordBoundary = 44] = "SpeechServiceResponse_RequestWordBoundary", e[e.SpeechServiceResponse_RequestPunctuationBoundary = 45] = "SpeechServiceResponse_RequestPunctuationBoundary", e[e.SpeechServiceResponse_RequestSentenceBoundary = 46] = "SpeechServiceResponse_RequestSentenceBoundary", e[e.SpeechServiceResponse_DiarizeIntermediateResults = 47] = "SpeechServiceResponse_DiarizeIntermediateResults", e[e.Conversation_ApplicationId = 48] = "Conversation_ApplicationId", e[e.Conversation_DialogType = 49] = "Conversation_DialogType", e[e.Conversation_Initial_Silence_Timeout = 50] = "Conversation_Initial_Silence_Timeout", e[e.Conversation_From_Id = 51] = "Conversation_From_Id", e[e.Conversation_Conversation_Id = 52] = "Conversation_Conversation_Id", e[e.Conversation_Custom_Voice_Deployment_Ids = 53] = "Conversation_Custom_Voice_Deployment_Ids", e[e.Conversation_Speech_Activity_Template = 54] = "Conversation_Speech_Activity_Template", e[e.Conversation_Request_Bot_Status_Messages = 55] = "Conversation_Request_Bot_Status_Messages", e[e.Conversation_Agent_Connection_Id = 56] = "Conversation_Agent_Connection_Id", e[e.SpeechServiceConnection_Host = 57] = "SpeechServiceConnection_Host", e[e.ConversationTranslator_Host = 58] = "ConversationTranslator_Host", e[e.ConversationTranslator_Name = 59] = "ConversationTranslator_Name", e[e.ConversationTranslator_CorrelationId = 60] = "ConversationTranslator_CorrelationId", e[e.ConversationTranslator_Token = 61] = "ConversationTranslator_Token", e[e.PronunciationAssessment_ReferenceText = 62] = "PronunciationAssessment_ReferenceText", e[e.PronunciationAssessment_GradingSystem = 63] = "PronunciationAssessment_GradingSystem", e[e.PronunciationAssessment_Granularity = 64] = "PronunciationAssessment_Granularity", e[e.PronunciationAssessment_EnableMiscue = 65] = "PronunciationAssessment_EnableMiscue", e[e.PronunciationAssessment_Json = 66] = "PronunciationAssessment_Json", e[e.PronunciationAssessment_Params = 67] = "PronunciationAssessment_Params", e[e.WebWorkerLoadType = 68] = "WebWorkerLoadType", e[e.TalkingAvatarService_WebRTC_SDP = 69] = "TalkingAvatarService_WebRTC_SDP", e[e.Recognizer_StopTimeoutMs = 70] = "Recognizer_StopTimeoutMs", e[e.SpeechServiceResponse_RecognitionLatencyMs = 71] = "SpeechServiceResponse_RecognitionLatencyMs"; 4755 }(t.PropertyId || (t.PropertyId = {})); 4756})(Ai); 4757var lt = {}, zs; 4758function Ud() { 4759 if (zs) return lt; 4760 zs = 1, Object.defineProperty(lt, "__esModule", { value: !0 }), lt.Recognizer = void 0;
4761 const t = A(), e = I(), r = O, s = R(); 4762 let p = class ec { 4763 /** 4764 * Creates and initializes an instance of a Recognizer 4765 * @constructor 4766 * @param {AudioConfig} audioInput - An optional audio input stream associated with the recognizer 4767 * @param {PropertyCollection} properties - A set of properties to set on the recognizer 4768 * @param {IConnectionFactory} connectionFactory - The factory class used to create a custom IConnection for the recognizer 4769 */ 4770 constructor(n, i, o, c) { 4771 this.audioConfig = n !== void 0 ? n : s.AudioConfig.fromDefaultMicrophoneInput(), this.privDisposed = !1, this.privProperties = i.clone(), this.privConnectionFactory = o, this.tokenCredential = c, this.implCommonRecognizerSetup(); 4772 } 4773 /** 4774 * Dispose of associated resources. 4775 * @member Recognizer.prototype.close 4776 * @function 4777 * @public 4778 */ 4779 close(n, i) { 4780 r.Contracts.throwIfDisposed(this.privDisposed), (0, e.marshalPromiseToCallbacks)(this.dispose(!0), n, i); 4781 } 4782 /** 4783 * @Internal 4784 * Internal data member to support fromRecognizer* pattern methods on other classes. 4785 * Do not use externally, object returned will change without warning or notice. 4786 */ 4787 get internalData() { 4788 return this.privReco; 4789 } 4790 /** 4791 * This method performs cleanup of resources. 4792 * The Boolean parameter disposing indicates whether the method is called 4793 * from Dispose (if disposing is true) or from the finalizer (if disposing is false). 4794 * Derived classes should override this method to dispose resource if needed. 4795 * @member Recognizer.prototype.dispose 4796 * @function 4797 * @public 4798 * @param {boolean} disposing - Flag to request disposal. 4799 */ 4800 async dispose(n) { 4801 this.privDisposed || (this.privDisposed = !0, n && this.privReco && (await this.privReco.audioSource.turnOff(), await this.privReco.dispose())); 4802 } 4803 /** 4804 * This method returns the current state of the telemetry setting. 4805 * @member Recognizer.prototype.telemetryEnabled 4806 * @function 4807 * @public 4808 * @returns true if the telemetry is enabled, false otherwise. 4809 */ 4810 static get telemetryEnabled() { 4811 return t.ServiceRecognizerBase.telemetryDataEnabled; 4812 } 4813 /** 4814 * This method globally enables or disables telemetry. 4815 * @member Recognizer.prototype.enableTelemetry 4816 * @function 4817 * @public 4818 * @param enabled - Global setting for telemetry collection. 4819 * If set to true, telemetry information like microphone errors, 4820 * recognition errors are collected and sent to Microsoft. 4821 * If set to false, no telemetry is sent to Microsoft. 4822 */ 4823 static enableTelemetry(n) { 4824 t.ServiceRecognizerBase.telemetryDataEnabled = n; 4825 } 4826 // Does the generic recognizer setup that is common across all recognizer types. 4827 implCommonRecognizerSetup() { 4828 let n = typeof window < "u" ? "Browser" : "Node", i = "unknown", o = "unknown"; 4829 typeof navigator < "u" && (n = n + "/" + navigator.platform, i = navigator.userAgent, o = navigator.appVersion); 4830 const c = this.createRecognizerConfig(new t.SpeechServiceConfig(new t.Context(new t.OS(n, i, o)))); 4831 this.privReco = this.createServiceRecognizer(ec.getAuth(this.privProperties, this.tokenCredential), this.privConnectionFactory, this.audioConfig, c); 4832 } 4833 async recognizeOnceAsyncImpl(n) { 4834 r.Contracts.throwIfDisposed(this.privDisposed); 4835 const i = new e.Deferred(); 4836 await this.implRecognizerStop(), await this.privReco.recognize(n, i.resolve, i.reject); 4837 const o = await i.promise; 4838 return await this.implRecognizerStop(), o; 4839 } 4840 async startContinuousRecognitionAsyncImpl(n) { 4841 r.Contracts.throwIfDisposed(this.privDisposed), await this.implRecognizerStop(), await this.privReco.recognize(n, void 0, void 0); 4842 } 4843 async stopContinuousRecognitionAsyncImpl() { 4844 r.Contracts.throwIfDisposed(this.privDisposed), await this.implRecognizerStop(); 4845 } 4846 async implRecognizerStop() { 4847 if (this.privReco) { 4848 const n = this.privProperties.getProperty(s.PropertyId.Recognizer_StopTimeoutMs, void 0); 4849 if (n !== void 0 && n !== "") { 4850 const i = parseInt(n, 10); 4851 if (i > 0) { 4852 try { 4853 await this.withTimeout(this.privReco.stopRecognizing(
4853), i, `Stop operation timed out after ${i}ms waiting for service to complete turn`); 4854 } catch (o) { 4855 throw await this.privReco.disconnect(), o; 4856 } 4857 return; 4858 } 4859 } 4860 await this.privReco.stopRecognizing(); 4861 } 4862 } 4863 withTimeout(n, i, o) { 4864 return Promise.race([ 4865 n, 4866 new Promise((c, u) => { 4867 setTimeout(() => { 4868 u(new Error(o)); 4869 }, i); 4870 }) 4871 ]); 4872 } 4873 static getAuth(n, i) { 4874 const o = n.getProperty(s.PropertyId.SpeechServiceConnection_Key, void 0); 4875 return o && o !== "" ? new t.CognitiveSubscriptionKeyAuthentication(o) : i ? new t.CognitiveTokenAuthentication(async () => { 4876 try { 4877 const c = await i.getToken("https://cognitiveservices.azure.com/.default"); 4878 return (c == null ? void 0 : c.token) ?? ""; 4879 } catch (c) { 4880 throw c; 4881 } 4882 }, async () => { 4883 try { 4884 const c = await i.getToken("https://cognitiveservices.azure.com/.default"); 4885 return (c == null ? void 0 : c.token) ?? ""; 4886 } catch (c) { 4887 throw c; 4888 } 4889 }) : new t.CognitiveTokenAuthentication(() => { 4890 const c = n.getProperty(s.PropertyId.SpeechServiceAuthorization_Token, void 0); 4891 return Promise.resolve(c); 4892 }, () => { 4893 const c = n.getProperty(s.PropertyId.SpeechServiceAuthorization_Token, void 0); 4894 return Promise.resolve(c); 4895 }); 4896 } 4897 }; 4898 return lt.Recognizer = p, lt; 4899} 4900var ft = {}, ae = {}; 4901(function(t) { 4902 Object.defineProperty(t, "__esModule", { value: !0 }), t.SpeechStartEventSensitivity = t.RecognitionMode = void 0, function(e) { 4903 e.Interactive = "Interactive", e.Dictation = "Dictation", e.Conversation = "Conversation", e.None = "None"; 4904 }(t.RecognitionMode || (t.RecognitionMode = {})), function(e) { 4905 e.Low = "low", e.Medium = "medium", e.High = "high"; 4906 }(t.SpeechStartEventSensitivity || (t.SpeechStartEventSensitivity = {})); 4907})(ae); 4908var js; 4909function xd() { 4910 if (js) return ft; 4911 js = 1, Object.defineProperty(ft, "__esModule", { value: !0 }), ft.SpeechRecognizer = void 0; 4912 const t = A(), e = ae, r = I(), s = O, p = R(); 4913 let a = class tc extends p.Recognizer { 4914 /** 4915 * SpeechRecognizer constructor. 4916 * @constructor 4917 * @param {SpeechConfig} speechConfig - an set of initial properties for this recognizer 4918 * @param {AudioConfig} audioConfig - An optional audio configuration associated with the recognizer 4919 */ 4920 constructor(i, o) { 4921 const c = i; 4922 s.Contracts.throwIfNull(c, "speechConfig"), s.Contracts.throwIfNullOrWhitespace(c.properties.getProperty(p.PropertyId.SpeechServiceConnection_RecoLanguage), p.PropertyId[p.PropertyId.SpeechServiceConnection_RecoLanguage]), super(o, c.properties, new t.SpeechConnectionFactory(), i.tokenCredential), this.privDisposedRecognizer = !1; 4923 } 4924 /** 4925 * SpeechRecognizer constructor. 4926 * @constructor 4927 * @param {SpeechConfig} speechConfig - an set of initial properties for this recognizer 4928 * @param {AutoDetectSourceLanguageConfig} autoDetectSourceLanguageConfig - An source language detection configuration associated with the recognizer 4929 * @param {AudioConfig} audioConfig - An optional audio configuration associated with the recognizer 4930 */ 4931 static FromConfig(i, o, c) { 4932 const u = i; 4933 return o.properties.mergeTo(u.properties), new tc(i, c); 4934 } 4935 /** 4936 * Gets the endpoint id of a customized speech model that is used for speech recognition. 4937 * @member SpeechRecognizer.prototype.endpointId 4938 * @function 4939 * @public 4940 * @returns {string} the endpoint id of a customized speech model that is used for speech recognition. 4941 */ 4942 get endpointId() { 4943 return s.Contracts.throwIfDisposed(this.privDisposedRecognizer), this.properties.getProperty(p.PropertyId.SpeechServiceConnection_EndpointId, "00000000-0000-0000-0000-000000000000"); 4944 } 4945 /** 4946 * Gets the authorization token used to communicate with the service. 4947 * @member SpeechRecognizer.prototype.authorizationToken 4948 * @function 4949 * @public 4950 * @returns {string} Authorization token. 4951 */ 4952 get authorizationToken() { 4953 return this.properties.getProperty(p.PropertyId.SpeechServiceAuthorization_Token); 4954 } 4955 /** 4956 * Gets/Sets the authorization token used to communicate with the service. 4957 * @member SpeechRecognizer.prototype.authorizationToken 4958 * @function 4959 * @public 4960 * @param {string} token - Authorization token. 4961 */ 4962 set authorizationToken(i) { 4963 s.Contracts.throwIfNullOrWhitespace(i, "token"), this.properties.setProperty(p.PropertyId.SpeechServiceAuthorization_Token, i); 4964 } 4965 /** 4966 * Gets the spoken language of recognition. 4967 * @member SpeechRecognizer.prototype.speechRecognitionLanguage 4968 * @function 4969 * @public 4970 * @returns {string} The spoken language of recognition. 4971 */ 4972 get speechRecognitionLanguage() { 4973 return s.Contracts.throwIfDisposed(this.privDisposedRecognizer), this.properties.getProperty(p.PropertyId.SpeechServiceConnection_RecoLanguage); 4974 } 4975 /** 4976 * Gets the output format of recognition. 4977 * @member SpeechRecognizer.prototype.outputFormat 4978 * @function 4979 * @public 4980 * @returns {OutputFormat} The output format of recognition. 4981 */ 4982 get outputFormat() { 4983 return s.Contracts.throwIfDisposed(this.privDisposedRecognizer), this.properties.getProperty(t.OutputFormatPropertyName, p.OutputFormat[p.OutputFormat.Simple]) === p.OutputFormat[p.OutputFormat.Simple] ? p.OutputFormat.Simple : p.OutputFormat.Detailed; 4984 } 4985 /** 4986 * The collection of properties and their values defined for this SpeechRecognizer. 4987 * @member SpeechRecognizer.prototype.properties 4988 * @function 4989 * @public 4990 * @returns {PropertyCollection} The collection of properties and their values defined for this SpeechRecognizer. 4991 */ 4992 get properties() { 4993 return this.privProperties; 4994 } 4995 /** 4996 * Starts speech recognition, and stops after the first utterance is recognized. 4997 * The task returns the recognition text as result. 4998 * Note: RecognizeOnceAsync() returns when the first utterance has been recognized, 4999 * so it is suitable only for single shot recognition 5000 * like command or query. For long-running recognition, use StartContinuousRecognitionAsync() instead. 5001 * @member SpeechRecognizer.prototype.recognizeOnceAsync 5002 * @function 5003 * @public 5004 * @param cb - Callback that received the SpeechRecognitionResult. 5005 * @param err - Callback invoked in case of an error. 5006 */ 5007 recognizeOnceAsync(i, o) { 5008 (0, r.marshalPromiseToCallbacks)(this.recognizeOnceAsyncImpl(e.RecognitionMode.Interactive), i, o); 5009 } 5010 /** 5011 * Starts speech recognition, until stopContinuousRecognitionAsync() is called. 5012 * User must subscribe to events to receive recognition results. 5013 * @member SpeechRecognizer.prototype.startContinuousRecognitionAsync 5014 * @function 5015 * @public 5016 * @param cb - Callback invoked once the recognition has started. 5017 * @param err - Callback invoked in case of an error. 5018 */ 5019 startContinuousRecognitionAsync(i, o) { 5020 (0, r.marshalPromiseToCallbacks)(this.startContinuousRecognitionAsyncImpl(this.properties.getProperty(t.ForceDictationPropertyName, void 0) === void 0 ? e.RecognitionMode.Conversation : e.RecognitionMode.Dictation), i, o); 5021 } 5022 /** 5023 * Stops continuous speech recognition. 5024 * @member SpeechRecognizer.prototype.stopContinuousRecognitionAsync 5025 * @function 5026 * @public 5027 * @param cb - Callback invoked once the recognition has stopped. 5028 * @param err - Callback invoked in case of an error. 5029 */ 5030 stopContinuousRecognitionAsync(i, o) { 5031 (0, r.marshalPromiseToCallbacks)(this.stopContinuousRecognitionAsyncImpl(), i, o); 5032 } 5033 /** 5034 * Starts speech recognition with keyword spotting, until 5035 * stopKeywordRecognitionAsync() is called. 5036 * User must subscribe to events to receive recognition results. 5037 * Note: Key word spotting functionality is only available on the 5038 * Speech Devices SDK. This functionality is currently not included in the SDK itself. 5039 * @member SpeechRecognizer.prototype.startKeywordRecognitionAsync 5040 * @function 5041 * @public 5042 * @param {KeywordRecognitionModel} model The keyword recognition model that 5043 * specifies the keyword to be recognized. 5044 * @param cb - Callback invoked once the recognition has started. 5045 * @param err - Callback invoked in case of an error. 5046 */ 5047 startKeywordRecognitionAsync(i, o, c) { 5048 s.Contracts.throwIfNull(i, "model"), c && c("Not yet implemented."); 5049 } 5050 /** 5051 * Stops continuous speech recognition. 5052 * Note: Key word spotting functionality is only available on the 5053 * Speech Devices SDK. This functionality is currently not included in the SDK itself. 5054 * @member SpeechRecognizer.prototype.stopKeywordRecognitionAsync 5055 * @function 5056 * @public 5057 * @param cb - Callback invoked once the recognition has stopped. 5058 * @param err - Callback invoked in case of an error. 5059 */ 5060 stopKeywordRecognitionAsync(i) { 5061 i && i(); 5062 } 5063 /** 5064 * closes all external resources held by an instance of this class. 5065 * @member SpeechRecognizer.prototype.close 5066 * @function 5067 * @public 5068 */ 5069 close(i, o) { 5070 s.Contracts.throwIfDisposed(this.privDisposedRecognizer), (0, r.marshalPromiseToCallbacks)(this.dispose(!0), i, o); 5071 } 5072 /**
5073 * Disposes any resources held by the object. 5074 * @member SpeechRecognizer.prototype.dispose 5075 * @function 5076 * @public 5077 * @param {boolean} disposing - true if disposing the object. 5078 */ 5079 async dispose(i) { 5080 this.privDisposedRecognizer || (i && (this.privDisposedRecognizer = !0, await this.implRecognizerStop()), await super.dispose(i)); 5081 } 5082 createRecognizerConfig(i) { 5083 return new t.RecognizerConfig(i, this.privProperties); 5084 } 5085 createServiceRecognizer(i, o, c, u) { 5086 const h = c; 5087 return new t.SpeechServiceRecognizer(i, o, h, u, this); 5088 } 5089 }; 5090 return ft.SpeechRecognizer = a, ft; 5091} 5092var gt = {}, mt = {}, be = {}, Ls; 5093function rc() { 5094 if (Ls) return be; 5095 Ls = 1, Object.defineProperty(be, "__esModule", { value: !0 }), be.ConnectionMessageImpl = be.ConnectionMessage = void 0; 5096 const t = Y, e = I(), r = $a(), s = Ai; 5097 let p = class { 5098 }; 5099 be.ConnectionMessage = p; 5100 class a { 5101 constructor(i) { 5102 this.privConnectionMessage = i, this.privProperties = new r.PropertyCollection(), this.privConnectionMessage.headers[t.HeaderNames.ConnectionId] && this.privProperties.setProperty(s.PropertyId.Speech_SessionId, this.privConnectionMessage.headers[t.HeaderNames.ConnectionId]), Object.keys(this.privConnectionMessage.headers).forEach((o) => { 5103 this.privProperties.setProperty(o, this.privConnectionMessage.headers[o]); 5104 }); 5105 } 5106 /** 5107 * The message path. 5108 */ 5109 get path() { 5110 return this.privConnectionMessage.headers[Object.keys(this.privConnectionMessage.headers).find((i) => i.toLowerCase() === "path".toLowerCase())]; 5111 } 5112 /** 5113 * Checks to see if the ConnectionMessage is a text message. 5114 * See also IsBinaryMessage(). 5115 */ 5116 get isTextMessage() { 5117 return this.privConnectionMessage.messageType === e.MessageType.Text; 5118 } 5119 /** 5120 * Checks to see if the ConnectionMessage is a binary message. 5121 * See also GetBinaryMessage(). 5122 */ 5123 get isBinaryMessage() { 5124 return this.privConnectionMessage.messageType === e.MessageType.Binary; 5125 } 5126 /** 5127 * Gets the text message payload. Typically the text message content-type is 5128 * application/json. To determine other content-types use 5129 * Properties.GetProperty("Content-Type"). 5130 */ 5131 get TextMessage() { 5132 return this.privConnectionMessage.textBody; 5133 } 5134 /** 5135 * Gets the binary message payload. 5136 */ 5137 get binaryMessage() { 5138 return this.privConnectionMessage.binaryBody; 5139 } 5140 /** 5141 * A collection of properties and their values defined for this <see cref="ConnectionMessage"/>. 5142 * Message headers can be accessed via this collection (e.g. "Content-Type"). 5143 */ 5144 get properties() { 5145 return this.privProperties; 5146 } 5147 /** 5148 * Returns a string that represents the connection message. 5149 */ 5150 toString() { 5151 return ""; 5152 } 5153 } 5154 return be.ConnectionMessageImpl = a, be; 5155} 5156var Bs; 5157function ic() { 5158 if (Bs) return mt; 5159 Bs = 1, Object.defineProperty(mt, "__esModule", { value: !0 }), mt.Connection = void 0; 5160 const t = A(), e = I(), r = rc(), s = O, p = R(); 5161 let a = class _n { 5162 /** 5163 * Gets the Connection instance from the specified recognizer. 5164 * @param recognizer The recognizer associated with the connection. 5165 * @return The Connection instance of the recognizer. 5166 */ 5167 static fromRecognizer(i) { 5168 const o = i.internalData, c = new _n(); 5169 return c.privInternalData = o, c.setupEvents(), c; 5170 } 5171 /** 5172 * Gets the Connection instance from the specified synthesizer. 5173 * @param synthesizer The synthesizer associated with the connection. 5174 * @return The Connection instance of the synthesizer. 5175 */ 5176 static fromSynthesizer(i) { 5177 const o = i.internalData, c = new _n(); 5178 return c.privInternalData = o, c.setupEvents(), c; 5179 } 5180 /** 5181 * Starts to set up connection to the service. 5182 * Users can optionally call openConnection() to manually set up a connection in advance before starting recognition on the 5183 * Recognizer associated with this Connection. After starting recognition, calling Open() will have no effect 5184 * 5185 * Note: On return, the connection might not be ready yet. Please subscribe to the Connected event to 5186 * be notified when the connection is established.
5187 */ 5188 openConnection(i, o) { 5189 (0, e.marshalPromiseToCallbacks)(this.privInternalData.connect(), i, o); 5190 } 5191 /** 5192 * Closes the connection the service. 5193 * Users can optionally call closeConnection() to manually shutdown the connection of the associated Recognizer. 5194 * 5195 * If closeConnection() is called during recognition, recognition will fail and cancel with an error. 5196 */ 5197 closeConnection(i, o) { 5198 if (this.privInternalData instanceof t.SynthesisAdapterBase) 5199 throw new Error("Disconnecting a synthesizer's connection is currently not supported"); 5200 (0, e.marshalPromiseToCallbacks)(this.privInternalData.disconnect(), i, o); 5201 } 5202 /** 5203 * Appends a parameter in a message to service. 5204 * Added in version 1.12.1. 5205 * @param path The path of the network message. 5206 * @param propertyName Name of the property 5207 * @param propertyValue Value of the property. This is a json string. 5208 */ 5209 setMessageProperty(i, o, c) { 5210 if (s.Contracts.throwIfNullOrWhitespace(o, "propertyName"), this.privInternalData instanceof t.ServiceRecognizerBase) { 5211 if (i.toLowerCase() !== "speech.context") 5212 throw new Error("Only speech.context message property sets are currently supported for recognizer"); 5213 { 5214 const u = this.privInternalData.speechContext.getContext(); 5215 u[o] = c; 5216 } 5217 } else if (this.privInternalData instanceof t.SynthesisAdapterBase) { 5218 if (i.toLowerCase() !== "speech.config" && i.toLowerCase() !== "synthesis.context") 5219 throw new Error("Only speech.config and synthesis.context message paths are currently supported for synthesizer"); 5220 if (i.toLowerCase() === "speech.config") { 5221 if (o.toLowerCase() !== "context") 5222 throw new Error("Only context property is currently supported for speech.config message path for synthesizer"); 5223 this.privInternalData.synthesizerConfig.setContextFromJson(c); 5224 } else 5225 this.privInternalData.synthesisContext.setSection(o, c); 5226 } 5227 } 5228 /** 5229 * Sends a message to the speech service. 5230 * Added in version 1.13.0. 5231 * @param path The WebSocket path of the message 5232 * @param payload The payload of the message. This is a json string or a ArrayBuffer. 5233 * @param success A callback to indicate success. 5234 * @param error A callback to indicate an error. 5235 */ 5236 sendMessageAsync(i, o, c, u) { 5237 (0, e.marshalPromiseToCallbacks)(this.privInternalData.sendNetworkMessage(i, o), c, u); 5238 } 5239 /** 5240 * Dispose of associated resources. 5241 */ 5242 close() { 5243 } 5244 setupEvents() { 5245 this.privEventListener = this.privInternalData.connectionEvents.attach((i) => { 5246 i.name === "ConnectionEstablishedEvent" ? this.connected && this.connected(new p.ConnectionEventArgs(i.connectionId)) : i.name === "ConnectionClosedEvent" ? this.disconnected && this.disconnected(new p.ConnectionEventArgs(i.connectionId)) : i.name === "ConnectionMessageSentEvent" ? this.messageSent && this.messageSent(new p.ConnectionMessageEventArgs(new r.ConnectionMessageImpl(i.message))) : i.name === "ConnectionMessageReceivedEvent" && this.messageReceived && this.messageReceived(new p.ConnectionMessageEventArgs(new r.ConnectionMessageImpl(i.message))); 5247 }), this.privServiceEventListener = this.privInternalData.serviceEvents.attach((i) => { 5248 this.receivedServiceMessage && this.receivedServiceMessage(new p.ServiceEventArgs(i.jsonString, i.name)); 5249 }); 5250 } 5251 }; 5252 return mt.Connection = a, mt; 5253} 5254var qs; 5255function Wd() { 5256 if (qs) return gt; 5257 qs = 1, Object.defineProperty(gt, "__esModule", { value: !0 }), gt.TranslationRecognizer = void 0; 5258 const t = A(), e = ae, r = I(), s = ic(), p = O, a = R(); 5259 let n = class nc extends a.Recognizer { 5260 /** 5261 * Initializes an instance of the TranslationRecognizer. 5262 * @constructor 5263 * @param {SpeechTranslationConfig} speechConfig - Set of properties to configure this recognizer. 5264 * @param {AudioConfig} audioConfig - An optional audio config associated with the recognizer 5265 * @param {IConnectionFactory} connectionFactory - An optional connection factory to use to generate the endpoint URIs, headers to set, etc... 5266 */ 5267 constructor(o, c, u) { 5268 const h = o; 5269 p.Contracts.throwIfNull(h, "speechConfig"), super(c, h.properties, u || new t.TranslationConnectionFactory(), o.tokenCredential), this.privDisposedTranslationRecognizer = !1, this.properties.getProperty(a.PropertyId.SpeechServiceConnection_TranslationVoice, void 0) !== void 0 && p.Contracts.throwIfNullOrWhitespace(this.properties.getProperty(a.PropertyId.SpeechServiceConnection_TranslationVoice), a.PropertyId[a.PropertyId.SpeechServiceConnection_TranslationVoice]), p.Contracts.throwIfNullOrWhitespace(this.properties.getProperty(a.PropertyId.SpeechServiceConnection_TranslationToLanguages), a.PropertyId[a.PropertyId.SpeechServiceConnection_TranslationToLanguages]), this.properties.getProperty(a.PropertyId.SpeechServiceConnection_AutoDetectSourceLanguages, void 0) === void 0 && p.Contracts.throwIfNullOrWhitespace(this.properties.getProperty(a.PropertyId.SpeechServiceConnection_RecoLanguage), a.PropertyId[a.PropertyId.SpeechServiceConnection_RecoLanguage]); 5270 } 5271 /** 5272 * TranslationRecognizer constructor. 5273 * @constructor 5274 * @param {SpeechTranslationConfig} speechTranslationConfig - an set of initial properties for this recognizer 5275 * @param {AutoDetectSourceLanguageConfig} autoDetectSourceLanguageConfig - An source language detection configuration associated with the recognizer 5276 * @param {AudioConfig} audioConfig - An optional audio configuration associated with the recognizer 5277 */ 5278 static FromConfig(o, c, u) { 5279 const h = o; 5280 return c.properties.mergeTo(h.properties), c.properties.getProperty(a.PropertyId.SpeechServiceConnection_AutoDetectSourceLanguages, void 0) === t.AutoDetectSourceLanguagesOpenRangeOptionName && h.properties.setProperty(a.PropertyId.SpeechServiceConnection_RecoLanguage, "en-US"), new nc(o, u); 5281 } 5282 /** 5283 * Gets the language name that was set when the recognizer was created. 5284 * @member TranslationRecognizer.prototype.speechRecognitionLanguage 5285 * @function 5286 * @public 5287 * @returns {string} Gets the language name that was set when the recognizer was created. 5288 */ 5289 get speechRecognitionLanguage() { 5290 return p.Contracts.throwIfDisposed(this.privDisposedTranslationRecognizer), this.properties.getProperty(a.PropertyId.SpeechServiceConnection_RecoLanguage); 5291 } 5292 /** 5293 * Gets target languages for translation that were set when the recognizer was created. 5294 * The language is specified in BCP-47 format. The translation will provide translated text for each of language. 5295 * @member TranslationRecognizer.prototype.targetLanguages 5296 * @function 5297 * @public 5298 * @returns {string[]} Gets target languages for translation that were set when the recognizer was created. 5299 */ 5300 get targetLanguages() { 5301 return p.Contracts.throwIfDisposed(this.privDisposedTranslationRecognizer), this.properties.getProperty(a.PropertyId.SpeechServiceConnection_TranslationToLanguages).split(","); 5302 } 5303 /** 5304 * Gets the name of output voice. 5305 * @member TranslationRecognizer.prototype.voiceName 5306 * @function 5307 * @public 5308 * @returns {string} the name of output voice. 5309 */ 5310 get voiceName() { 5311 return p.Contracts.throwIfDisposed(this.privDisposedTranslationRecognizer), this.properties.getProperty(a.PropertyId.SpeechServiceConnection_TranslationVoice, void 0); 5312 } 5313 /** 5314 * The collection of properties and their values defined for this TranslationRecognizer. 5315 * @member TranslationRecognizer.prototype.properties 5316 * @function 5317 * @public 5318 * @returns {PropertyCollection} The collection of properties and their values defined for this TranslationRecognizer. 5319 */ 5320 get properties() { 5321 return this.privProperties; 5322 } 5323 /** 5324 * Gets the authorization token used to communicate with the service. 5325 * @member TranslationRecognizer.prototype.authorizationToken 5326 * @function 5327 * @public 5328 * @returns {string} Authorization token. 5329 */ 5330 get authorizationToken() { 5331 return this.properties.getProperty(a.PropertyId.SpeechServiceAuthorization_Token); 5332 } 5333 /** 5334 * Gets/Sets the authorization token used to communicate with the service. 5335 * @member TranslationRecognizer.prototype.authorizationToken 5336 * @function 5337 * @public 5338 * @param {string} value - Authorization token. 5339 */ 5340 set authorizationToken(o) { 5341 this.properties.setProperty(a.PropertyId.SpeechServiceAuthorization_Token, o); 5342 } 5343 /** 5344 * Starts recognition and translation, and stops after the first utterance is recognized. 5345 * The task returns the translation text as result. 5346 * Note: recognizeOnceAsync returns when the first utterance has been recognized, so it is suitable only 5347 * for single shot recognition like command or query. For long-running recognition, 5348 * use startContinuousRecognitionAsync() instead. 5349 * @member TranslationRecognizer.prototype.recognizeOnceAsync 5350 * @function 5351 * @public 5352 * @param cb - Callback that received the result when the translation has completed. 5353 * @param err - Callback invoked in case of an error. 5354 */ 5355 recognizeOnceAsync(o, c) { 5356 p.Contracts.throwIfDisposed(this.privDisposedTranslationRecognizer), (0, r.marshalPromiseToCallbacks)(this.recognizeOnceAsyncImpl(e.RecognitionMode.Interactive), o, c); 5357 } 5358 /** 5359 * Starts recognition and translation, until stopContinuousRecognitionAsync() is called. 5360 * User must subscribe to events to receive translation results. 5361 * @member TranslationRecognizer.prototype.startContinuousRecognitionAsync 5362 * @function 5363 * @public 5364 * @param cb - Callback that received the translation has started. 5365 * @param err - Callback invoked in case of an error. 5366 */ 5367 startContinuousRecognitionAsync(o, c) { 5368 (0, r.marshalPromiseToCallbacks)(this.startContinuousRecognitionAsyncImpl(e.RecognitionMode.Conversation), o, c); 5369 } 5370 /** 5371 * Stops continuous recognition and translation. 5372 * @member TranslationRecognizer.prototype.stopContinuousRecognitionAsync 5373 * @function 5374 * @public 5375 * @param cb - Callback that received the translation has stopped. 5376 * @param err - Callback invoked in case of an error. 5377 */ 5378 stopContinuousRecognitionAsync(o, c) { 5379 (0, r.marshalPromiseToCallbacks)(this.stopContinuousRecognitionAsyncImpl(), o, c); 5380 } 5381 /** 5382 * dynamically remove a language from list of target language 5383 * (can be used while recognition is ongoing) 5384 * @member TranslationRecognizer.prototype.removeTargetLanguage 5385 * @function 5386 * @param lang - language to be removed 5387 * @public 5388 */ 5389 removeTargetLanguage(o) { 5390 if (p.Contracts.throwIfNullOrUndefined(o, "language to be removed"), this.properties.getProperty(a.PropertyId.SpeechServiceConnection_TranslationToLanguages, void 0) !== void 0) { 5391 const c = this.properties.getProperty(a.PropertyId.SpeechServiceConnection_TranslationToLanguages).split(","), u = c.indexOf(o); 5392 u > -1 && (c.splice(u, 1), this.properties.setProperty(a.PropertyId.SpeechServiceConnection_TranslationToLanguages, c.join(",")), this.updateLanguages(c)); 5393 } 5394 } 5395 /** 5396 * dynamically add a language to list of target language 5397 * (can be used while recognition is ongoing) 5398 * @member TranslationRecognizer.prototype.addTargetLanguage 5399 * @function 5400 * @param lang - language to be added 5401 * @public 5402 */ 5403 addTargetLanguage(o) { 5404 p.Contracts.throwIfNullOrUndefined(o, "language to be added"); 5405 let c = []; 5406 this.properties.getProperty(a.PropertyId.SpeechServiceConnection_TranslationToLanguages, void 0) !== void 0 ? (c = this.properties.getProperty(a.PropertyId.SpeechServiceConnection_TranslationToLanguages).split(","), c.includes(o) || (c.push(o), this.properties.setProperty(a.PropertyId.SpeechServiceConnection_TranslationToLanguages, c.join(",")))) : (this.properties.setProperty(a.PropertyId.SpeechServiceConnection_TranslationToLanguages, o), c = [o]), this.updateLanguages(c); 5407 } 5408 /** 5409 * closes all external resources held by an instance of this class. 5410 * @member TranslationRecognizer.prototype.close 5411 * @function 5412 * @public 5413 */ 5414 close(o, c) { 5415 p.Contracts.throwIfDisposed(this.privDisposedTranslationRecognizer), (0, r.marshalPromiseToCallbacks)(this.dispose(!0), o, c); 5416 } 5417 /** 5418 * handles ConnectionEstablishedEvent for conversation translation scenarios. 5419 * @member TranslationRecognizer.prototype.onConnection 5420 * @function 5421 * @public 5422 */ 5423 // eslint-disable-next-line @typescript-eslint/no-empty-function 5424 onConnection() { 5425 } 5426 async dispose(o) { 5427 this.privDisposedTranslationRecognizer || (this.privDisposedTranslationRecognizer = !0, o && (await this.implRecognizerStop(), await super.dispose(o))); 5428 } 5429 createRecognizerConfig(o) { 5430 return new t.RecognizerConfig(o, this.privProperties); 5431 } 5432 createServiceRecognizer(o, c, u, h) { 5433 const d = u; 5434 return new t.TranslationServiceRecognizer(o, c, d, h, this); 5435 } 5436 updateLanguages(o) { 5437 const c = s.Connection.fromRecognizer(this); 5438 c && (c.setMessageProperty("speech.context", "translationcontext", { to: o }), c.sendMessageAsync("event", JSON.stringify({ 5439 id: "translation", 5440 name: "updateLanguage", 5441 to: o 5442 }))); 5443 } 5444 }; 5445 return gt.TranslationRecognizer = n, gt; 5446} 5447var St = {}, Fs; 5448function Hd() { 5449 if (Fs) return St; 5450 Fs = 1, Object.defineProperty(St, "__esModule", { value: !0 }), St.Translations = void 0; 5451 const t = R(); 5452 let e = class { 5453 constructor() { 5454 this.privMap = new t.PropertyCollection(); 5455 } 5456 /** 5457 * Get the languages in the object in a String array. 5458 * @member Translations.prototype.languages 5459 * @function 5460 * @public 5461 * @returns {string[]} languages in translations object. 5462 */ 5463 get languages() { 5464 return this.privMap.keys; 5465 } 5466 /**
5467 * Returns the parameter value in type String. The parameter must have the same type as String. 5468 * Currently only String, int and bool are allowed. 5469 * If the name is not available, the specified defaultValue is returned. 5470 * @member Translations.prototype.get 5471 * @function 5472 * @public 5473 * @param {string} key - The parameter name. 5474 * @param {string} def - The default value which is returned if the parameter is not available in the collection. 5475 * @returns {string} value of the parameter. 5476 */ 5477 get(s, p) { 5478 return this.privMap.getProperty(s, p); 5479 } 5480 /** 5481 * Sets the String value of the parameter specified by name. 5482 * @member Translations.prototype.set 5483 * @function 5484 * @public 5485 * @param {string} key - The parameter name. 5486 * @param {string} value - The value of the parameter. 5487 */ 5488 set(s, p) { 5489 this.privMap.setProperty(s, p); 5490 } 5491 }; 5492 return St.Translations = e, St; 5493} 5494var sc = {}; 5495(function(t) { 5496 Object.defineProperty(t, "__esModule", { value: !0 }), t.NoMatchReason = void 0, function(e) { 5497 e[e.NotRecognized = 0] = "NotRecognized", e[e.InitialSilenceTimeout = 1] = "InitialSilenceTimeout", e[e.InitialBabbleTimeout = 2] = "InitialBabbleTimeout"; 5498 }(t.NoMatchReason || (t.NoMatchReason = {})); 5499})(sc); 5500var Ct = {}, Us; 5501function Kd() { 5502 if (Us) return Ct; 5503 Us = 1, Object.defineProperty(Ct, "__esModule", { value: !0 }), Ct.NoMatchDetails = void 0; 5504 const t = A(), e = R(); 5505 let r = class oc { 5506 /** 5507 * Creates and initializes an instance of this class. 5508 * @constructor 5509 * @param {NoMatchReason} reason - The no-match reason. 5510 */ 5511 constructor(p) { 5512 this.privReason = p; 5513 } 5514 /** 5515 * Creates an instance of NoMatchDetails object for the NoMatch SpeechRecognitionResults. 5516 * @member NoMatchDetails.fromResult 5517 * @function 5518 * @public 5519 * @param {SpeechRecognitionResult | TranslationRecognitionResult} 5520 * result - The recognition result that was not recognized. 5521 * @returns {NoMatchDetails} The no match details object being created. 5522 */ 5523 static fromResult(p) { 5524 const a = t.SimpleSpeechPhrase.fromJSON(p.json, 0); 5525 let n = e.NoMatchReason.NotRecognized; 5526 switch (a.RecognitionStatus) { 5527 case t.RecognitionStatus.BabbleTimeout: 5528 n = e.NoMatchReason.InitialBabbleTimeout; 5529 break; 5530 case t.RecognitionStatus.InitialSilenceTimeout: 5531 n = e.NoMatchReason.InitialSilenceTimeout; 5532 break; 5533 default: 5534 n = e.NoMatchReason.NotRecognized; 5535 break; 5536 } 5537 return new oc(n); 5538 } 5539 /** 5540 * The reason the recognition was canceled. 5541 * @member NoMatchDetails.prototype.reason 5542 * @function 5543 * @public 5544 * @returns {NoMatchReason} Specifies the reason canceled. 5545 */ 5546 get reason() { 5547 return this.privReason; 5548 } 5549 }; 5550 return Ct.NoMatchDetails = r, Ct; 5551} 5552var Ii = {}; 5553Object.defineProperty(Ii, "__esModule", { value: !0 }); 5554Ii.TranslationRecognitionCanceledEventArgs = void 0; 5555class Jd { 5556 /** 5557 * Creates and initializes an instance of this class. 5558 * @constructor 5559 * @param {string} sessionid - The session id. 5560 * @param {CancellationReason} cancellationReason - The cancellation reason. 5561 * @param {string} errorDetails - Error details, if provided. 5562 * @param {TranslationRecognitionResult} result - The result. 5563 */ 5564 constructor(e, r, s, p, a) { 5565 this.privCancelReason = r, this.privErrorDetails = s, this.privResult = a, this.privSessionId = e, this.privErrorCode = p; 5566 } 5567 /** 5568 * Specifies the recognition result. 5569 * @member TranslationRecognitionCanceledEventArgs.prototype.result 5570 * @function 5571 * @public 5572 * @returns {TranslationRecognitionResult} the recognition result. 5573 */ 5574 get result() { 5575 return this.privResult; 5576 } 5577 /** 5578 * Specifies the session identifier. 5579 * @member TranslationRecognitionCanceledEventArgs.prototype.sessionId 5580 * @function 5581 * @public 5582 * @returns {string} the session identifier. 5583 */ 5584 get sessionId() { 5585 return this.privSessionId; 5586 } 5587 /** 5588 * The reason the recognition was canceled. 5589 * @member TranslationRecognitionCanceledEventArgs.prototype.reason 5590 * @function 5591 * @public 5592 * @returns {CancellationReason} Specifies the reason canceled. 5593 */ 5594 get reason() { 5595 return this.privCancelReason; 5596 } 5597 /** 5598 * The error code in case of an unsuccessful recognition. 5599 * Added in version 1.1.0. 5600 * @return An error code that represents the error reason. 5601 */ 5602 get errorCode() { 5603 return this.privErrorCode; 5604 } 5605 /** 5606 * In case of an unsuccessful recognition, provides details of the occurred error. 5607 * @member TranslationRecognitionCanceledEventArgs.prototype.errorDetails 5608 * @function 5609 * @public 5610 * @returns {string} A String that represents the error details. 5611 */ 5612 get errorDetails() { 5613 return this.privErrorDetails; 5614 } 5615} 5616Ii.TranslationRecognitionCanceledEventArgs = Jd; 5617var jr = {}; 5618Object.defineProperty(jr, "__esModule", { value: !0 });
5619jr.CancellationDetailsBase = void 0; 5620class Vd { 5621 /** 5622 * Creates and initializes an instance of this class. 5623 * @constructor 5624 * @param {CancellationReason} reason - The cancellation reason. 5625 * @param {string} errorDetails - The error details, if provided. 5626 */ 5627 constructor(e, r, s) { 5628 this.privReason = e, this.privErrorDetails = r, this.privErrorCode = s; 5629 } 5630 /** 5631 * The reason the recognition was canceled. 5632 * @member CancellationDetailsBase.prototype.reason 5633 * @function 5634 * @public 5635 * @returns {CancellationReason} Specifies the reason canceled. 5636 */ 5637 get reason() { 5638 return this.privReason; 5639 } 5640 /** 5641 * In case of an unsuccessful recognition, provides details of the occurred error. 5642 * @member CancellationDetailsBase.prototype.errorDetails 5643 * @function 5644 * @public 5645 * @returns {string} A String that represents the error details. 5646 */ 5647 get errorDetails() { 5648 return this.privErrorDetails; 5649 } 5650 /** 5651 * The error code in case of an unsuccessful recognition. 5652 * Added in version 1.1.0. 5653 * @return An error code that represents the error reason. 5654 */ 5655 get ErrorCode() { 5656 return this.privErrorCode; 5657 } 5658} 5659jr.CancellationDetailsBase = Vd; 5660var yt = {}, xs; 5661function Gd() { 5662 if (xs) return yt; 5663 xs = 1, Object.defineProperty(yt, "__esModule", { value: !0 }), yt.CancellationDetails = void 0; 5664 const t = A(), e = jr, r = R(); 5665 let s = class ac extends e.CancellationDetailsBase { 5666 constructor(a, n, i) { 5667 super(a, n, i); 5668 } 5669 /** 5670 * Creates an instance of CancellationDetails object for the canceled RecognitionResult. 5671 * @member CancellationDetails.fromResult 5672 * @function 5673 * @public 5674 * @param {RecognitionResult | SpeechSynthesisResult} result - The result that was canceled. 5675 * @returns {CancellationDetails} The cancellation details object being created. 5676 */ 5677 static fromResult(a) { 5678 let n = r.CancellationReason.Error, i = r.CancellationErrorCode.NoError; 5679 if (a instanceof r.RecognitionResult && a.json) { 5680 const o = t.SimpleSpeechPhrase.fromJSON(a.json, 0); 5681 n = t.EnumTranslation.implTranslateCancelResult(o.RecognitionStatus); 5682 } 5683 return a.properties && (i = r.CancellationErrorCode[a.properties.getProperty(t.CancellationErrorCodePropertyName, r.CancellationErrorCode[r.CancellationErrorCode.NoError])]), new ac(n, a.errorDetails || t.EnumTranslation.implTranslateErrorDetails(i), i); 5684 } 5685 }; 5686 return yt.CancellationDetails = s, yt; 5687} 5688var cc = {}; 5689(function(t) { 5690 Object.defineProperty(t, "__esModule", { value: !0 }), t.CancellationErrorCode = void 0, function(e) { 5691 e[e.NoError = 0] = "NoError", e[e.AuthenticationFailure = 1] = "AuthenticationFailure", e[e.BadRequestParameters = 2] = "BadRequestParameters", e[e.TooManyRequests = 3] = "TooManyRequests", e[e.ConnectionFailure = 4] = "ConnectionFailure", e[e.ServiceTimeout = 5] = "ServiceTimeout", e[e.ServiceError = 6] = "ServiceError", e[e.RuntimeError = 7] = "RuntimeError", e[e.Forbidden = 8] = "Forbidden"; 5692 }(t.CancellationErrorCode || (t.CancellationErrorCode = {})); 5693})(cc); 5694var Pt = {}, Ws; 5695function Qd() { 5696 if (Ws) return Pt; 5697 Ws = 1, Object.defineProperty(Pt, "__esModule", { value: !0 }), Pt.ConnectionEventArgs = void 0; 5698 const t = R(); 5699 let e = class extends t.SessionEventArgs { 5700 }; 5701 return Pt.ConnectionEventArgs = e, Pt; 5702} 5703var Rt = {}, Hs; 5704function Xd() { 5705 if (Hs) return Rt; 5706 Hs = 1, Object.defineProperty(Rt, "__esModule", { value: !0 }), Rt.ServiceEventArgs = void 0; 5707 const t = R(); 5708 let e = class extends t.SessionEventArgs { 5709 /** 5710 * Creates and initializes an instance of this class. 5711 * @constructor 5712 * @param {string} json - json payload of the USP message. 5713 */ 5714 constructor(s, p, a) { 5715 super(a), this.privJsonResult = s, this.privEventName = p; 5716 } 5717 get jsonString() { 5718 return this.privJsonResult; 5719 } 5720 get eventName() { 5721 return this.privEventName; 5722 } 5723 }; 5724 return Rt.ServiceEventArgs = e, Rt; 5725} 5726var wi = {}; 5727Object.defineProperty(wi, "__esModule", { value: !0 }); 5728wi.PhraseListGrammar = void 0; 5729const Yd = O; 5730class qn { 5731 constructor(e) { 5732 this.privGrammerBuilder = e.dynamicGrammar; 5733 } 5734 /** 5735 * Creates a PhraseListGrammar from a given speech recognizer. Will accept any recognizer that derives from @class Recognizer. 5736 * @param recognizer The recognizer to add phrase lists to. 5737 */ 5738 static fromRecognizer(e) { 5739 const r = e.internalData; 5740 return new qn(r); 5741 } 5742 /** 5743 * Adds a single phrase to the current recognizer. 5744 * @param phrase Phrase to add. 5745 */ 5746 addPhrase(e) { 5747 this.privGrammerBuilder.addPhrase(e); 5748 } 5749 /** 5750 * Adds multiple phrases to the current recognizer. 5751 * @param phrases Array of phrases to add. 5752 */ 5753 addPhrases(e) { 5754 this.privGrammerBuilder.addPhrase(e); 5755 } 5756 /** 5757 * Clears all phrases added to the current recognizer. 5758 */ 5759 clear() { 5760 this.privGrammerBuilder.clearPhrases(); 5761 } 5762 /** 5763 * Sets the phrase list grammar biasing weight. 5764 * The allowed range is [0.0, 2.0]. 5765 * The default weight is 1.0. Value zero disables the phrase list. 5766 * @param weight Phrase list grammar biasing weight. 5767 */ 5768 setWeight(e) { 5769 Yd.Contracts.throwIfNumberOutOfRange(e, "weight", 0, 2), this.privGrammerBuilder.setWeight(e); 5770 } 5771} 5772wi.PhraseListGrammar = qn; 5773var Me = {}, Ks; 5774function Fn() { 5775 if (Ks) return Me; 5776 Ks = 1, Object.defineProperty(Me, "__esModule", { value: !0 }), Me.DialogServiceConfigImpl = Me.DialogServiceConfig = void 0; 5777 const t = O, e = R(); 5778 let r = class { 5779 /** 5780 * Creates an instance of DialogService config. 5781 * @constructor 5782 */ 5783 constructor() { 5784 } 5785 /** 5786 * Sets the corresponding backend application identifier. 5787 * @member DialogServiceConfig.prototype.Conversation_ApplicationId 5788 * @function 5789 * @public 5790 * @param {string} value - The application identifier to set. 5791 */ 5792 // eslint-disable-next-line @typescript-eslint/no-empty-function 5793 set applicationId(a) { 5794 } 5795 static get DialogTypes() { 5796 return { 5797 BotFramework: "bot_framework", 5798 CustomCommands: "custom_commands" 5799 }; 5800 } 5801 }; 5802 Me.DialogServiceConfig = r; 5803 class s extends r { 5804 /** 5805 * Creates an instance of dialogService config. 5806 */ 5807 constructor() { 5808 super(), this.privSpeechConfig = new e.SpeechConfigImpl(); 5809 } 5810 /** 5811 * Provides access to custom properties. 5812 * @member DialogServiceConfigImpl.prototype.properties 5813 * @function 5814 * @public 5815 * @returns {PropertyCollection} The properties. 5816 */ 5817 get properties() { 5818 return this.privSpeechConfig.properties; 5819 } 5820 /** 5821 * Gets the speech recognition language. 5822 * @member DialogServiceConfigImpl.prototype.speechRecognitionLanguage 5823 * @function 5824 * @public 5825 */ 5826 get speechRecognitionLanguage() { 5827 return this.privSpeechConfig.speechRecognitionLanguage; 5828 } 5829 /** 5830 * Sets the speech recognition language. 5831 * @member DialogServiceConfigImpl.prototype.speechRecognitionLanguage 5832 * @function 5833 * @public 5834 * @param {string} value - The language to set. 5835 */ 5836 set speechRecognitionLanguage(a) { 5837 t.Contracts.throwIfNullOrWhitespace(a, "value"), this.privSpeechConfig.speechRecognitionLanguage = a; 5838 } 5839 get outputFormat() { 5840 return this.privSpeechConfig.outputFormat; 5841 } 5842 set outputFormat(a) { 5843 this.privSpeechConfig.outputFormat = a; 5844 } 5845 /** 5846 * Sets a named property as value 5847 * @member DialogServiceConfigImpl.prototype.setProperty 5848 * @function 5849 * @public 5850 * @param {PropertyId | string} name - The property to set. 5851 * @param {string} value - The value. 5852 */ 5853 setProperty(a, n) { 5854 this.privSpeechConfig.setProperty(a, n); 5855 } 5856 /** 5857 * Sets a named property as value 5858 * @member DialogServiceConfigImpl.prototype.getProperty 5859 * @function 5860 * @public 5861 * @param {PropertyId | string} name - The property to get. 5862 * @param {string} def - The default value to return in case the property is not known. 5863 * @returns {string} The current value, or provided default, of the given property. 5864 */ 5865 getProperty(a, n) { 5866 return this.privSpeechConfig.getProperty(a); 5867 } 5868 /** 5869 * Sets the proxy configuration. 5870 * Only relevant in Node.js environments. 5871 * Added in version 1.4.0. 5872 * @param proxyHostName The host name of the proxy server, without the protocol scheme (http://) 5873 * @param proxyPort The port number of the proxy server. 5874 * @param proxyUserName The user name of the proxy server. 5875 * @param proxyPassword The password of the proxy server. 5876 */ 5877 setProxy(a, n, i, o) { 5878 this.setProperty(e.PropertyId.SpeechServiceConnection_ProxyHostName, a), this.setProperty(e.PropertyId.SpeechServiceConnection_ProxyPort, `${n}`), i && this.setProperty(e.PropertyId.SpeechServiceConnection_ProxyUserName, i), o && this.setProperty(e.PropertyId.SpeechServiceConnection_ProxyPassword, o); 5879 } 5880 setServiceProperty(a, n, i) { 5881 this.privSpeechConfig.setServiceProperty(a, n); 5882 } 5883 /**
5884 * Dispose of associated resources. 5885 * @member DialogServiceConfigImpl.prototype.close 5886 * @function 5887 * @public 5888 */ 5889 close() { 5890 } 5891 } 5892 return Me.DialogServiceConfigImpl = s, Me; 5893} 5894var Et = {}, Js; 5895function Zd() { 5896 if (Js) return Et; 5897 Js = 1, Object.defineProperty(Et, "__esModule", { value: !0 }), Et.BotFrameworkConfig = void 0; 5898 const t = O, e = Fn(), r = R(); 5899 let s = class extends e.DialogServiceConfigImpl { 5900 /** 5901 * Creates an instance of BotFrameworkConfig. 5902 */ 5903 constructor() { 5904 super(); 5905 } 5906 /** 5907 * Creates a bot framework configuration instance with the provided subscription information. 5908 * @member BotFrameworkConfig.fromSubscription 5909 * @function 5910 * @public 5911 * @param subscription Subscription key associated with the bot 5912 * @param region The region name (see the <a href="https://aka.ms/csspeech/region">region page</a>). 5913 * @param botId Optional. Identifier for using a specific bot within an Azure resource group. Equivalent to the 5914 * resource name. 5915 * @returns {BotFrameworkConfig} A new bot framework configuration instance. 5916 */ 5917 static fromSubscription(a, n, i) { 5918 t.Contracts.throwIfNullOrWhitespace(a, "subscription"), t.Contracts.throwIfNullOrWhitespace(n, "region"); 5919 const o = new e.DialogServiceConfigImpl(); 5920 return o.setProperty(r.PropertyId.Conversation_DialogType, e.DialogServiceConfig.DialogTypes.BotFramework), o.setProperty(r.PropertyId.SpeechServiceConnection_Key, a), o.setProperty(r.PropertyId.SpeechServiceConnection_Region, n), i && o.setProperty(r.PropertyId.Conversation_ApplicationId, i), o; 5921 } 5922 /** 5923 * Creates a bot framework configuration instance for the specified authorization token and region. 5924 * Note: The caller must ensure that an authorization token is valid. Before an authorization token expires, the 5925 * caller must refresh it by setting the authorizationToken property on the corresponding 5926 * DialogServiceConnector instance created with this config. The contents of configuration objects are copied 5927 * when connectors are created, so setting authorizationToken on a DialogServiceConnector will not update the 5928 * original configuration's authorization token. Create a new configuration instance or set the 5929 * SpeechServiceAuthorization_Token property to update an existing instance if it will be used to create 5930 * further DialogServiceConnectors. 5931 * @member BotFrameworkConfig.fromAuthorizationToken 5932 * @function 5933 * @public 5934 * @param authorizationToken The authorization token associated with the bot 5935 * @param region The region name (see the <a href="https://aka.ms/csspeech/region">region page</a>). 5936 * @param botId Optional. Identifier for using a specific bot within an Azure resource group. Equivalent to the 5937 * resource name. 5938 * @returns {BotFrameworkConfig} A new bot framework configuration instance. 5939 */ 5940 static fromAuthorizationToken(a, n, i) { 5941 t.Contracts.throwIfNullOrWhitespace(a, "authorizationToken"), t.Contracts.throwIfNullOrWhitespace(n, "region"); 5942 const o = new e.DialogServiceConfigImpl(); 5943 return o.setProperty(r.PropertyId.Conversation_DialogType, e.DialogServiceConfig.DialogTypes.BotFramework), o.setProperty(r.PropertyId.SpeechServiceAuthorization_Token, a), o.setProperty(r.PropertyId.SpeechServiceConnection_Region, n), i && o.setProperty(r.PropertyId.Conversation_ApplicationId, i), o; 5944 } 5945 /** 5946 * Creates an instance of a BotFrameworkConfig. 5947 * This method is intended only for users who use a non-default service host. The standard resource path will be 5948 * assumed. For services with a non-standard resource path or no path at all, use fromEndpoint instead. 5949 * Note: Query parameters are not allowed in the host URI and must be set by other APIs. 5950 * Note: To use an authorization token with fromHost, use fromHost(URL) and then set the AuthorizationToken 5951 * property on the created BotFrameworkConfig instance. 5952 * Note: Added in version 1.15.0. 5953 * @member BotFrameworkConfig.fromHost 5954 * @function 5955 * @public 5956 * @param {URL | string} host - If a URL is provided, the fully-qualified host with protocol (e.g. 5957 * wss://your.host.com:1234) will be used. If a string is provided, it will be embedded in 5958 * wss://{host}.convai.speech.azure.us. 5959 * @param {string} subscriptionKey - The subscription key. If a subscription key is not specified, an authorization 5960 * token must be set. 5961 * @param botId Optional. Identifier for using a specific bot within an Azure resource group. Equivalent to the 5962 * resource name. 5963 * @returns {BotFrameworkConfig} A new bot framework configuration instance. 5964 */ 5965 static fromHost(a, n, i) { 5966 t.Contracts.throwIfNullOrUndefined(a, "host"); 5967 const o = a instanceof URL ? a : new URL(`wss://${a}.convai.speech.azure.us`); 5968 t.Contracts.throwIfNullOrUndefined(o, "resolvedHost"); 5969 const c = new e.DialogServiceConfigImpl(); 5970 return c.setProperty(r.PropertyId.Conversation_DialogType, e.DialogServiceConfig.DialogTypes.BotFramework), c.setProperty(r.PropertyId.SpeechServiceConnection_Host, o.toString()), n !== void 0 && c.setProperty(r.PropertyId.SpeechServiceConnection_Key, n), c; 5971 } 5972 /** 5973 * Creates an instance of a BotFrameworkConfig. 5974 * This method is intended only for users who use a non-standard service endpoint or parameters. 5975 * Note: The query parameters specified in the endpoint URL are not changed, even if they are set by any other APIs. 5976 * Note: To use authorization token with fromEndpoint, pass an empty string to the subscriptionKey in the
5977 * fromEndpoint method, and then set authorizationToken="token" on the created BotFrameworkConfig instance to 5978 * use the authorization token. 5979 * Note: Added in version 1.15.0. 5980 * @member BotFrameworkConfig.fromEndpoint 5981 * @function 5982 * @public 5983 * @param {URL} endpoint - The service endpoint to connect to. 5984 * @param {string} subscriptionKey - The subscription key. If a subscription key is not specified, an authorization 5985 * token must be set. 5986 * @returns {BotFrameworkConfig} - A new bot framework configuration instance using the provided endpoint. 5987 */ 5988 static fromEndpoint(a, n) { 5989 t.Contracts.throwIfNull(a, "endpoint"); 5990 const i = new e.DialogServiceConfigImpl(); 5991 return i.setProperty(r.PropertyId.Conversation_DialogType, e.DialogServiceConfig.DialogTypes.BotFramework), i.setProperty(r.PropertyId.SpeechServiceConnection_Endpoint, a.toString()), n !== void 0 && i.setProperty(r.PropertyId.SpeechServiceConnection_Key, n), i; 5992 } 5993 }; 5994 return Et.BotFrameworkConfig = s, Et; 5995} 5996var Tt = {}, Vs; 5997function $d() { 5998 if (Vs) return Tt; 5999 Vs = 1, Object.defineProperty(Tt, "__esModule", { value: !0 }), Tt.CustomCommandsConfig = void 0; 6000 const t = O, e = Fn(), r = R(); 6001 let s = class extends e.DialogServiceConfigImpl { 6002 /** 6003 * Creates an instance of CustomCommandsConfig. 6004 */ 6005 constructor() { 6006 super(); 6007 } 6008 /** 6009 * Creates an instance of the bot framework config with the specified subscription and region. 6010 * @member CustomCommandsConfig.fromSubscription 6011 * @function 6012 * @public 6013 * @param applicationId Speech Commands application id. 6014 * @param subscription Subscription key associated with the bot 6015 * @param region The region name (see the <a href="https://aka.ms/csspeech/region">region page</a>). 6016 * @returns {CustomCommandsConfig} A new bot framework config. 6017 */ 6018 static fromSubscription(a, n, i) { 6019 t.Contracts.throwIfNullOrWhitespace(a, "applicationId"), t.Contracts.throwIfNullOrWhitespace(n, "subscription"), t.Contracts.throwIfNullOrWhitespace(i, "region"); 6020 const o = new e.DialogServiceConfigImpl(); 6021 return o.setProperty(r.PropertyId.Conversation_DialogType, e.DialogServiceConfig.DialogTypes.CustomCommands), o.setProperty(r.PropertyId.Conversation_ApplicationId, a), o.setProperty(r.PropertyId.SpeechServiceConnection_Key, n), o.setProperty(r.PropertyId.SpeechServiceConnection_Region, i), o; 6022 } 6023 /** 6024 * Creates an instance of the bot framework config with the specified Speech Commands application id, authorization token and region. 6025 * Note: The caller needs to ensure that the authorization token is valid. Before the authorization token 6026 * expires, the caller needs to refresh it by calling this setter with a new valid token. 6027 * As configuration values are copied when creating a new recognizer, the new token value will not apply to recognizers that have already been created. 6028 * For recognizers that have been created before, you need to set authorization token of the corresponding recognizer 6029 * to refresh the token. Otherwise, the recognizers will encounter errors during recognition. 6030 * @member CustomCommandsConfig.fromAuthorizationToken 6031 * @function 6032 * @public 6033 * @param applicationId Speech Commands application id. 6034 * @param authorizationToken The authorization token associated with the application. 6035 * @param region The region name (see the <a href="https://aka.ms/csspeech/region">region page</a>). 6036 * @returns {CustomCommandsConfig} A new speech commands config. 6037 */ 6038 static fromAuthorizationToken(a, n, i) { 6039 t.Contracts.throwIfNullOrWhitespace(a, "applicationId"), t.Contracts.throwIfNullOrWhitespace(n, "authorizationToken"), t.Contracts.throwIfNullOrWhitespace(i, "region"); 6040 const o = new e.DialogServiceConfigImpl(); 6041 return o.setProperty(r.PropertyId.Conversation_DialogType, e.DialogServiceConfig.DialogTypes.CustomCommands), o.setProperty(r.PropertyId.Conversation_ApplicationId, a), o.setProperty(r.PropertyId.SpeechServiceAuthorization_Token, n), o.setProperty(r.PropertyId.SpeechServiceConnection_Region, i), o; 6042 } 6043 /** 6044 * Sets the corresponding backend application identifier. 6045 * @member CustomCommandsConfig.prototype.Conversation_ApplicationId 6046 * @function 6047 * @public 6048 * @param {string} value - The application identifier to set. 6049 */ 6050 set applicationId(a) { 6051 t.Contracts.throwIfNullOrWhitespace(a, "value"), this.setProperty(r.PropertyId.Conversation_ApplicationId, a); 6052 } 6053 /** 6054 * Gets the corresponding backend application identifier. 6055 * @member CustomCommandsConfig.prototype.Conversation_ApplicationId 6056 * @function 6057 * @public 6058 * @param {string} value - The application identifier to get. 6059 */ 6060 get applicationId() { 6061 return this.getProperty(r.PropertyId.Conversation_ApplicationId); 6062 } 6063 }; 6064 return Tt.CustomCommandsConfig = s, Tt; 6065} 6066var At = {}, It = {}, wt = {}, pe = {}; 6067Object.defineProperty(pe, "__esModule", { value: !0 }); 6068pe.QueryParameterNames = void 0; 6069class j { 6070} 6071pe.QueryParameterNames = j; 6072j.BotId = "botid"; 6073j.CustomSpeechDeploymentId = "cid"; 6074j.CustomVoiceDeploymentId = "deploymentId"; 6075j.EnableAudioLogging = "storeAudio"; 6076j.EnableLanguageId = "lidEnabled"; 6077j.EnableWordLevelTimestamps = "wordLevelTimestamps"; 6078j.EndSilenceTimeoutMs = "endSilenceTimeoutMs"; 6079j.SegmentationSilenceTimeoutMs = "segmentationSilenceTimeoutMs"; 6080j.SegmentationMaximumTimeMs = "segmentationMaximumTimeMs"; 6081j.SegmentationStrategy = "segmentationStrategy"; 6082j.Format = "format"; 6083j.InitialSilenceTimeoutMs = "initialSilenceTimeoutMs"; 6084j.Language = "language"; 6085j.Profanity = "profanity"; 6086j.RequestBotStatusMessages = "enableBotMessageStatus"; 6087j.StableIntermediateThreshold = "stableIntermediateThreshold"; 6088j.StableTranslation = "stableTranslation"; 6089j.TestHooks = "testhooks"; 6090j.Postprocessing = "postprocessing"; 6091j.CtsMeetingId = "meetingId"; 6092j.CtsDeviceId = "deviceId"; 6093j.CtsIsParticipant = "isParticipant"; 6094j.EnableAvatar = "enableTalkingAvatar"; 6095var Gs; 6096function Se() { 6097 if (Gs) return wt; 6098 Gs = 1, Object.defineProperty(wt, "__esModule", { value: !0 }), wt.ConnectionFactoryBase = void 0;
6099 const t = A(), e = I(), r = R(), s = pe; 6100 let p = class { 6101 static getHostSuffix(n) { 6102 if (n) { 6103 if (n.toLowerCase().startsWith("china")) 6104 return ".azure.cn"; 6105 if (n.toLowerCase().startsWith("usgov")) 6106 return ".azure.us"; 6107 } 6108 return ".microsoft.com"; 6109 } 6110 setCommonUrlParams(n, i, o) { 6111 (/* @__PURE__ */ new Map([ 6112 [r.PropertyId.Speech_SegmentationSilenceTimeoutMs, s.QueryParameterNames.SegmentationSilenceTimeoutMs], 6113 [r.PropertyId.SpeechServiceConnection_EnableAudioLogging, s.QueryParameterNames.EnableAudioLogging], 6114 [r.PropertyId.SpeechServiceConnection_EndSilenceTimeoutMs, s.QueryParameterNames.EndSilenceTimeoutMs], 6115 [r.PropertyId.SpeechServiceConnection_InitialSilenceTimeoutMs, s.QueryParameterNames.InitialSilenceTimeoutMs], 6116 [r.PropertyId.SpeechServiceResponse_PostProcessingOption, s.QueryParameterNames.Postprocessing], 6117 [r.PropertyId.SpeechServiceResponse_ProfanityOption, s.QueryParameterNames.Profanity], 6118 [r.PropertyId.SpeechServiceResponse_RequestWordLevelTimestamps, s.QueryParameterNames.EnableWordLevelTimestamps], 6119 [r.PropertyId.SpeechServiceResponse_StablePartialResultThreshold, s.QueryParameterNames.StableIntermediateThreshold] 6120 ])).forEach((h, d) => { 6121 this.setUrlParameter(d, h, n, i, o); 6122 }); 6123 const u = JSON.parse(n.parameters.getProperty(t.ServicePropertiesPropertyName, "{}")); 6124 Object.keys(u).forEach((h) => { 6125 i[h] = u[h]; 6126 }); 6127 } 6128 setUrlParameter(n, i, o, c, u) { 6129 const h = o.parameters.getProperty(n, void 0); 6130 h && (!u || u.search(i) === -1) && (c[i] = h.toLocaleLowerCase()); 6131 } 6132 static async getRedirectUrlFromEndpoint(n) { 6133 const i = new URL(n); 6134 i.protocol = "https:", i.port = "443", i.searchParams.append("GenerateRedirectResponse", "true"); 6135 const c = i.toString(); 6136 e.Events.instance.onEvent(new e.ConnectionRedirectEvent("", c, void 0, "ConnectionFactoryBase: redirectUrl request")); 6137 const u = await fetch(c); 6138 if (u.status !== 200) 6139 return n; 6140 const h = await u.text(); 6141 e.Events.instance.onEvent(new e.ConnectionRedirectEvent("", h, n, "ConnectionFactoryBase: redirectUrlString")); 6142 try { 6143 return new URL(h.trim()).toString(); 6144 } catch { 6145 return n; 6146 } 6147 } 6148 }; 6149 return wt.ConnectionFactoryBase = p, wt; 6150} 6151var Qs; 6152function ev() { 6153 if (Qs) return It; 6154 Qs = 1, Object.defineProperty(It, "__esModule", { value: !0 }), It.DialogConnectionFactory = void 0; 6155 const t = re(), e = A(), r = R(), s = Se(), p = A(), a = Y, n = pe; 6156 class i extends s.ConnectionFactoryBase { 6157 create(c, u, h) { 6158 const d = c.parameters.getProperty(r.PropertyId.Conversation_ApplicationId, ""), v = c.parameters.getProperty(r.PropertyId.Conversation_DialogType), f = c.parameters.getProperty(r.PropertyId.SpeechServiceConnection_Region), m = c.parameters.getProperty(r.PropertyId.SpeechServiceConnection_RecoLanguage, "en-US"), S = c.parameters.getProperty(r.PropertyId.Conversation_Request_Bot_Status_Messages, "true"), l = {}; 6159 l[a.HeaderNames.ConnectionId] = h, l[n.QueryParameterNames.Format] = c.parameters.getProperty(e.OutputFormatPropertyName, r.OutputFormat[r.OutputFormat.Simple]).toLowerCase(), l[n.QueryParameterNames.Language] = m, l[n.QueryParameterNames.RequestBotStatusMessages] = S, d && (l[n.QueryParameterNames.BotId] = d, v === r.DialogServiceConfig.DialogTypes.CustomCommands && (l[a.HeaderNames.CustomCommandsAppId] = d)); 6160 const g = v === r.DialogServiceConfig.DialogTypes.CustomCommands ? "commands/" : "", C = v === r.DialogServiceConfig.DialogTypes.CustomCommands ? "v1" : v === r.DialogServiceConfig.DialogTypes.BotFramework ? "v3" : "v0", y = {}; 6161 u.token != null && u.token !== "" && (y[u.headerName] = u.token); 6162 let P = c.parameters.getProperty(r.PropertyId.SpeechServiceConnection_Endpoint, ""); 6163 if (!P) { 6164 const _ = s.ConnectionFactoryBase.getHostSuffix(f), E = c.parameters.getProperty(r.PropertyId.SpeechServiceConnection_Host, `wss://${f}.${i.BaseUrl}${_}`); 6165 P = `${E.endsWith("/") ? E : E + "/"}${g}${i.ApiKey}/${C}`; 6166 } 6167 this.setCommonUrlParams(c, l, P); 6168 const T = c.parameters.getProperty("SPEECH-EnableWebsocketCompression", "false") === "true"; 6169 return Promise.resolve(new t.WebsocketConnection(P, l, y, new p.WebsocketMessageFormatter(), t.ProxyInfo.fromRecognizerConfig(c), T, h)); 6170 } 6171 } 6172 return It.DialogConnectionFactory = i, i.ApiKey = "api", i.BaseUrl = "convai.speech", It; 6173} 6174var Xs; 6175function tv() { 6176 if (Xs) return At; 6177 Xs = 1, Object.defineProperty(At, "__esModule", { value: !0 }), At.DialogServiceConnector = void 0; 6178 const t = ev(), e = A(), r = ae, s = I(), p = O, a = R(), n = Ai; 6179 let i = class extends a.Recognizer { 6180 /** 6181 * Initializes an instance of the DialogServiceConnector. 6182 * @constructor 6183 * @param {DialogServiceConfig} dialogConfig - Set of properties to configure this recognizer. 6184 * @param {AudioConfig} audioConfig - An optional audio config associated with the recognizer 6185 */ 6186 constructor(c, u) { 6187 const h = c; 6188 p.Contracts.throwIfNull(c, "dialogConfig"), super(u, h.properties, new t.DialogConnectionFactory()), this.isTurnComplete = !0, this.privIsDisposed = !1, this.privProperties = h.properties.clone(); 6189 const d = this.buildAgentConfig(); 6190 this.privReco.agentConfig.set(d); 6191 } 6192 /** 6193 * Starts a connection to the service. 6194 * Users can optionally call connect() to manually set up a connection in advance, before starting interactions. 6195 * 6196 * Note: On return, the connection might not be ready yet. Please subscribe to the Connected event to 6197 * be notified when the connection is established.
6198 * @member DialogServiceConnector.prototype.connect 6199 * @function 6200 * @public 6201 */ 6202 connect(c, u) { 6203 (0, s.marshalPromiseToCallbacks)(this.privReco.connect(), c, u); 6204 } 6205 /** 6206 * Closes the connection the service. 6207 * Users can optionally call disconnect() to manually shutdown the connection of the associated DialogServiceConnector. 6208 * 6209 * If disconnect() is called during a recognition, recognition will fail and cancel with an error. 6210 */ 6211 disconnect(c, u) { 6212 (0, s.marshalPromiseToCallbacks)(this.privReco.disconnect(), c, u); 6213 } 6214 /** 6215 * Gets the authorization token used to communicate with the service. 6216 * @member DialogServiceConnector.prototype.authorizationToken 6217 * @function 6218 * @public 6219 * @returns {string} Authorization token. 6220 */ 6221 get authorizationToken() { 6222 return this.properties.getProperty(n.PropertyId.SpeechServiceAuthorization_Token); 6223 } 6224 /** 6225 * Sets the authorization token used to communicate with the service. 6226 * @member DialogServiceConnector.prototype.authorizationToken 6227 * @function 6228 * @public 6229 * @param {string} token - Authorization token. 6230 */ 6231 set authorizationToken(c) { 6232 p.Contracts.throwIfNullOrWhitespace(c, "token"), this.properties.setProperty(n.PropertyId.SpeechServiceAuthorization_Token, c); 6233 } 6234 /** 6235 * The collection of properties and their values defined for this DialogServiceConnector. 6236 * @member DialogServiceConnector.prototype.properties 6237 * @function 6238 * @public 6239 * @returns {PropertyCollection} The collection of properties and their values defined for this DialogServiceConnector. 6240 */ 6241 get properties() { 6242 return this.privProperties; 6243 } 6244 /** Gets the template for the activity generated by service from speech. 6245 * Properties from the template will be stamped on the generated activity. 6246 * It can be empty 6247 */ 6248 get speechActivityTemplate() { 6249 return this.properties.getProperty(n.PropertyId.Conversation_Speech_Activity_Template); 6250 } 6251 /** Sets the template for the activity generated by service from speech. 6252 * Properties from the template will be stamped on the generated activity. 6253 * It can be null or empty. 6254 * Note: it has to be a valid Json object. 6255 */ 6256 set speechActivityTemplate(c) { 6257 this.properties.setProperty(n.PropertyId.Conversation_Speech_Activity_Template, c); 6258 } 6259 /** 6260 * Starts recognition and stops after the first utterance is recognized. 6261 * @member DialogServiceConnector.prototype.listenOnceAsync 6262 * @function 6263 * @public 6264 * @param cb - Callback that received the result when the reco has completed. 6265 * @param err - Callback invoked in case of an error. 6266 */ 6267 listenOnceAsync(c, u) { 6268 if (this.isTurnComplete) { 6269 p.Contracts.throwIfDisposed(this.privIsDisposed); 6270 const d = (async () => { 6271 await this.privReco.connect(), await this.implRecognizerStop(), this.isTurnComplete = !1; 6272 const v = new s.Deferred(); 6273 await this.privReco.recognize(r.RecognitionMode.Conversation, v.resolve, v.reject); 6274 const f = await v.promise; 6275 return await this.implRecognizerStop(), f; 6276 })(); 6277 d.catch(() => { 6278 this.dispose(!0).catch(() => { 6279 }); 6280 }), (0, s.marshalPromiseToCallbacks)(d.finally(() => { 6281 this.isTurnComplete = !0; 6282 }), c, u); 6283 } 6284 } 6285 sendActivityAsync(c, u, h) { 6286 (0, s.marshalPromiseToCallbacks)(this.privReco.sendMessage(c), u, h); 6287 } 6288 /** 6289 * closes all external resources held by an instance of this class. 6290 * @member DialogServiceConnector.prototype.close 6291 * @function 6292 * @public 6293 */ 6294 close(c, u) { 6295 p.Contracts.throwIfDisposed(this.privIsDisposed), (0, s.marshalPromiseToCallbacks)(this.dispose(!0), c, u); 6296 } 6297 async dispose(c) { 6298 this.privIsDisposed || c && (this.privIsDisposed = !0, await this.implRecognizerStop(), await super.dispose(c)); 6299 } 6300 createRecognizerConfig(c) { 6301 return new e.RecognizerConfig(c, this.privProperties); 6302 } 6303 createServiceRecognizer(c, u, h, d) { 6304 const v = h; 6305 return new e.DialogServiceAdapter(c, u, v, d, this); 6306 } 6307 buildAgentConfig() { 6308 return { 6309 botInfo: { 6310 commType: this.properties.getProperty("Conversation_Communication_Type", "Default"), 6311 commandsCulture: void 0, 6312 connectionId: this.properties.getProperty(n.PropertyId.Conversation_Agent_Connection_Id), 6313 conversationId: this.properties.getProperty(n.PropertyId.Conversation_Conversation_Id, void 0), 6314 fromId: this.properties.getProperty(n.PropertyId.Conversation_From_Id, void 0), 6315 ttsAudioFormat: this.properties.getProperty(n.PropertyId.SpeechServiceConnection_SynthOutputFormat, void 0) 6316 }, 6317 version: 0.2 6318 }; 6319 } 6320 }; 6321 return At.DialogServiceConnector = i, At; 6322} 6323var _i = {}; 6324Object.defineProperty(_i, "__esModule", { value: !0 }); 6325_i.ActivityReceivedEventArgs = void 0; 6326class rv { 6327 /** 6328 * Creates and initializes an instance of this class. 6329 * @constructor 6330 * @param {any} activity - The activity.. 6331 */ 6332 constructor(e, r) { 6333 this.privActivity = e, this.privAudioStream = r; 6334 } 6335 /** 6336 * Gets the received activity 6337 * @member ActivityReceivedEventArgs.prototype.activity 6338 * @function 6339 * @public 6340 * @returns {any} the received activity. 6341 */ 6342 get activity() { 6343 return this.privActivity; 6344 } 6345 get audioStream() { 6346 return this.privAudioStream; 6347 } 6348} 6349_i.ActivityReceivedEventArgs = rv; 6350var bi = {}, Mi = {}; 6351Object.defineProperty(Mi, "__esModule", { value: !0 }); 6352Mi.TurnStatusResponsePayload = void 0; 6353class Un { 6354 constructor(e) {
6355 this.privMessageStatusResponse = JSON.parse(e); 6356 } 6357 static fromJSON(e) { 6358 return new Un(e); 6359 } 6360 get interactionId() { 6361 return this.privMessageStatusResponse.interactionId; 6362 } 6363 get conversationId() { 6364 return this.privMessageStatusResponse.conversationId; 6365 } 6366 get statusCode() { 6367 switch (this.privMessageStatusResponse.statusCode) { 6368 case "Success": 6369 return 200; 6370 case "Failed": 6371 return 400; 6372 case "TimedOut": 6373 return 429; 6374 default: 6375 return this.privMessageStatusResponse.statusCode; 6376 } 6377 } 6378} 6379Mi.TurnStatusResponsePayload = Un; 6380Object.defineProperty(bi, "__esModule", { value: !0 }); 6381bi.TurnStatusReceivedEventArgs = void 0; 6382const iv = Mi; 6383class nv { 6384 /** 6385 * Creates and initializes an instance of this class. 6386 * @constructor 6387 * @param {string} turnStatus - The JSON-encoded turn status message. 6388 */ 6389 constructor(e) { 6390 this.privTurnStatus = iv.TurnStatusResponsePayload.fromJSON(e); 6391 } 6392 /** 6393 * Gets the interaction identifier associated with this turn status event. 6394 * @member TurnStatusReceivedEventArgs.prototype.interactionId 6395 * @function 6396 * @public 6397 * @returns {any} the received interaction id. 6398 */ 6399 get interactionId() { 6400 return this.privTurnStatus.interactionId; 6401 } 6402 /** 6403 * Gets the conversation identifier associated with this turn status event. 6404 * @member TurnStatusReceivedEventArgs.prototype.conversationId 6405 * @function 6406 * @public 6407 * @returns {any} the received conversation id. 6408 */ 6409 get conversationId() { 6410 return this.privTurnStatus.conversationId; 6411 } 6412 /** 6413 * Gets the received turn status code. 6414 * @member TurnStatusReceivedEventArgs.prototype.statusCode 6415 * @function 6416 * @public 6417 * @returns {number} the received turn status. 6418 */ 6419 get statusCode() { 6420 return this.privTurnStatus.statusCode; 6421 } 6422} 6423bi.TurnStatusReceivedEventArgs = nv; 6424var pc = {}; 6425(function(t) { 6426 Object.defineProperty(t, "__esModule", { value: !0 }), t.ServicePropertyChannel = void 0, function(e) { 6427 e[e.UriQueryParameter = 0] = "UriQueryParameter"; 6428 }(t.ServicePropertyChannel || (t.ServicePropertyChannel = {})); 6429})(pc); 6430var uc = {}; 6431(function(t) { 6432 Object.defineProperty(t, "__esModule", { value: !0 }), t.ProfanityOption = void 0, function(e) { 6433 e[e.Masked = 0] = "Masked", e[e.Removed = 1] = "Removed", e[e.Raw = 2] = "Raw"; 6434 }(t.ProfanityOption || (t.ProfanityOption = {})); 6435})(uc); 6436var _t = {}, Ys; 6437function sv() { 6438 if (Ys) return _t; 6439 Ys = 1, Object.defineProperty(_t, "__esModule", { value: !0 }), _t.BaseAudioPlayer = void 0; 6440 const t = x, e = R(), r = Ae; 6441 let s = class { 6442 /** 6443 * Creates and initializes an instance of this class. 6444 * @constructor 6445 * @param {AudioStreamFormat} audioFormat audio stream format recognized by the player. 6446 */ 6447 constructor(a) { 6448 this.audioContext = null, this.gainNode = null, this.autoUpdateBufferTimer = 0, a === void 0 && (a = e.AudioStreamFormat.getDefaultInputFormat()), this.init(a); 6449 } 6450 /** 6451 * play Audio sample 6452 * @param newAudioData audio data to be played. 6453 */ 6454 playAudioSample(a, n, i) { 6455 try { 6456 this.ensureInitializedContext(); 6457 const o = this.formatAudioData(a), c = new Float32Array(this.samples.length + o.length); 6458 c.set(this.samples, 0), c.set(o, this.samples.length), this.samples = c, n && n(); 6459 } catch (o) { 6460 i && i(o); 6461 } 6462 } 6463 /** 6464 * stops audio and clears the buffers 6465 */ 6466 stopAudio(a, n) { 6467 this.audioContext !== null && (this.samples = new Float32Array(), clearInterval(this.autoUpdateBufferTimer), this.audioContext.close().then(() => { 6468 a && a(); 6469 }, (i) => { 6470 n && n(i); 6471 }), this.audioContext = null); 6472 } 6473 init(a) { 6474 this.audioFormat = a, this.samples = new Float32Array(); 6475 } 6476 ensureInitializedContext() { 6477 if (this.audioContext === null) { 6478 this.createAudioContext(); 6479 const a = 200; 6480 this.autoUpdateBufferTimer = setInterval(() => { 6481 this.updateAudioBuffer(); 6482 }, a); 6483 } 6484 } 6485 createAudioContext() { 6486 this.audioContext = r.AudioStreamFormatImpl.getAudioContext(), this.gainNode = this.audioContext.createGain(), this.gainNode.gain.value = 1, this.gainNode.connect(this.audioContext.destination), this.startTime = this.audioContext.currentTime; 6487 } 6488 formatAudioData(a) { 6489 switch (this.audioFormat.bitsPerSample) { 6490 case 8: 6491 return this.formatArrayBuffer(new Int8Array(a), 128); 6492 case 16: 6493 return this.formatArrayBuffer(new Int16Array(a), 32768); 6494 case 32: 6495 return this.formatArrayBuffer(new Int32Array(a), 2147483648); 6496 default: 6497 throw new t.InvalidOperationError("Only WAVE_FORMAT_PCM (8/16/32 bps) format supported at this time"); 6498 } 6499 } 6500 formatArrayBuffer(a, n) { 6501 const i = new Float32Array(a.length); 6502 for (let o = 0; o < a.length; o++) 6503 i[o] = a[o] / n; 6504 return i; 6505 } 6506 updateAudioBuffer() { 6507 if (this.samples.length === 0) 6508 return; 6509 const a = this.audioFormat.channels, n = this.audioContext.createBufferSource(), i = this.samples.length / a, o = this.audioContext.createBuffer(a, i, this.audioFormat.samplesPerSec); 6510 for (let c = 0; c < a; c++) { 6511 let u = c; 6512 const h = o.getChannelData(c); 6513 for (let d = 0; d < this.samples.length; d++, u += a) 6514 h[d] = this.samples[u]; 6515 } 6516 this.startTime < this.audioContext.currentTime && (this.startTime = this.audioContext.currentTime), n.buffer = o, n.connect(this.gainNode), n.start(this.startTime), this.startTime += o.duration, this.samples = new Float32Array(); 6517 } 6518 async playAudio(a) { 6519 this.audioContext === null && this.createAudioContext(); 6520 const n = this.audioContext.createBufferSource(), i = this.audioContext.destination; 6521 await this.audioContext.decodeAudioData(a, (o) => { 6522 n.buffer = o, n.connect(i), n.start(0); 6523 }); 6524 } 6525 }; 6526 return _t.BaseAudioPlayer = s, _t; 6527} 6528var Oi = {}; 6529Object.defineProperty(Oi, "__esModule", { value: !0 }); 6530Oi.ConnectionMessageEventArgs = void 0; 6531class ov { 6532 constructor(e) { 6533 this.privConnectionMessage = e; 6534 } 6535 /** 6536 * Gets the <see cref="ConnectionMessage"/> associated with this <see cref="ConnectionMessageEventArgs"/>. 6537 */ 6538 get message() { 6539 return this.privConnectionMessage; 6540 } 6541 /** 6542 * Returns a string that represents the connection message event. 6543 */ 6544 toString() { 6545 return "Message: " + this.privConnectionMessage.toString(); 6546 } 6547} 6548Oi.ConnectionMessageEventArgs = ov; 6549var bt = {}, xn = {}; 6550(function(t) { 6551 Object.defineProperty(t, "__esModule", { value: !0 }), t.LanguageIdMode = void 0, function(e) { 6552 e[e.AtStart = 0] = "AtStart", e[e.Continuous = 1] = "Continuous"; 6553 }(t.LanguageIdMode || (t.LanguageIdMode = {})); 6554})(xn); 6555var Zs; 6556function av() { 6557 if (Zs) return bt;
6558 Zs = 1, Object.defineProperty(bt, "__esModule", { value: !0 }), bt.AutoDetectSourceLanguageConfig = void 0; 6559 const t = A(), e = O, r = R(), s = xn; 6560 let p = class Wr { 6561 constructor() { 6562 this.privProperties = new r.PropertyCollection(), this.privProperties.setProperty(r.PropertyId.SpeechServiceConnection_LanguageIdMode, "AtStart"), this.privLanguageIdMode = s.LanguageIdMode.AtStart; 6563 } 6564 /** 6565 * @member AutoDetectSourceLanguageConfig.fromOpenRange 6566 * @function 6567 * @public 6568 * Only [[SpeechSynthesizer]] supports source language auto detection from open range, 6569 * for [[Recognizer]], please use AutoDetectSourceLanguageConfig with specific source languages. 6570 * @return {AutoDetectSourceLanguageConfig} Instance of AutoDetectSourceLanguageConfig 6571 * @summary Creates an instance of the AutoDetectSourceLanguageConfig with open range. 6572 */ 6573 static fromOpenRange() { 6574 const n = new Wr(); 6575 return n.properties.setProperty(r.PropertyId.SpeechServiceConnection_AutoDetectSourceLanguages, t.AutoDetectSourceLanguagesOpenRangeOptionName), n.properties.setProperty(r.PropertyId.SpeechServiceConnection_RecoLanguage, "en-US"), n; 6576 } 6577 /** 6578 * @member AutoDetectSourceLanguageConfig.fromLanguages 6579 * @function 6580 * @public 6581 * @param {string[]} languages Comma-separated string of languages (eg. "en-US,fr-FR") to populate properties of config. 6582 * @return {AutoDetectSourceLanguageConfig} Instance of AutoDetectSourceLanguageConfig 6583 * @summary Creates an instance of the AutoDetectSourceLanguageConfig with given languages. 6584 */ 6585 static fromLanguages(n) { 6586 e.Contracts.throwIfArrayEmptyOrWhitespace(n, "languages"); 6587 const i = new Wr(); 6588 return i.properties.setProperty(r.PropertyId.SpeechServiceConnection_AutoDetectSourceLanguages, n.join()), i; 6589 } 6590 /** 6591 * @member AutoDetectSourceLanguageConfig.fromSourceLanguageConfigs 6592 * @function 6593 * @public 6594 * @param {SourceLanguageConfig[]} configs SourceLanguageConfigs to populate properties of config. 6595 * @return {AutoDetectSourceLanguageConfig} Instance of AutoDetectSourceLanguageConfig 6596 * @summary Creates an instance of the AutoDetectSourceLanguageConfig with given SourceLanguageConfigs. 6597 */ 6598 static fromSourceLanguageConfigs(n) { 6599 if (n.length < 1) 6600 throw new Error("Expected non-empty SourceLanguageConfig array."); 6601 const i = new Wr(), o = []; 6602 return n.forEach((c) => { 6603 if (o.push(c.language), c.endpointId !== void 0 && c.endpointId !== "") { 6604 const u = c.language + r.PropertyId.SpeechServiceConnection_EndpointId.toString(); 6605 i.properties.setProperty(u, c.endpointId); 6606 } 6607 }), i.properties.setProperty(r.PropertyId.SpeechServiceConnection_AutoDetectSourceLanguages, o.join()), i; 6608 } 6609 /** 6610 * @member AutoDetectSourceLanguageConfig.prototype.properties 6611 * @function 6612 * @public 6613 * @return {PropertyCollection} Properties of the config. 6614 * @summary Gets an auto detected language config properties 6615 */ 6616 get properties() { 6617 return this.privProperties; 6618 } 6619 /** 6620 * @member AutoDetectSourceLanguageConfig.prototype.mode 6621 * @function 6622 * @public 6623 * @param {LanguageIdMode} mode LID mode desired. 6624 * @summary Sets LID operation to desired mode 6625 */ 6626 set mode(n) { 6627 n === s.LanguageIdMode.Continuous ? (this.privProperties.setProperty(r.PropertyId.SpeechServiceConnection_RecognitionEndpointVersion, "2"), this.privProperties.setProperty(r.PropertyId.SpeechServiceConnection_LanguageIdMode, "Continuous")) : (this.privProperties.setProperty(r.PropertyId.SpeechServiceConnection_RecognitionEndpointVersion, "1"), this.privProperties.setProperty(r.PropertyId.SpeechServiceConnection_LanguageIdMode, "AtStart")), this.privLanguageIdMode = n; 6628 } 6629 }; 6630 return bt.AutoDetectSourceLanguageConfig = p, bt; 6631} 6632var Di = {}; 6633Object.defineProperty(Di, "__esModule", { value: !0 }); 6634Di.AutoDetectSourceLanguageResult = void 0; 6635const $s = O; 6636class Hr { 6637 constructor(e, r) { 6638 $s.Contracts.throwIfNullOrUndefined(e, "language"), $s.Contracts.throwIfNullOrUndefined(r, "languageDetectionConfidence"), this.privLanguage = e, this.privLanguageDetectionConfidence = r; 6639 } 6640 /** 6641 * Creates an instance of AutoDetectSourceLanguageResult object from a SpeechRecognitionResult instance. 6642 * @member AutoDetectSourceLanguageResult.fromResult 6643 * @function 6644 * @public 6645 * @param {SpeechRecognitionResult} result - The recognition result. 6646 * @returns {AutoDetectSourceLanguageResult} AutoDetectSourceLanguageResult object being created. 6647 */ 6648 static fromResult(e) { 6649 return new Hr(e.language, e.languageDetectionConfidence); 6650 } 6651 /** 6652 * Creates an instance of AutoDetectSourceLanguageResult object from a ConversationTranscriptionResult instance. 6653 * @member AutoDetectSourceLanguageResult.fromConversationTranscriptionResult 6654 * @function 6655 * @public 6656 * @param {ConversationTranscriptionResult} result - The transcription result. 6657 * @returns {AutoDetectSourceLanguageResult} AutoDetectSourceLanguageResult object being created. 6658 */ 6659 static fromConversationTranscriptionResult(e) { 6660 return new Hr(e.language, e.languageDetectionConfidence); 6661 } 6662 get language() { 6663 return this.privLanguage; 6664 } 6665 get languageDetectionConfidence() { 6666 return this.privLanguageDetectionConfidence; 6667 } 6668} 6669Di.AutoDetectSourceLanguageResult = Hr; 6670var ki = {}; 6671Object.defineProperty(ki, "__esModule", { value: !0 }); 6672ki.SourceLanguageConfig = void 0; 6673const cv = O;
6674class Wn { 6675 constructor(e, r) { 6676 cv.Contracts.throwIfNullOrUndefined(e, "language"), this.privLanguage = e, this.privEndpointId = r; 6677 } 6678 /** 6679 * @member SourceLanguageConfig.fromLanguage 6680 * @function 6681 * @public 6682 * @param {string} language language (eg. "en-US") value of config. 6683 * @param {string?} endpointId endpointId of model bound to given language of config. 6684 * @return {SourceLanguageConfig} Instance of SourceLanguageConfig 6685 * @summary Creates an instance of the SourceLanguageConfig with the given language and optional endpointId. 6686 * Added in version 1.13.0. 6687 */ 6688 static fromLanguage(e, r) { 6689 return new Wn(e, r); 6690 } 6691 get language() { 6692 return this.privLanguage; 6693 } 6694 get endpointId() { 6695 return this.privEndpointId; 6696 } 6697} 6698ki.SourceLanguageConfig = Wn; 6699var Cn = {}, Oe = {}, eo; 6700function hc() { 6701 if (eo) return Oe; 6702 eo = 1, Object.defineProperty(Oe, "__esModule", { value: !0 }), Oe.ConversationImpl = Oe.Conversation = void 0; 6703 const t = A(), e = I(), r = O, s = R(); 6704 let p = class { 6705 constructor() { 6706 } 6707 /** 6708 * Create a conversation 6709 * @param speechConfig 6710 * @param cb 6711 * @param err 6712 */ 6713 static createConversationAsync(i, o, c, u) { 6714 r.Contracts.throwIfNullOrUndefined(i, t.ConversationConnectionConfig.restErrors.invalidArgs.replace("{arg}", "config")), r.Contracts.throwIfNullOrUndefined(i.region, t.ConversationConnectionConfig.restErrors.invalidArgs.replace("{arg}", "SpeechServiceConnection_Region")), !i.subscriptionKey && !i.getProperty(s.PropertyId[s.PropertyId.SpeechServiceAuthorization_Token]) && r.Contracts.throwIfNullOrUndefined(i.subscriptionKey, t.ConversationConnectionConfig.restErrors.invalidArgs.replace("{arg}", "SpeechServiceConnection_Key")); 6715 let h, d, v; 6716 return typeof o == "string" ? (h = new a(i, o), (0, e.marshalPromiseToCallbacks)((async () => { 6717 })(), c, u)) : (h = new a(i), d = o, v = c, h.createConversationAsync(() => { 6718 d && d(); 6719 }, (f) => { 6720 v && v(f); 6721 })), h; 6722 } 6723 }; 6724 Oe.Conversation = p; 6725 class a extends p { 6726 /** 6727 * Create a conversation impl 6728 * @param speechConfig 6729 * @param {string} id - optional conversationId 6730 */ 6731 constructor(i, o) { 6732 if (super(), this.privErrors = t.ConversationConnectionConfig.restErrors, this.onConnected = (h) => { 6733 var d; 6734 this.privIsConnected = !0; 6735 try { 6736 (d = this.privConversationTranslator) != null && d.sessionStarted && this.privConversationTranslator.sessionStarted(this.privConversationTranslator, h); 6737 } catch { 6738 } 6739 }, this.onDisconnected = (h) => { 6740 var d; 6741 try { 6742 (d = this.privConversationTranslator) != null && d.sessionStopped && this.privConversationTranslator.sessionStopped(this.privConversationTranslator, h); 6743 } catch { 6744 } finally { 6745 this.close(!1); 6746 } 6747 }, this.onCanceled = (h, d) => { 6748 var v; 6749 try { 6750 (v = this.privConversationTranslator) != null && v.canceled && this.privConversationTranslator.canceled(this.privConversationTranslator, d); 6751 } catch { 6752 } 6753 }, this.onParticipantUpdateCommandReceived = (h, d) => { 6754 try { 6755 const v = this.privParticipants.getParticipant(d.id); 6756 if (v !== void 0) { 6757 switch (d.key) { 6758 case t.ConversationTranslatorCommandTypes.changeNickname: 6759 v.displayName = d.value; 6760 break; 6761 case t.ConversationTranslatorCommandTypes.setUseTTS: 6762 v.isUsingTts = d.value; 6763 break; 6764 case t.ConversationTranslatorCommandTypes.setProfanityFiltering: 6765 v.profanity = d.value; 6766 break; 6767 case t.ConversationTranslatorCommandTypes.setMute: 6768 v.isMuted = d.value; 6769 break; 6770 case t.ConversationTranslatorCommandTypes.setTranslateToLanguages: 6771 v.translateToLanguages = d.value; 6772 break; 6773 } 6774 this.privParticipants.addOrUpdateParticipant(v), this.privConversationTranslator && this.privConversationTranslator.participantsChanged(this.privConversationTranslator, new s.ConversationParticipantsChangedEventArgs(s.ParticipantChangedReason.Updated, [this.toParticipant(v)], d.sessionId)); 6775 } 6776 } catch { 6777 } 6778 }, this.onLockRoomCommandReceived = () => { 6779 }, this.onMuteAllCommandReceived = (h, d) => { 6780 try {
6781 this.privParticipants.participants.forEach((v) => v.isMuted = v.isHost ? !1 : d.isMuted), this.privConversationTranslator && this.privConversationTranslator.participantsChanged(this.privConversationTranslator, new s.ConversationParticipantsChangedEventArgs(s.ParticipantChangedReason.Updated, this.toParticipants(!1), d.sessionId)); 6782 } catch { 6783 } 6784 }, this.onParticipantJoinCommandReceived = (h, d) => { 6785 try { 6786 const v = this.privParticipants.addOrUpdateParticipant(d.participant); 6787 v !== void 0 && this.privConversationTranslator && this.privConversationTranslator.participantsChanged(this.privConversationTranslator, new s.ConversationParticipantsChangedEventArgs(s.ParticipantChangedReason.JoinedConversation, [this.toParticipant(v)], d.sessionId)); 6788 } catch { 6789 } 6790 }, this.onParticipantLeaveCommandReceived = (h, d) => { 6791 try { 6792 const v = this.privParticipants.getParticipant(d.participant.id); 6793 v !== void 0 && (this.privParticipants.deleteParticipant(d.participant.id), this.privConversationTranslator && this.privConversationTranslator.participantsChanged(this.privConversationTranslator, new s.ConversationParticipantsChangedEventArgs(s.ParticipantChangedReason.LeftConversation, [this.toParticipant(v)], d.sessionId))); 6794 } catch { 6795 } 6796 }, this.onTranslationReceived = (h, d) => { 6797 try { 6798 switch (d.command) { 6799 case t.ConversationTranslatorMessageTypes.final: 6800 this.privConversationTranslator && this.privConversationTranslator.transcribed(this.privConversationTranslator, new s.ConversationTranslationEventArgs(d.payload, void 0, d.sessionId)); 6801 break; 6802 case t.ConversationTranslatorMessageTypes.partial: 6803 this.privConversationTranslator && this.privConversationTranslator.transcribing(this.privConversationTranslator, new s.ConversationTranslationEventArgs(d.payload, void 0, d.sessionId)); 6804 break; 6805 case t.ConversationTranslatorMessageTypes.instantMessage: 6806 this.privConversationTranslator && this.privConversationTranslator.textMessageReceived(this.privConversationTranslator, new s.ConversationTranslationEventArgs(d.payload, void 0, d.sessionId)); 6807 break; 6808 } 6809 } catch { 6810 } 6811 }, this.onParticipantsListReceived = (h, d) => { 6812 var v; 6813 try { 6814 if (d.sessionToken !== void 0 && d.sessionToken !== null && (this.privRoom.token = d.sessionToken), this.privParticipants.participants = [...d.participants], this.privParticipants.me !== void 0 && (this.privIsReady = !0), this.privConversationTranslator && this.privConversationTranslator.participantsChanged(this.privConversationTranslator, new s.ConversationParticipantsChangedEventArgs(s.ParticipantChangedReason.JoinedConversation, this.toParticipants(!0), d.sessionId)), this.me.isHost) { 6815 const f = (v = this.privConversationTranslator) == null ? void 0 : v.properties.getProperty(s.PropertyId.ConversationTranslator_Name); 6816 f !== void 0 && f.length > 0 && f !== this.me.displayName && this.changeNicknameAsync(f); 6817 } 6818 } catch { 6819 } 6820 }, this.onConversationExpiration = (h, d) => { 6821 try { 6822 this.privConversationTranslator && this.privConversationTranslator.conversationExpiration(this.privConversationTranslator, d); 6823 } catch { 6824 } 6825 }, this.privIsConnected = !1, this.privIsDisposed = !1, this.privConversationId = "", this.privProperties = new s.PropertyCollection(), this.privManager = new t.ConversationManager(), i.getProperty(s.PropertyId[s.PropertyId.SpeechServiceConnection_RecoLanguage]) || i.setProperty(s.PropertyId[s.PropertyId.SpeechServiceConnection_RecoLanguage], t.ConversationConnectionConfig.defaultLanguageCode), this.privLanguage = i.getProperty(s.PropertyId[s.PropertyId.SpeechServiceConnection_RecoLanguage]), o) 6826 this.privConversationId = o; 6827 else { 6828 i.targetLanguages.length === 0 && i.addTargetLanguage(this.privLanguage), i.getProperty(s.PropertyId[s.PropertyId.SpeechServiceResponse_ProfanityOption]) || i.setProfanity(s.ProfanityOption.Masked); 6829 let d = i.getProperty(s.PropertyId[s.PropertyId.ConversationTranslator_Name]); 6830 d == null && (d = "Host"), r.Contracts.throwIfNullOrTooLong(d, "nickname", 50), r.Contracts.throwIfNullOrTooShort(d, "nickname", 2), i.setProperty(s.PropertyId[s.PropertyId.ConversationTranslator_Name], d); 6831 } 6832 this.privConfig = i; 6833 const u = i; 6834 r.Contracts.throwIfNull(u, "speechConfig"), this.privProperties = u.properties.clone(), this.privIsConnected = !1, this.privParticipants = new t.InternalParticipants(), this.privIsReady = !1, this.privTextMessageMaxLength = 1e3; 6835 } 6836 // get the internal data about a conversation 6837 get room() { 6838 return this.privRoom; 6839 } 6840 // get the wrapper for connecting to the websockets 6841 get connection() { 6842 return this.privConversationRecognizer; 6843 } 6844 // get the config 6845 get config() { 6846 return this.privConfig; 6847 } 6848 // get the conversation Id 6849 get conversationId() { 6850 return this.privRoom ? this.privRoom.roomId : this.privConversationId; 6851 } 6852 // get the properties 6853 get properties() { 6854 return this.privProperties; 6855 } 6856 // get the speech language 6857 get speechRecognitionLanguage() { 6858 return this.privLanguage; 6859 } 6860 get isMutedByHost() { 6861 var i, o; 6862 return (i = this.privParticipants.me) != null && i.isHost ? !1 : (o = this.privParticipants.me) == null ? void 0 : o.isMuted; 6863 } 6864 get isConnected() { 6865 return this.privIsConnected && this.privIsReady; 6866 } 6867 get participants() { 6868 return this.toParticipants(!0); 6869 } 6870 get me() { 6871 return this.toParticipant(this.privParticipants.me); 6872 } 6873 get host() { 6874 return this.toParticipant(this.privParticipants.host); 6875 } 6876 get transcriberRecognizer() { 6877 return this.privTranscriberRecognizer; 6878 } 6879 get conversationInfo() { 6880 const i = this.conversationId, o = this.participants.map((h) => ({ 6881 id: h.id, 6882 preferredLanguage: h.preferredLanguage, 6883 voice: h.voice 6884 })), c = {}; 6885 for (const h of t.ConversationConnectionConfig.transcriptionEventKeys) { 6886 const d = this.properties.getProperty(h, ""); 6887 d !== "" && (c[h] = d); 6888 } 6889 return { id: i, participants: o, conversationProperties: c }; 6890 } 6891 get canSend() { 6892 var i; 6893 return this.privIsConnected && !((i = this.privParticipants.me) != null && i.isMuted); 6894 } 6895 get canSendAsHost() { 6896 var i; 6897 return this.privIsConnected && ((i = this.privParticipants.me) == null ? void 0 : i.isHost); 6898 } 6899 // get / set the speech auth token 6900 // eslint-disable-next-line @typescript-eslint/member-ordering 6901 get authorizationToken() { 6902 return this.privToken; 6903 } 6904 set authorizationToken(i) { 6905 r.Contracts.throwIfNullOrWhitespace(i, "authorizationToken"), this.privToken = i; 6906 } 6907 set conversationTranslator(i) { 6908 this.privConversationTranslator = i; 6909 } 6910 onToken(i) { 6911 this.privConversationTranslator.onToken(i); 6912 } 6913 /** 6914 * Create a new conversation as Host 6915 * @param cb 6916 * @param err 6917 */ 6918 createConversationAsync(i, o) {
6919 try { 6920 this.privConversationRecognizer && this.handleError(new Error(this.privErrors.permissionDeniedStart), o), this.privManager.createOrJoin(this.privProperties, void 0, (c) => { 6921 c || this.handleError(new Error(this.privErrors.permissionDeniedConnect), o), this.privRoom = c, this.handleCallback(i, o); 6922 }, (c) => { 6923 this.handleError(c, o); 6924 }); 6925 } catch (c) { 6926 this.handleError(c, o); 6927 } 6928 } 6929 /** 6930 * Starts a new conversation as host. 6931 * @param cb 6932 * @param err 6933 */ 6934 startConversationAsync(i, o) { 6935 try { 6936 this.privConversationRecognizer && this.handleError(new Error(this.privErrors.permissionDeniedStart), o), r.Contracts.throwIfNullOrUndefined(this.privRoom, this.privErrors.permissionDeniedConnect), this.privParticipants.meId = this.privRoom.participantId, this.privConversationRecognizer = t.ConversationRecognizerFactory.fromConfig(this, this.privConfig), this.privConversationRecognizer.connected = this.onConnected, this.privConversationRecognizer.disconnected = this.onDisconnected, this.privConversationRecognizer.canceled = this.onCanceled, this.privConversationRecognizer.participantUpdateCommandReceived = this.onParticipantUpdateCommandReceived, this.privConversationRecognizer.lockRoomCommandReceived = this.onLockRoomCommandReceived, this.privConversationRecognizer.muteAllCommandReceived = this.onMuteAllCommandReceived, this.privConversationRecognizer.participantJoinCommandReceived = this.onParticipantJoinCommandReceived, this.privConversationRecognizer.participantLeaveCommandReceived = this.onParticipantLeaveCommandReceived, this.privConversationRecognizer.translationReceived = this.onTranslationReceived, this.privConversationRecognizer.participantsListReceived = this.onParticipantsListReceived, this.privConversationRecognizer.conversationExpiration = this.onConversationExpiration, this.privConversationRecognizer.connect(this.privRoom.token, () => { 6937 this.handleCallback(i, o); 6938 }, (c) => { 6939 this.handleError(c, o); 6940 }); 6941 } catch (c) { 6942 this.handleError(c, o); 6943 } 6944 } 6945 /** 6946 * Join a conversation as a participant. 6947 * @param { IParticipant } participant - participant to add 6948 * @param cb 6949 * @param err 6950 */ 6951 addParticipantAsync(i, o, c) { 6952 r.Contracts.throwIfNullOrUndefined(i, "Participant"), (0, e.marshalPromiseToCallbacks)(this.addParticipantImplAsync(i), o, c); 6953 } 6954 /** 6955 * Join a conversation as a participant. 6956 * @param conversation 6957 * @param nickname 6958 * @param lang 6959 * @param cb 6960 * @param err 6961 */ 6962 joinConversationAsync(i, o, c, u, h) { 6963 try { 6964 r.Contracts.throwIfNullOrWhitespace(i, this.privErrors.invalidArgs.replace("{arg}", "conversationId")), r.Contracts.throwIfNullOrWhitespace(o, this.privErrors.invalidArgs.replace("{arg}", "nickname")), r.Contracts.throwIfNullOrWhitespace(c, this.privErrors.invalidArgs.replace("{arg}", "language")), this.privManager.createOrJoin(this.privProperties, i, (d) => { 6965 r.Contracts.throwIfNullOrUndefined(d, this.privErrors.permissionDeniedConnect), this.privRoom = d, this.privConfig.authorizationToken = d.cognitiveSpeechAuthToken, u && u(d.cognitiveSpeechAuthToken); 6966 }, (d) => { 6967 this.handleError(d, h); 6968 }); 6969 } catch (d) { 6970 this.handleError(d, h); 6971 } 6972 } 6973 /** 6974 * Deletes a conversation 6975 * @param cb 6976 * @param err 6977 */ 6978 deleteConversationAsync(i, o) { 6979 (0, e.marshalPromiseToCallbacks)(this.deleteConversationImplAsync(), i, o); 6980 } 6981 async deleteConversationImplAsync() { 6982 r.Contracts.throwIfNullOrUndefined(this.privProperties, this.privErrors.permissionDeniedConnect), r.Contracts.throwIfNullOrWhitespace(this.privRoom.token, this.privErrors.permissionDeniedConnect), await this.privManager.leave(this.privProperties, this.privRoom.token), this.dispose(); 6983 } 6984 /** 6985 * Issues a request to close the client websockets 6986 * @param cb 6987 * @param err 6988 */ 6989 endConversationAsync(i, o) { 6990 (0, e.marshalPromiseToCallbacks)(this.endConversationImplAsync(), i, o); 6991 } 6992 endConversationImplAsync() { 6993 return this.close(!0); 6994 } 6995 /** 6996 * Issues a request to lock the conversation 6997 * @param cb 6998 * @param err 6999 */ 7000 lockConversationAsync(i, o) {
7001 try { 7002 r.Contracts.throwIfDisposed(this.privIsDisposed), r.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()), r.Contracts.throwIfNullOrUndefined(this.privRoom, this.privErrors.permissionDeniedSend), this.canSendAsHost || this.handleError(new Error(this.privErrors.permissionDeniedConversation.replace("{command}", "lock")), o), this.privConversationRecognizer && this.privConversationRecognizer.sendRequest(this.getLockCommand(!0), () => { 7003 this.handleCallback(i, o); 7004 }, (c) => { 7005 this.handleError(c, o); 7006 }); 7007 } catch (c) { 7008 this.handleError(c, o); 7009 } 7010 } 7011 /** 7012 * Issues a request to mute the conversation 7013 * @param cb 7014 * @param err 7015 */ 7016 muteAllParticipantsAsync(i, o) { 7017 try { 7018 r.Contracts.throwIfDisposed(this.privIsDisposed), r.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()), r.Contracts.throwIfNullOrUndefined(this.privConversationRecognizer, this.privErrors.permissionDeniedSend), r.Contracts.throwIfNullOrUndefined(this.privRoom, this.privErrors.permissionDeniedSend), this.canSendAsHost || this.handleError(new Error(this.privErrors.permissionDeniedConversation.replace("{command}", "mute")), o), this.privConversationRecognizer && this.privConversationRecognizer.sendRequest(this.getMuteAllCommand(!0), () => { 7019 this.handleCallback(i, o); 7020 }, (c) => { 7021 this.handleError(c, o); 7022 }); 7023 } catch (c) { 7024 this.handleError(c, o); 7025 } 7026 } 7027 /** 7028 * Issues a request to mute a participant in the conversation 7029 * @param userId 7030 * @param cb 7031 * @param err 7032 */ 7033 muteParticipantAsync(i, o, c) { 7034 try { 7035 r.Contracts.throwIfDisposed(this.privIsDisposed), r.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()), r.Contracts.throwIfNullOrWhitespace(i, this.privErrors.invalidArgs.replace("{arg}", "userId")), r.Contracts.throwIfNullOrUndefined(this.privRoom, this.privErrors.permissionDeniedSend), this.canSend || this.handleError(new Error(this.privErrors.permissionDeniedSend), c), !this.me.isHost && this.me.id !== i && this.handleError(new Error(this.privErrors.permissionDeniedParticipant.replace("{command}", "mute")), c), this.privParticipants.getParticipantIndex(i) === -1 && this.handleError(new Error(this.privErrors.invalidParticipantRequest), c), this.privConversationRecognizer && this.privConversationRecognizer.sendRequest(this.getMuteCommand(i, !0), () => { 7036 this.handleCallback(o, c); 7037 }, (h) => { 7038 this.handleError(h, c); 7039 }); 7040 } catch (u) { 7041 this.handleError(u, c); 7042 } 7043 } 7044 /** 7045 * Issues a request to remove a participant from the conversation 7046 * @param userId 7047 * @param cb 7048 * @param err 7049 */ 7050 removeParticipantAsync(i, o, c) { 7051 try { 7052 if (r.Contracts.throwIfDisposed(this.privIsDisposed), this.privTranscriberRecognizer && i.hasOwnProperty("id")) 7053 (0, e.marshalPromiseToCallbacks)(this.removeParticipantImplAsync(i), o, c); 7054 else { 7055 r.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()), r.Contracts.throwIfNullOrUndefined(this.privRoom, this.privErrors.permissionDeniedSend), this.canSendAsHost || this.handleError(new Error(this.privErrors.permissionDeniedParticipant.replace("{command}", "remove")), c); 7056 let u = ""; 7057 typeof i == "string" ? u = i : i.hasOwnProperty("id") ? u = i.id : i.hasOwnProperty("userId") && (u = i.userId), r.Contracts.throwIfNullOrWhitespace(u, this.privErrors.invalidArgs.replace("{arg}", "userId")), this.participants.findIndex((d) => d.id === u) === -1 && this.handleError(new Error(this.privErrors.invalidParticipantRequest), c), this.privConversationRecognizer && this.privConversationRecognizer.sendRequest(this.getEjectCommand(u), () => { 7058 this.handleCallback(o, c); 7059 }, (d) => { 7060 this.handleError(d, c); 7061 }); 7062 } 7063 } catch (u) { 7064 this.handleError(u, c); 7065 } 7066 } 7067 /** 7068 * Issues a request to unlock the conversation 7069 * @param cb 7070 * @param err 7071 */ 7072 unlockConversationAsync(i, o) {
7073 try { 7074 r.Contracts.throwIfDisposed(this.privIsDisposed), r.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()), r.Contracts.throwIfNullOrUndefined(this.privRoom, this.privErrors.permissionDeniedSend), this.canSendAsHost || this.handleError(new Error(this.privErrors.permissionDeniedConversation.replace("{command}", "unlock")), o), this.privConversationRecognizer && this.privConversationRecognizer.sendRequest(this.getLockCommand(!1), () => { 7075 this.handleCallback(i, o); 7076 }, (c) => { 7077 this.handleError(c, o); 7078 }); 7079 } catch (c) { 7080 this.handleError(c, o); 7081 } 7082 } 7083 /** 7084 * Issues a request to unmute all participants in the conversation 7085 * @param cb 7086 * @param err 7087 */ 7088 unmuteAllParticipantsAsync(i, o) { 7089 try { 7090 r.Contracts.throwIfDisposed(this.privIsDisposed), r.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()), r.Contracts.throwIfNullOrUndefined(this.privRoom, this.privErrors.permissionDeniedSend), this.canSendAsHost || this.handleError(new Error(this.privErrors.permissionDeniedConversation.replace("{command}", "unmute all")), o), this.privConversationRecognizer && this.privConversationRecognizer.sendRequest(this.getMuteAllCommand(!1), () => { 7091 this.handleCallback(i, o); 7092 }, (c) => { 7093 this.handleError(c, o); 7094 }); 7095 } catch (c) { 7096 this.handleError(c, o); 7097 } 7098 } 7099 /** 7100 * Issues a request to unmute a participant in the conversation 7101 * @param userId 7102 * @param cb 7103 * @param err 7104 */ 7105 unmuteParticipantAsync(i, o, c) { 7106 try { 7107 r.Contracts.throwIfDisposed(this.privIsDisposed), r.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()), r.Contracts.throwIfNullOrWhitespace(i, this.privErrors.invalidArgs.replace("{arg}", "userId")), r.Contracts.throwIfNullOrUndefined(this.privRoom, this.privErrors.permissionDeniedSend), this.canSend || this.handleError(new Error(this.privErrors.permissionDeniedSend), c), !this.me.isHost && this.me.id !== i && this.handleError(new Error(this.privErrors.permissionDeniedParticipant.replace("{command}", "mute")), c), this.privParticipants.getParticipantIndex(i) === -1 && this.handleError(new Error(this.privErrors.invalidParticipantRequest), c), this.privConversationRecognizer && this.privConversationRecognizer.sendRequest(this.getMuteCommand(i, !1), () => { 7108 this.handleCallback(o, c); 7109 }, (h) => { 7110 this.handleError(h, c); 7111 }); 7112 } catch (u) { 7113 this.handleError(u, c); 7114 } 7115 } 7116 /** 7117 * Send a text message 7118 * @param message 7119 * @param cb 7120 * @param err 7121 */ 7122 sendTextMessageAsync(i, o, c) { 7123 try { 7124 r.Contracts.throwIfDisposed(this.privIsDisposed), r.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()), r.Contracts.throwIfNullOrWhitespace(i, this.privErrors.invalidArgs.replace("{arg}", "message")), r.Contracts.throwIfNullOrUndefined(this.privRoom, this.privErrors.permissionDeniedSend), this.canSend || this.handleError(new Error(this.privErrors.permissionDeniedSend), c), i.length > this.privTextMessageMaxLength && this.handleError(new Error(this.privErrors.invalidArgs.replace("{arg}", "message length")), c), this.privConversationRecognizer && this.privConversationRecognizer.sendRequest(this.getMessageCommand(i), () => { 7125 this.handleCallback(o, c); 7126 }, (u) => { 7127 this.handleError(u, c); 7128 }); 7129 } catch (u) { 7130 this.handleError(u, c); 7131 } 7132 } 7133 /** 7134 * Set translated to languages 7135 * @param {string[]} languages - languages to translate to 7136 * @param cb 7137 * @param err 7138 */ 7139 setTranslatedLanguagesAsync(i, o, c) { 7140 try { 7141 r.Contracts.throwIfDisposed(this.privIsDisposed), r.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()), r.Contracts.throwIfArrayEmptyOrWhitespace(i, this.privErrors.invalidArgs.replace("{arg}", "languages")), r.Contracts.throwIfNullOrUndefined(this.privRoom, this.privErrors.permissionDeniedSend), this.canSend || this.handleError(new Error(this.privErrors.permissionDeniedSend), c), this.privConversationRecognizer && this.privConversationRecognizer.sendRequest(this.getSetTranslateToLanguagesCommand(i), () => { 7142 this.handleCallback(o, c); 7143 }, (u) => { 7144 this.handleError(u, c); 7145 }); 7146 } catch (u) { 7147 this.handleError(u, c); 7148 } 7149 } 7150 /** 7151 * Change nickname 7152 * @param {string} nickname - new nickname for the room 7153 * @param cb 7154 * @param err 7155 */ 7156 changeNicknameAsync(i, o, c) {
7157 try { 7158 r.Contracts.throwIfDisposed(this.privIsDisposed), r.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()), r.Contracts.throwIfNullOrWhitespace(i, this.privErrors.invalidArgs.replace("{arg}", "nickname")), r.Contracts.throwIfNullOrUndefined(this.privRoom, this.privErrors.permissionDeniedSend), this.canSend || this.handleError(new Error(this.privErrors.permissionDeniedSend), c), this.privConversationRecognizer && this.privConversationRecognizer.sendRequest(this.getChangeNicknameCommand(i), () => { 7159 this.handleCallback(o, c); 7160 }, (u) => { 7161 this.handleError(u, c); 7162 }); 7163 } catch (u) { 7164 this.handleError(u, c); 7165 } 7166 } 7167 isDisposed() { 7168 return this.privIsDisposed; 7169 } 7170 dispose() { 7171 this.isDisposed || (this.privIsDisposed = !0, this.config && this.config.close(), this.privConfig = void 0, this.privLanguage = void 0, this.privProperties = void 0, this.privRoom = void 0, this.privToken = void 0, this.privManager = void 0, this.privIsConnected = !1, this.privIsReady = !1, this.privParticipants = void 0); 7172 } 7173 async connectTranscriberRecognizer(i) { 7174 this.privTranscriberRecognizer && await this.privTranscriberRecognizer.close(), await i.enforceAudioGating(), this.privTranscriberRecognizer = i, this.privTranscriberRecognizer.conversation = this; 7175 } 7176 getKeepAlive() { 7177 const i = this.me ? this.me.displayName : "default_nickname"; 7178 return JSON.stringify({ 7179 id: "0", 7180 nickname: i, 7181 participantId: this.privRoom.participantId, 7182 roomId: this.privRoom.roomId, 7183 type: t.ConversationTranslatorMessageTypes.keepAlive 7184 }); 7185 } 7186 /* eslint-enable @typescript-eslint/typedef */ 7187 addParticipantImplAsync(i) { 7188 if (this.privParticipants.addOrUpdateParticipant(i) !== void 0 && this.privTranscriberRecognizer) { 7189 const c = this.conversationInfo; 7190 return c.participants = [i], this.privTranscriberRecognizer.pushConversationEvent(c, "join"); 7191 } 7192 } 7193 removeParticipantImplAsync(i) { 7194 this.privParticipants.deleteParticipant(i.id); 7195 const o = this.conversationInfo; 7196 return o.participants = [i], this.privTranscriberRecognizer.pushConversationEvent(o, "leave"); 7197 } 7198 async close(i) { 7199 var o;
7200 try { 7201 this.privIsConnected = !1, await ((o = this.privConversationRecognizer) == null ? void 0 : o.close()), this.privConversationRecognizer = void 0, this.privConversationTranslator && this.privConversationTranslator.dispose(); 7202 } catch (c) { 7203 throw c; 7204 } 7205 i && this.dispose(); 7206 } 7207 /** Helpers */ 7208 handleCallback(i, o) { 7209 if (i) { 7210 try { 7211 i(); 7212 } catch (c) { 7213 o && o(c); 7214 } 7215 i = void 0; 7216 } 7217 } 7218 handleError(i, o) { 7219 if (o) 7220 if (i instanceof Error) { 7221 const c = i; 7222 o(c.name + ": " + c.message); 7223 } else 7224 o(i); 7225 } 7226 /** Participant Helpers */ 7227 toParticipants(i) { 7228 const o = this.privParticipants.participants.map((c) => this.toParticipant(c)); 7229 return i ? o : o.filter((c) => c.isHost === !1); 7230 } 7231 toParticipant(i) { 7232 return new s.Participant(i.id, i.avatar, i.displayName, i.isHost, i.isMuted, i.isUsingTts, i.preferredLanguage, i.voice); 7233 } 7234 getMuteAllCommand(i) { 7235 return r.Contracts.throwIfNullOrWhitespace(this.privRoom.roomId, "conversationId"), r.Contracts.throwIfNullOrWhitespace(this.privRoom.participantId, "participantId"), JSON.stringify({ 7236 command: t.ConversationTranslatorCommandTypes.setMuteAll, 7237 participantId: this.privRoom.participantId, 7238 roomid: this.privRoom.roomId, 7239 type: t.ConversationTranslatorMessageTypes.participantCommand, 7240 value: i 7241 }); 7242 } 7243 getMuteCommand(i, o) { 7244 return r.Contracts.throwIfNullOrWhitespace(this.privRoom.roomId, "conversationId"), r.Contracts.throwIfNullOrWhitespace(i, "participantId"), JSON.stringify({ 7245 command: t.ConversationTranslatorCommandTypes.setMute, 7246 // eslint-disable-next-line object-shorthand 7247 participantId: i, 7248 roomid: this.privRoom.roomId, 7249 type: t.ConversationTranslatorMessageTypes.participantCommand, 7250 value: o 7251 }); 7252 } 7253 getLockCommand(i) { 7254 return r.Contracts.throwIfNullOrWhitespace(this.privRoom.roomId, "conversationId"), r.Contracts.throwIfNullOrWhitespace(this.privRoom.participantId, "participantId"), JSON.stringify({ 7255 command: t.ConversationTranslatorCommandTypes.setLockState, 7256 participantId: this.privRoom.participantId, 7257 roomid: this.privRoom.roomId, 7258 type: t.ConversationTranslatorMessageTypes.participantCommand, 7259 value: i 7260 }); 7261 } 7262 getEjectCommand(i) { 7263 return r.Contracts.throwIfNullOrWhitespace(this.privRoom.roomId, "conversationId"), r.Contracts.throwIfNullOrWhitespace(i, "participantId"), JSON.stringify({ 7264 command: t.ConversationTranslatorCommandTypes.ejectParticipant, 7265 // eslint-disable-next-line object-shorthand 7266 participantId: i, 7267 roomid: this.privRoom.roomId, 7268 type: t.ConversationTranslatorMessageTypes.participantCommand 7269 }); 7270 } 7271 getSetTranslateToLanguagesCommand(i) { 7272 return r.Contracts.throwIfNullOrWhitespace(this.privRoom.roomId, "conversationId"), r.Contracts.throwIfNullOrWhitespace(this.privRoom.participantId, "participantId"), JSON.stringify({ 7273 command: t.ConversationTranslatorCommandTypes.setTranslateToLanguages, 7274 participantId: this.privRoom.participantId, 7275 roomid: this.privRoom.roomId, 7276 type: t.ConversationTranslatorMessageTypes.participantCommand, 7277 value: i 7278 }); 7279 } 7280 getChangeNicknameCommand(i) { 7281 return r.Contracts.throwIfNullOrWhitespace(this.privRoom.roomId, "conversationId"), r.Contracts.throwIfNullOrWhitespace(i, "nickname"), r.Contracts.throwIfNullOrWhitespace(this.privRoom.participantId, "participantId"), JSON.stringify({ 7282 command: t.ConversationTranslatorCommandTypes.changeNickname, 7283 nickname: i, 7284 participantId: this.privRoom.participantId, 7285 roomid: this.privRoom.roomId, 7286 type: t.ConversationTranslatorMessageTypes.participantCommand, 7287 value: i 7288 }); 7289 } 7290 getMessageCommand(i) { 7291 return r.Contracts.throwIfNullOrWhitespace(this.privRoom.roomId, "conversationId"), r.Contracts.throwIfNullOrWhitespace(this.privRoom.participantId, "participantId"), r.Contracts.throwIfNullOrWhitespace(i, "message"), JSON.stringify({ 7292 participantId: this.privRoom.participantId, 7293 roomId: this.privRoom.roomId, 7294 text: i, 7295 type: t.ConversationTranslatorMessageTypes.instantMessage 7296 }); 7297 } 7298 } 7299 return Oe.ConversationImpl = a, Oe; 7300} 7301var Ni = {}; 7302Object.defineProperty(Ni, "__esModule", { value: !0 }); 7303Ni.ConversationCommon = void 0; 7304class pv {
7305 constructor(e) { 7306 this.privAudioConfig = e; 7307 } 7308 handleCallback(e, r) { 7309 if (e) { 7310 try { 7311 e(); 7312 } catch (s) { 7313 r && r(s); 7314 } 7315 e = void 0; 7316 } 7317 } 7318 handleError(e, r) { 7319 if (r) 7320 if (e instanceof Error) { 7321 const s = e; 7322 r(s.name + ": " + s.message); 7323 } else 7324 r(e); 7325 } 7326} 7327Ni.ConversationCommon = pv; 7328var Mt = {}, to; 7329function uv() { 7330 if (to) return Mt; 7331 to = 1, Object.defineProperty(Mt, "__esModule", { value: !0 }), Mt.ConversationExpirationEventArgs = void 0; 7332 const t = R(); 7333 let e = class extends t.SessionEventArgs { 7334 constructor(s, p) { 7335 super(p), this.privExpirationTime = s; 7336 } 7337 /** How much longer until the conversation expires (in minutes). */ 7338 get expirationTime() { 7339 return this.privExpirationTime; 7340 } 7341 }; 7342 return Mt.ConversationExpirationEventArgs = e, Mt; 7343} 7344var Ot = {}, ro; 7345function hv() { 7346 if (ro) return Ot; 7347 ro = 1, Object.defineProperty(Ot, "__esModule", { value: !0 }), Ot.ConversationParticipantsChangedEventArgs = void 0; 7348 const t = R(); 7349 let e = class extends t.SessionEventArgs { 7350 constructor(s, p, a) { 7351 super(a), this.privReason = s, this.privParticipant = p; 7352 } 7353 get reason() { 7354 return this.privReason; 7355 } 7356 get participants() { 7357 return this.privParticipant; 7358 } 7359 }; 7360 return Ot.ConversationParticipantsChangedEventArgs = e, Ot; 7361} 7362var Dt = {}, io; 7363function dv() { 7364 if (io) return Dt; 7365 io = 1, Object.defineProperty(Dt, "__esModule", { value: !0 }), Dt.ConversationTranslationCanceledEventArgs = void 0; 7366 const t = zr(); 7367 let e = class extends t.CancellationEventArgsBase { 7368 }; 7369 return Dt.ConversationTranslationCanceledEventArgs = e, Dt; 7370} 7371var kt = {}, no; 7372function vv() { 7373 if (no) return kt; 7374 no = 1, Object.defineProperty(kt, "__esModule", { value: !0 }), kt.ConversationTranslationEventArgs = void 0; 7375 const t = R(); 7376 let e = class extends t.RecognitionEventArgs { 7377 /** 7378 * Creates and initializes an instance of this class. 7379 * @constructor 7380 * @param {ConversationTranslationResult} result - The translation recognition result. 7381 * @param {number} offset - The offset. 7382 * @param {string} sessionId - The session id. 7383 */ 7384 constructor(s, p, a) { 7385 super(p, a), this.privResult = s; 7386 } 7387 /** 7388 * Specifies the recognition result. 7389 * @returns {ConversationTranslationResult} the recognition result. 7390 */ 7391 get result() { 7392 return this.privResult; 7393 } 7394 }; 7395 return kt.ConversationTranslationEventArgs = e, kt; 7396} 7397var Nt = {}, so; 7398function lv() { 7399 if (so) return Nt; 7400 so = 1, Object.defineProperty(Nt, "__esModule", { value: !0 }), Nt.ConversationTranslationResult = void 0; 7401 const t = Xa(); 7402 let e = class extends t.TranslationRecognitionResult { 7403 constructor(s, p, a, n, i, o, c, u, h, d, v) { 7404 super(p, n, i, o, c, u, void 0, void 0, h, d, v), this.privId = s, this.privOrigLang = a; 7405 } 7406 /** 7407 * The unique identifier for the participant this result is for. 7408 */ 7409 get participantId() { 7410 return this.privId; 7411 } 7412 /** 7413 * The original language this result was in. 7414 */ 7415 get originalLang() { 7416 return this.privOrigLang; 7417 } 7418 }; 7419 return Nt.ConversationTranslationResult = e, Nt; 7420} 7421var yn = {}, zt = {}, Lr = {}; 7422Object.defineProperty(Lr, "__esModule", { value: !0 }); 7423Lr.StringUtils = void 0; 7424class fv { 7425 /** 7426 * Formats a string by replacing the named {keys} in the string with the values contained in the replacement dictionary. 7427 * @param format The format string that contains the parts to replace surrounded by {}. For example: "wss://{region}.cts.speech.microsoft.com". 7428 * If your string needs to contain a { or } you can use the {{ and }} escape sequences respectively. 7429 * @param replacements The dictionary of replacements. If a replacement is not found, it is replaced with an empty string 7430 * @returns The formatted string. If you pass in a null or undefined format string, an empty string will be returned 7431 */ 7432 static formatString(e, r) { 7433 if (!e) 7434 return ""; 7435 if (!r) 7436 return e; 7437 let s = "", p = ""; 7438 const a = (o) => { 7439 s += o; 7440 }, n = (o) => { 7441 p += o; 7442 }; 7443 let i = a; 7444 for (let o = 0; o < e.length; o++) { 7445 const c = e[o], u = o + 1 < e.length ? e[o + 1] : ""; 7446 switch (c) { 7447 case "{": 7448 u === "{" ? (i("{"), o++) : i = n; 7449 break; 7450 case "}": 7451 u === "}" ? (i("}"), o++) : (r.hasOwnProperty(p) && (s += r[p]), i = a, p = ""); 7452 break; 7453 default: 7454 i(c); 7455 break; 7456 } 7457 } 7458 return s; 7459 } 7460} 7461Lr.StringUtils = fv; 7462var oo;
7463function gv() { 7464 if (oo) return zt; 7465 oo = 1, Object.defineProperty(zt, "__esModule", { value: !0 }), zt.ConversationTranslatorConnectionFactory = void 0; 7466 const t = re(), e = Lr, r = O, s = R(), p = Y, a = pe, n = Se(), i = A(); 7467 let o = class dc extends n.ConnectionFactoryBase { 7468 constructor(u) { 7469 super(), r.Contracts.throwIfNullOrUndefined(u, "convGetter"), this.privConvGetter = u; 7470 } 7471 create(u, h, d) { 7472 const v = u.parameters.getProperty("ConversationTranslator_MultiChannelAudio", "").toUpperCase() === "TRUE", f = this.privConvGetter().room, m = f.cognitiveSpeechRegion || u.parameters.getProperty(s.PropertyId.SpeechServiceConnection_Region, ""), S = { 7473 hostSuffix: n.ConnectionFactoryBase.getHostSuffix(m), 7474 path: dc.CTS_VIRT_MIC_PATH, 7475 region: encodeURIComponent(m) 7476 }; 7477 S[a.QueryParameterNames.Language] = encodeURIComponent(u.parameters.getProperty(s.PropertyId.SpeechServiceConnection_RecoLanguage, "")), S[a.QueryParameterNames.CtsMeetingId] = encodeURIComponent(f.roomId), S[a.QueryParameterNames.CtsDeviceId] = encodeURIComponent(f.participantId), S[a.QueryParameterNames.CtsIsParticipant]
7477= f.isHost ? "" : "&" + a.QueryParameterNames.CtsIsParticipant; 7478 let l = ""; 7479 const g = {}, C = {}; 7480 if (v) { 7481 l = u.parameters.getProperty(s.PropertyId.SpeechServiceConnection_Endpoint), l || (l = "wss://" + u.parameters.getProperty(s.PropertyId.SpeechServiceConnection_Host, "transcribe.{region}.cts.speech{hostSuffix}") + "{path}"), l = e.StringUtils.formatString(l, S); 7482 const P = new URL(l); 7483 P.searchParams.forEach((_, E) => { 7484 g[E] = _; 7485 }), new i.TranscriberConnectionFactory().setQueryParams(g, u, l), g[a.QueryParameterNames.CtsMeetingId] = S[a.QueryParameterNames.CtsMeetingId], g[a.QueryParameterNames.CtsDeviceId] = S[a.QueryParameterNames.CtsDeviceId], f.isHost || (g[a.QueryParameterNames.CtsIsParticipant] = ""), a.QueryParameterNames.Format in g || (g[a.QueryParameterNames.Format] = "simple"), P.searchParams.forEach((_, E) => { 7486 P.searchParams.set(E, g[E]), delete g[E]; 7487 }), l = P.toString(); 7488 } else { 7489 const P = new i.TranslationConnectionFactory(); 7490 l = P.getEndpointUrl(u, !0), l = e.StringUtils.formatString(l, S), P.setQueryParams(g, u, l); 7491 } 7492 C[p.HeaderNames.ConnectionId] = d, C[t.RestConfigBase.configParams.token] = f.token, h.token && (C[h.headerName] = h.token); 7493 const y = u.parameters.getProperty("SPEECH-EnableWebsocketCompression", "").toUpperCase() === "TRUE"; 7494 return Promise.resolve(new t.WebsocketConnection(l, g, C, new i.WebsocketMessageFormatter(), t.ProxyInfo.fromRecognizerConfig(u), y, d)); 7495 } 7496 }; 7497 return zt.ConversationTranslatorConnectionFactory = o, o.CTS_VIRT_MIC_PATH = "/speech/recognition/dynamicaudio", zt; 7498} 7499var ao; 7500function mv() { 7501 return ao || (ao = 1, function(t) { 7502 Object.defineProperty(t, "__esModule", { value: !0 }), t.ConversationTranslator = t.SpeechState = void 0; 7503 const e = A(), r = gv(), s = I(), p = O, a = R(), n = hc(), i = Hn(); 7504 var o; 7505 (function(h) { 7506 h[h.Inactive = 0] = "Inactive", h[h.Connecting = 1] = "Connecting", h[h.Connected = 2] = "Connected"; 7507 })(o = t.SpeechState || (t.SpeechState = {})); 7508 class c extends a.TranslationRecognizer { 7509 constructor(d, v, f, m) { 7510 super(d, v, new r.ConversationTranslatorConnectionFactory(m)), this.privSpeechState = o.Inactive, f && (this.privTranslator = f, this.sessionStarted = () => { 7511 this.privSpeechState = o.Connected; 7512 }, this.sessionStopped = () => { 7513 this.privSpeechState = o.Inactive; 7514 }, this.recognizing = (S, l) => { 7515 this.privTranslator.recognizing && this.privTranslator.recognizing(this.privTranslator, l); 7516 }, this.recognized = async (S, l) => { 7517 var g; 7518 (g = l.result) != null && g.errorDetails ? (await this.cancelSpeech(), this.fireCancelEvent(l.result.errorDetails)) : this.privTranslator.recognized && this.privTranslator.recognized(this.privTranslator, l); 7519 }, this.canceled = async () => { 7520 if (this.privSpeechState !== o.Inactive) 7521 try { 7522 await this.cancelSpeech(); 7523 } catch { 7524 this.privSpeechState = o.Inactive; 7525 } 7526 }); 7527 } 7528 get state() { 7529 return this.privSpeechState; 7530 } 7531 set state(d) { 7532 this.privSpeechState = d; 7533 } 7534 set authentication(d) { 7535 this.privReco.authentication = d; 7536 } 7537 onConnection() { 7538 this.privSpeechState = o.Connected; 7539 } 7540 async onCancelSpeech() { 7541 this.privSpeechState = o.Inactive, await this.cancelSpeech(); 7542 } 7543 /** 7544 * Fire a cancel event 7545 * @param error 7546 */ 7547 fireCancelEvent(d) { 7548 try { 7549 if (this.privTranslator.canceled) { 7550 const v = new i.ConversationTranslationCanceledEventArgs(a.CancellationReason.Error, d, a.CancellationErrorCode.RuntimeError); 7551 this.privTranslator.canceled(this.privTranslator, v); 7552 } 7553 } catch { 7554 } 7555 } 7556 async cancelSpeech() { 7557 var d; 7558 try { 7559 this.stopContinuousRecognitionAsync(), await ((d = this.privReco) == null ? void 0 : d.disconnect()), this.privSpeechState = o.Inactive; 7560 } catch { 7561 } 7562 } 7563 } 7564 class u extends i.ConversationCommon { 7565 constructor(d) { 7566 super(d), this.privErrors = e.ConversationConnectionConfig.restErrors, this.privIsDisposed = !1, this.privIsSpeaking = !1, this.privPlaceholderKey = "abcdefghijklmnopqrstuvwxyz012345", this.privPlaceholderRegion = "westus", this.privProperties = new a.PropertyCollection(); 7567 } 7568 get properties() { 7569 return this.privProperties; 7570 } 7571 get speechRecognitionLanguage() { 7572 return this.privSpeechRecognitionLanguage; 7573 } 7574 get participants() { 7575 var d; 7576 return (d = this.privConversation) == null ? void 0 : d.participants; 7577 } 7578 get canSpeak() { 7579 return !(!this.privConversation.isConnected || !this.privCTRecognizer || this.privIsSpeaking || this.privCTRecognizer.state === o.Connected || this.privCTRecognizer.state === o.Connecting || this.privConversation.isMutedByHost); 7580 } 7581 onToken(d) { 7582 this.privCTRecognizer.authentication = d; 7583 } 7584 setServiceProperty(d, v) {
7585 const f = JSON.parse(this.privProperties.getProperty(e.ServicePropertiesPropertyName, "{}")); 7586 f[d] = v, this.privProperties.setProperty(e.ServicePropertiesPropertyName, JSON.stringify(f)); 7587 } 7588 joinConversationAsync(d, v, f, m, S) { 7589 try { 7590 if (typeof d == "string") { 7591 p.Contracts.throwIfNullOrUndefined(d, this.privErrors.invalidArgs.replace("{arg}", "conversation id")), p.Contracts.throwIfNullOrWhitespace(v, this.privErrors.invalidArgs.replace("{arg}", "nickname")), this.privConversation && this.handleError(new Error(this.privErrors.permissionDeniedStart), S); 7592 let l = f; 7593 (l == null || l === "") && (l = e.ConversationConnectionConfig.defaultLanguageCode), this.privSpeechTranslationConfig = a.SpeechTranslationConfig.fromSubscription(this.privPlaceholderKey, this.privPlaceholderRegion), this.privSpeechTranslationConfig.setProfanity(a.ProfanityOption.Masked), this.privSpeechTranslationConfig.addTargetLanguage(l), this.privSpeechTranslationConfig.setProperty(a.PropertyId[a.PropertyId.SpeechServiceConnection_RecoLanguage], l), this.privSpeechTranslationConfig.setProperty(a.PropertyId[a.PropertyId.ConversationTranslator_Name], v); 7594 const g = [ 7595 a.PropertyId.SpeechServiceConnection_Host, 7596 a.PropertyId.ConversationTranslator_Host, 7597 a.PropertyId.SpeechServiceConnection_Endpoint, 7598 a.PropertyId.SpeechServiceConnection_ProxyHostName, 7599 a.PropertyId.SpeechServiceConnection_ProxyPassword, 7600 a.PropertyId.SpeechServiceConnection_ProxyPort, 7601 a.PropertyId.SpeechServiceConnection_ProxyUserName, 7602 "ConversationTranslator_MultiChannelAudio", 7603 "ConversationTranslator_Region" 7604 ]; 7605 for (const y of g) { 7606 const P = this.privProperties.getProperty(y); 7607 if (P) { 7608 const T = typeof y == "string" ? y : a.PropertyId[y]; 7609 this.privSpeechTranslationConfig.setProperty(T, P); 7610 } 7611 } 7612 const C = JSON.parse(this.privProperties.getProperty(e.ServicePropertiesPropertyName, "{}")); 7613 for (const y of Object.keys(C)) 7614 this.privSpeechTranslationConfig.setServiceProperty(y, C[y], a.ServicePropertyChannel.UriQueryParameter); 7615 this.privConversation = new n.ConversationImpl(this.privSpeechTranslationConfig), this.privConversation.conversationTranslator = this, this.privConversation.joinConversationAsync(d, v, l, (y) => { 7616 y || this.handleError(new Error(this.privErrors.permissionDeniedConnect), S), this.privSpeechTranslationConfig.authorizationToken = y, this.privConversation.room.isHost = !1, this.privConversation.startConversationAsync(() => { 7617 this.handleCallback(m, S); 7618 }, (P) => { 7619 this.handleError(P, S); 7620 }); 7621 }, (y) => { 7622 this.handleError(y, S); 7623 }); 7624 } else typeof d == "object" ? (p.Contracts.throwIfNullOrUndefined(d, this.privErrors.invalidArgs.replace("{arg}", "conversation id")), p.Contracts.throwIfNullOrWhitespace(v, this.privErrors.invalidArgs.replace("{arg}", "nickname")), this.privProperties.setProperty(a.PropertyId.ConversationTranslator_Name, v), this.privConversation = d, this.privConversation.conversationTranslator = this, this.privConversation.room.isHost = !0, p.Contracts.throwIfNullOrUndefined(this.privConversation, this.privErrors.permissionDeniedConnect), p.Contracts.throwIfNullOrUndefined(this.privConversation.room.token, this.privErrors.permissionDeniedConnect), this.privSpeechTranslationConfig = d.config, this.handleCallback(f, m)) : this.handleError(new Error(this.privErrors.invalidArgs.replace("{arg}", "invalid conversation type")), m); 7625 } catch (l) { 7626 this.handleError(l, typeof f == "string" ? S : m); 7627 } 7628 } 7629 /** 7630 * Leave the conversation 7631 * @param cb 7632 * @param err 7633 */ 7634 leaveConversationAsync(d, v) { 7635 (0, s.marshalPromiseToCallbacks)((async () => { 7636 await this.cancelSpeech(), await this.privConversation.endConversationImplAsync(), await this.privConversation.deleteConversationImplAsync(), this.dispose(); 7637 })(), d, v); 7638 } 7639 /** 7640 * Send a text message 7641 * @param message 7642 * @param cb 7643 * @param err 7644 */ 7645 sendTextMessageAsync(d, v, f) { 7646 try { 7647 p.Contracts.throwIfNullOrUndefined(this.privConversation, this.privErrors.permissionDeniedSend), p.Contracts.throwIfNullOrWhitespace(d, this.privErrors.invalidArgs.replace("{arg}", d)), this.privConversation.sendTextMessageAsync(d, v, f); 7648 } catch (m) { 7649 this.handleError(m, f); 7650 } 7651 } 7652 /** 7653 * Start speaking 7654 * @param cb 7655 * @param err 7656 */ 7657 startTranscribingAsync(d, v) { 7658 (0, s.marshalPromiseToCallbacks)((async () => { 7659 try { 7660 p.Contracts.throwIfNullOrUndefined(this.privConversation, this.privErrors.permissionDeniedSend), p.Contracts.throwIfNullOrUndefined(this.privConversation.room.token, this.privErrors.permissionDeniedConnect), this.privCTRecognizer === void 0 && await this.connectTranslatorRecognizer(), p.Contracts.throwIfNullOrUndefined(this.privCTRecognizer, this.privErrors.permissionDeniedSend), this.canSpeak || this.handleError(new Error(this.privErrors.permissionDeniedSend), v), await this.startContinuousRecognition(), this.privIsSpeaking = !0; 7661 } catch (f) { 7662 throw this.privIsSpeaking = !1, await this.cancelSpeech(), f; 7663 } 7664 })(), d, v); 7665 } 7666 /** 7667 * Stop speaking 7668 * @param cb 7669 * @param err 7670 */ 7671 stopTranscribingAsync(d, v) { 7672 (0, s.marshalPromiseToCallbacks)((async () => { 7673 try { 7674 if (!this.privIsSpeaking) { 7675 await this.cancelSpeech(); 7676 return; 7677 } 7678 this.privIsSpeaking = !1, await new Promise((f, m) => { 7679 this.privCTRecognizer.stopContinuousRecognitionAsync(f, m); 7680 }); 7681 } catch { 7682 await this.cancelSpeech(); 7683 } 7684 })(), d, v); 7685 } 7686 isDisposed() { 7687 return this.privIsDisposed; 7688 } 7689 dispose(d, v, f) { 7690 (0, s.marshalPromiseToCallbacks)((async () => { 7691 this.isDisposed && !this.privIsSpeaking || (await this.cancelSpeech(), this.privIsDisposed = !0, this.privSpeechTranslationConfig.close(), this.privSpeechRecognitionLanguage = void 0, this.privProperties = void 0, this.privAudioConfig = void 0, this.privSpeechTranslationConfig = void 0, this.privConversation.dispose(), this.privConversation = void 0); 7692 })(), v, f); 7693 } 7694 /** 7695 * Cancel the speech websocket 7696 */ 7697 async cancelSpeech() { 7698 var d; 7699 try { 7700 this.privIsSpeaking = !1, await ((d = this.privCTRecognizer) == null ? void 0 : d.onCancelSpeech()), this.privCTRecognizer = void 0; 7701 } catch { 7702 } 7703 } 7704 /** 7705 * Connect to the speech translation recognizer. 7706 * Currently there is no language validation performed before sending the SpeechLanguage code to the service.
7707 * If it's an invalid language the raw error will be: 'Error during WebSocket handshake: Unexpected response code: 400' 7708 * e.g. pass in 'fr' instead of 'fr-FR', or a text-only language 'cy' 7709 */ 7710 async connectTranslatorRecognizer() { 7711 try { 7712 this.privAudioConfig === void 0 && (this.privAudioConfig = a.AudioConfig.fromDefaultMicrophoneInput()), this.privSpeechTranslationConfig.getProperty(a.PropertyId[a.PropertyId.SpeechServiceConnection_Key]) === this.privPlaceholderKey && this.privSpeechTranslationConfig.setProperty(a.PropertyId[a.PropertyId.SpeechServiceConnection_Key], ""); 7713 const d = () => this.privConversation; 7714 this.privCTRecognizer = new c(this.privSpeechTranslationConfig, this.privAudioConfig, this, d); 7715 } catch (d) { 7716 throw await this.cancelSpeech(), d; 7717 } 7718 } 7719 /** 7720 * Handle the start speaking request 7721 */ 7722 startContinuousRecognition() { 7723 return new Promise((d, v) => { 7724 this.privCTRecognizer.startContinuousRecognitionAsync(d, v); 7725 }); 7726 } 7727 } 7728 t.ConversationTranslator = u; 7729 }(yn)), yn; 7730} 7731var jt = {}, co; 7732function Sv() { 7733 if (co) return jt; 7734 co = 1, Object.defineProperty(jt, "__esModule", { value: !0 }), jt.ConversationTranscriber = void 0; 7735 const t = A(), e = ae, r = I(), s = O, p = R(); 7736 let a = class vc extends p.Recognizer { 7737 /** 7738 * ConversationTranscriber constructor. 7739 * @constructor 7740 * @param {SpeechConfig} speechConfig - an set of initial properties for this recognizer 7741 * @param {AudioConfig} audioConfig - An optional audio configuration associated with the recognizer 7742 */ 7743 constructor(i, o) { 7744 const c = i; 7745 s.Contracts.throwIfNull(c, "speechConfig"), s.Contracts.throwIfNullOrWhitespace(c.properties.getProperty(p.PropertyId.SpeechServiceConnection_RecoLanguage), p.PropertyId[p.PropertyId.SpeechServiceConnection_RecoLanguage]), super(o, c.properties, new t.ConversationTranscriberConnectionFactory(), i.tokenCredential), this.privProperties.setProperty(p.PropertyId.SpeechServiceConnection_RecognitionEndpointVersion, "2"), this.privDisposedRecognizer = !1; 7746 } 7747 /** 7748 * ConversationTranscriber constructor. 7749 * @constructor 7750 * @param {SpeechConfig} speechConfig - an set of initial properties for this recognizer 7751 * @param {AutoDetectSourceLanguageConfig} autoDetectSourceLanguageConfig - An source language detection configuration associated with the recognizer 7752 * @param {AudioConfig} audioConfig - An optional audio configuration associated with the recognizer 7753 */ 7754 static FromConfig(i, o, c) { 7755 const u = i; 7756 return o.properties.mergeTo(u.properties), new vc(i, c); 7757 } 7758 /** 7759 * Gets the endpoint id of a customized speech model that is used for transcription. 7760 * @member ConversationTranscriber.prototype.endpointId 7761 * @function 7762 * @public 7763 * @returns {string} the endpoint id of a customized speech model that is used for speech recognition. 7764 */ 7765 get endpointId() { 7766 return s.Contracts.throwIfDisposed(this.privDisposedRecognizer), this.properties.getProperty(p.PropertyId.SpeechServiceConnection_EndpointId, "00000000-0000-0000-0000-000000000000"); 7767 } 7768 /** 7769 * Gets the authorization token used to communicate with the service. 7770 * @member ConversationTranscriber.prototype.authorizationToken 7771 * @function 7772 * @public 7773 * @returns {string} Authorization token. 7774 */ 7775 get authorizationToken() { 7776 return this.properties.getProperty(p.PropertyId.SpeechServiceAuthorization_Token); 7777 } 7778 /** 7779 * Gets/Sets the authorization token used to communicate with the service. 7780 * @member ConversationTranscriber.prototype.authorizationToken 7781 * @function 7782 * @public 7783 * @param {string} token - Authorization token. 7784 */ 7785 set authorizationToken(i) { 7786 s.Contracts.throwIfNullOrWhitespace(i, "token"), this.properties.setProperty(p.PropertyId.SpeechServiceAuthorization_Token, i); 7787 } 7788 /** 7789 * Gets the spoken language of transcription. 7790 * @member ConversationTranscriber.prototype.speechRecognitionLanguage 7791 * @function 7792 * @public 7793 * @returns {string} The spoken language of transcription. 7794 */ 7795 get speechRecognitionLanguage() { 7796 return s.Contracts.throwIfDisposed(this.privDisposedRecognizer), this.properties.getProperty(p.PropertyId.SpeechServiceConnection_RecoLanguage); 7797 } 7798 /** 7799 * Gets the output format of transcription. 7800 * @member ConversationTranscriber.prototype.outputFormat 7801 * @function 7802 * @public 7803 * @returns {OutputFormat} The output format of transcription. 7804 */ 7805 get outputFormat() { 7806 return s.Contracts.throwIfDisposed(this.privDisposedRecognizer), this.properties.getProperty(t.OutputFormatPropertyName, p.OutputFormat[p.OutputFormat.Simple]) === p.OutputFormat[p.OutputFormat.Simple] ? p.OutputFormat.Simple : p.OutputFormat.Detailed; 7807 } 7808 /** 7809 * The collection of properties and their values defined for this conversation transcriber. 7810 * @member ConversationTranscriber.prototype.properties 7811 * @function 7812 * @public 7813 * @returns {PropertyCollection} The collection of properties and their values defined for this SpeechRecognizer. 7814 */ 7815 get properties() { 7816 return this.privProperties; 7817 } 7818 /** 7819 * Starts conversation transcription, until stopTranscribingAsync() is called. 7820 * User must subscribe to events to receive transcription results. 7821 * @member ConversationTranscriber.prototype.startTranscribingAsync 7822 * @function 7823 * @public 7824 * @param cb - Callback invoked once the transcription has started. 7825 * @param err - Callback invoked in case of an error. 7826 */ 7827 startTranscribingAsync(i, o) { 7828 (0, r.marshalPromiseToCallbacks)(this.startContinuousRecognitionAsyncImpl(e.RecognitionMode.Conversation), i, o); 7829 } 7830 /** 7831 * Stops conversation transcription. 7832 * @member ConversationTranscriber.prototype.stopTranscribingAsync 7833 * @function 7834 * @public 7835 * @param cb - Callback invoked once the transcription has stopped. 7836 * @param err - Callback invoked in case of an error. 7837 */ 7838 stopTranscribingAsync(i, o) { 7839 (0, r.marshalPromiseToCallbacks)(this.stopContinuousRecognitionAsyncImpl(), i, o); 7840 } 7841 /** 7842 * closes all external resources held by an instance of this class. 7843 * @member ConversationTranscriber.prototype.close 7844 * @function 7845 * @public 7846 */ 7847 close(i, o) { 7848 s.Contracts.throwIfDisposed(this.privDisposedRecognizer), (0, r.marshalPromiseToCallbacks)(this.dispose(!0), i, o); 7849 } 7850 /**
7851 * Disposes any resources held by the object. 7852 * @member SpeechRecognizer.prototype.dispose 7853 * @function 7854 * @public 7855 * @param {boolean} disposing - true if disposing the object. 7856 */ 7857 async dispose(i) { 7858 this.privDisposedRecognizer || (i && (this.privDisposedRecognizer = !0, await this.implRecognizerStop()), await super.dispose(i)); 7859 } 7860 createRecognizerConfig(i) { 7861 return new t.RecognizerConfig(i, this.privProperties); 7862 } 7863 createServiceRecognizer(i, o, c, u) { 7864 const h = c; 7865 return u.isSpeakerDiarizationEnabled = !0, new t.ConversationTranscriptionServiceRecognizer(i, o, h, u, this); 7866 } 7867 }; 7868 return jt.ConversationTranscriber = a, jt; 7869} 7870var De = {}, po; 7871function Cv() { 7872 if (po) return De; 7873 po = 1, Object.defineProperty(De, "__esModule", { value: !0 }), De.Participant = De.User = void 0; 7874 const t = R(); 7875 class e { 7876 constructor(p) { 7877 this.privUserId = p; 7878 } 7879 get userId() { 7880 return this.privUserId; 7881 } 7882 } 7883 De.User = e; 7884 class r { 7885 constructor(p, a, n, i, o, c, u, h) { 7886 this.privId = p, this.privAvatar = a, this.privDisplayName = n, this.privIsHost = i, this.privIsMuted = o, this.privIsUsingTts = c, this.privPreferredLanguage = u, this.privVoice = h, this.privProperties = new t.PropertyCollection(); 7887 } 7888 get avatar() { 7889 return this.privAvatar; 7890 } 7891 get displayName() { 7892 return this.privDisplayName; 7893 } 7894 get id() { 7895 return this.privId; 7896 } 7897 get preferredLanguage() { 7898 return this.privPreferredLanguage; 7899 } 7900 get isHost() { 7901 return this.privIsHost; 7902 } 7903 get isMuted() { 7904 return this.privIsMuted; 7905 } 7906 get isUsingTts() { 7907 return this.privIsUsingTts; 7908 } 7909 get voice() { 7910 return this.privVoice; 7911 } 7912 get properties() { 7913 return this.privProperties; 7914 } 7915 static From(p, a, n) { 7916 return new r(p, "", p, !1, !1, !1, a, n); 7917 } 7918 } 7919 return De.Participant = r, De; 7920} 7921var lc = {}; 7922(function(t) { 7923 Object.defineProperty(t, "__esModule", { value: !0 }), t.ParticipantChangedReason = void 0, function(e) { 7924 e[e.JoinedConversation = 0] = "JoinedConversation", e[e.LeftConversation = 1] = "LeftConversation", e[e.Updated = 2] = "Updated"; 7925 }(t.ParticipantChangedReason || (t.ParticipantChangedReason = {})); 7926})(lc); 7927var ke = {}, uo; 7928function yv() { 7929 if (uo) return ke; 7930 uo = 1, Object.defineProperty(ke, "__esModule", { value: !0 }), ke.MeetingImpl = ke.Meeting = void 0; 7931 const t = A(), e = I(), r = O, s = R(); 7932 let p = class { 7933 constructor() { 7934 } 7935 /** 7936 * Create a meeting 7937 * @param speechConfig 7938 * @param meetingId 7939 * @param cb 7940 * @param err 7941 */ 7942 static createMeetingAsync(i, o, c, u) { 7943 if (r.Contracts.throwIfNullOrUndefined(i, t.ConversationConnectionConfig.restErrors.invalidArgs.replace("{arg}", "config")), r.Contracts.throwIfNullOrUndefined(i.region, t.ConversationConnectionConfig.restErrors.invalidArgs.replace("{arg}", "SpeechServiceConnection_Region")), r.Contracts.throwIfNull(o, "meetingId"), o.length === 0) 7944 throw new Error("meetingId cannot be empty"); 7945 !i.subscriptionKey && !i.getProperty(s.PropertyId[s.PropertyId.SpeechServiceAuthorization_Token]) && r.Contracts.throwIfNullOrUndefined(i.subscriptionKey, t.ConversationConnectionConfig.restErrors.invalidArgs.replace("{arg}", "SpeechServiceConnection_Key")); 7946 const h = new a(i, o); 7947 return (0, e.marshalPromiseToCallbacks)((async () => { 7948 })(), c, u), h; 7949 } 7950 }; 7951 ke.Meeting = p; 7952 class a extends p { 7953 /** 7954 * Create a Meeting impl 7955 * @param speechConfig 7956 * @param {string} id - optional conversationId 7957 */ 7958 constructor(i, o) { 7959 super(), this.privErrors = t.ConversationConnectionConfig.restErrors, this.onConnected = (h) => { 7960 var d; 7961 this.privIsConnected = !0; 7962 try { 7963 (d = this.privConversationTranslator) != null && d.sessionStarted && this.privConversationTranslator.sessionStarted(this.privConversationTranslator, h); 7964 } catch { 7965 } 7966 }, this.onDisconnected = (h) => { 7967 var d; 7968 try { 7969 (d = this.privConversationTranslator) != null && d.sessionStopped && this.privConversationTranslator.sessionStopped(this.privConversationTranslator, h); 7970 } catch { 7971 } finally { 7972 this.close(!1); 7973 } 7974 }, this.onCanceled = (h, d) => { 7975 var v; 7976 try { 7977 (v = this.privConversationTranslator) != null && v.canceled && this.privConversationTranslator.canceled(this.privConversationTranslator, d); 7978 } catch { 7979 } 7980 }, this.onParticipantUpdateCommandReceived = (h, d) => { 7981 try { 7982 const v = this.privParticipants.getParticipant(d.id); 7983 if (v !== void 0) { 7984 switch (d.key) { 7985 case t.ConversationTranslatorCommandTypes.changeNickname: 7986 v.displayName = d.value; 7987 break; 7988 case t.ConversationTranslatorCommandTypes.setUseTTS: 7989 v.isUsingTts = d.value; 7990 break; 7991 case t.ConversationTranslatorCommandTypes.setProfanityFiltering: 7992 v.profanity = d.value; 7993 break; 7994 case t.ConversationTranslatorCommandTypes.setMute: 7995 v.isMuted = d.value; 7996 break; 7997 case t.ConversationTranslatorCommandTypes.setTranslateToLanguages: 7998 v.translateToLanguages = d.value; 7999 break; 8000 } 8001 this.privParticipants.addOrUpdateParticipant(v), this.privConversationTranslator && this.privConversationTranslator.participantsChanged(this.privConversationTranslator, new s.ConversationParticipantsChangedEventArgs(s.ParticipantChangedReason.Updated, [this.toParticipant(v)], d.sessionId)); 8002 } 8003 } catch { 8004 } 8005 }, this.onLockRoomCommandReceived = () => { 8006 }, this.onMuteAllCommandReceived = (h, d) => { 8007 try {
8008 this.privParticipants.participants.forEach((v) => v.isMuted = v.isHost ? !1 : d.isMuted), this.privConversationTranslator && this.privConversationTranslator.participantsChanged(this.privConversationTranslator, new s.ConversationParticipantsChangedEventArgs(s.ParticipantChangedReason.Updated, this.toParticipants(!1), d.sessionId)); 8009 } catch { 8010 } 8011 }, this.onParticipantJoinCommandReceived = (h, d) => { 8012 try { 8013 const v = this.privParticipants.addOrUpdateParticipant(d.participant); 8014 v !== void 0 && this.privConversationTranslator && this.privConversationTranslator.participantsChanged(this.privConversationTranslator, new s.ConversationParticipantsChangedEventArgs(s.ParticipantChangedReason.JoinedConversation, [this.toParticipant(v)], d.sessionId)); 8015 } catch { 8016 } 8017 }, this.onParticipantLeaveCommandReceived = (h, d) => { 8018 try { 8019 const v = this.privParticipants.getParticipant(d.participant.id); 8020 v !== void 0 && (this.privParticipants.deleteParticipant(d.participant.id), this.privConversationTranslator && this.privConversationTranslator.participantsChanged(this.privConversationTranslator, new s.ConversationParticipantsChangedEventArgs(s.ParticipantChangedReason.LeftConversation, [this.toParticipant(v)], d.sessionId))); 8021 } catch { 8022 } 8023 }, this.onTranslationReceived = (h, d) => { 8024 try { 8025 switch (d.command) { 8026 case t.ConversationTranslatorMessageTypes.final: 8027 this.privConversationTranslator && this.privConversationTranslator.transcribed(this.privConversationTranslator, new s.ConversationTranslationEventArgs(d.payload, void 0, d.sessionId)); 8028 break; 8029 case t.ConversationTranslatorMessageTypes.partial: 8030 this.privConversationTranslator && this.privConversationTranslator.transcribing(this.privConversationTranslator, new s.ConversationTranslationEventArgs(d.payload, void 0, d.sessionId)); 8031 break; 8032 case t.ConversationTranslatorMessageTypes.instantMessage: 8033 this.privConversationTranslator && this.privConversationTranslator.textMessageReceived(this.privConversationTranslator, new s.ConversationTranslationEventArgs(d.payload, void 0, d.sessionId)); 8034 break; 8035 } 8036 } catch { 8037 } 8038 }, this.onParticipantsListReceived = (h, d) => { 8039 var v; 8040 try { 8041 if (d.sessionToken !== void 0 && d.sessionToken !== null && (this.privRoom.token = d.sessionToken), this.privParticipants.participants = [...d.participants], this.privParticipants.me !== void 0 && (this.privIsReady = !0), this.privConversationTranslator && this.privConversationTranslator.participantsChanged(this.privConversationTranslator, new s.ConversationParticipantsChangedEventArgs(s.ParticipantChangedReason.JoinedConversation, this.toParticipants(!0), d.sessionId)), this.me.isHost) { 8042 const f = (v = this.privConversationTranslator) == null ? void 0 : v.properties.getProperty(s.PropertyId.ConversationTranslator_Name); 8043 f !== void 0 && f.length > 0 && f !== this.me.displayName && this.changeNicknameAsync(f); 8044 } 8045 } catch { 8046 } 8047 }, this.onConversationExpiration = (h, d) => { 8048 try { 8049 this.privConversationTranslator && this.privConversationTranslator.conversationExpiration(this.privConversationTranslator, d); 8050 } catch { 8051 } 8052 }, this.privIsConnected = !1, this.privIsDisposed = !1, this.privConversationId = "", this.privProperties = new s.PropertyCollection(), this.privManager = new t.ConversationManager(), i.getProperty(s.PropertyId[s.PropertyId.SpeechServiceConnection_RecoLanguage]) || i.setProperty(s.PropertyId[s.PropertyId.SpeechServiceConnection_RecoLanguage], t.ConversationConnectionConfig.defaultLanguageCode), this.privLanguage = i.getProperty(s.PropertyId[s.PropertyId.SpeechServiceConnection_RecoLanguage]), this.privConversationId = o, this.privConfig = i; 8053 const u = i; 8054 r.Contracts.throwIfNull(u, "speechConfig"), this.privProperties = u.properties.clone(), this.privIsConnected = !1, this.privParticipants = new t.InternalParticipants(), this.privIsReady = !1, this.privTextMessageMaxLength = 1e3; 8055 } 8056 // get the internal data about a conversation 8057 get room() { 8058 return this.privRoom; 8059 } 8060 // get the wrapper for connecting to the websockets 8061 get connection() { 8062 return this.privConversationRecognizer; 8063 } 8064 // get the config 8065 get config() { 8066 return this.privConfig; 8067 } 8068 // get the meeting Id 8069 get meetingId() { 8070 return this.privRoom ? this.privRoom.roomId : this.privConversationId; 8071 } 8072 // get the properties 8073 get properties() { 8074 return this.privProperties; 8075 } 8076 // get the speech language 8077 get speechRecognitionLanguage() { 8078 return this.privLanguage; 8079 } 8080 get isMutedByHost() { 8081 var i, o; 8082 return (i = this.privParticipants.me) != null && i.isHost ? !1 : (o = this.privParticipants.me) == null ? void 0 : o.isMuted; 8083 } 8084 get isConnected() { 8085 return this.privIsConnected && this.privIsReady; 8086 } 8087 get participants() { 8088 return this.toParticipants(!0); 8089 } 8090 get me() { 8091 return this.toParticipant(this.privParticipants.me); 8092 } 8093 get host() { 8094 return this.toParticipant(this.privParticipants.host); 8095 } 8096 get transcriberRecognizer() { 8097 return this.privTranscriberRecognizer; 8098 } 8099 get meetingInfo() { 8100 const i = this.meetingId, o = this.participants.map((h) => ({ 8101 id: h.id, 8102 preferredLanguage: h.preferredLanguage, 8103 voice: h.voice 8104 })), c = {}; 8105 for (const h of t.ConversationConnectionConfig.transcriptionEventKeys) { 8106 const d = this.properties.getProperty(h, ""); 8107 d !== "" && (c[h] = d); 8108 } 8109 return { id: i, participants: o, meetingProperties: c }; 8110 } 8111 get canSend() { 8112 var i; 8113 return this.privIsConnected && !((i = this.privParticipants.me) != null && i.isMuted); 8114 } 8115 get canSendAsHost() { 8116 var i; 8117 return this.privIsConnected && ((i = this.privParticipants.me) == null ? void 0 : i.isHost); 8118 } 8119 // get / set the speech auth token 8120 // eslint-disable-next-line @typescript-eslint/member-ordering 8121 get authorizationToken() { 8122 return this.privToken; 8123 } 8124 set authorizationToken(i) { 8125 r.Contracts.throwIfNullOrWhitespace(i, "authorizationToken"), this.privToken = i; 8126 } 8127 /** 8128 * Create a new meeting as Host 8129 * @param cb 8130 * @param err 8131 */ 8132 createMeetingAsync(i, o) {
8133 try { 8134 this.privConversationRecognizer && this.handleError(new Error(this.privErrors.permissionDeniedStart), o), this.privManager.createOrJoin(this.privProperties, void 0, (c) => { 8135 c || this.handleError(new Error(this.privErrors.permissionDeniedConnect), o), this.privRoom = c, this.handleCallback(i, o); 8136 }, (c) => { 8137 this.handleError(c, o); 8138 }); 8139 } catch (c) { 8140 this.handleError(c, o); 8141 } 8142 } 8143 /** 8144 * Starts a new meeting as host. 8145 * @param cb 8146 * @param err 8147 */ 8148 startMeetingAsync(i, o) { 8149 try { 8150 this.privConversationRecognizer && this.handleError(new Error(this.privErrors.permissionDeniedStart), o), r.Contracts.throwIfNullOrUndefined(this.privRoom, this.privErrors.permissionDeniedConnect), this.privParticipants.meId = this.privRoom.participantId, this.privConversationRecognizer.connected = this.onConnected, this.privConversationRecognizer.disconnected = this.onDisconnected, this.privConversationRecognizer.canceled = this.onCanceled, this.privConversationRecognizer.participantUpdateCommandReceived = this.onParticipantUpdateCommandReceived, this.privConversationRecognizer.lockRoomCommandReceived = this.onLockRoomCommandReceived, this.privConversationRecognizer.muteAllCommandReceived = this.onMuteAllCommandReceived, this.privConversationRecognizer.participantJoinCommandReceived = this.onParticipantJoinCommandReceived, this.privConversationRecognizer.participantLeaveCommandReceived = this.onParticipantLeaveCommandReceived, this.privConversationRecognizer.translationReceived = this.onTranslationReceived, this.privConversationRecognizer.participantsListReceived = this.onParticipantsListReceived, this.privConversationRecognizer.conversationExpiration = this.onConversationExpiration, this.privConversationRecognizer.connect(this.privRoom.token, () => { 8151 this.handleCallback(i, o); 8152 }, (c) => { 8153 this.handleError(c, o); 8154 }); 8155 } catch (c) { 8156 this.handleError(c, o); 8157 } 8158 } 8159 /** 8160 * Join a meeting as a participant. 8161 * @param { IParticipant } participant - participant to add 8162 * @param cb 8163 * @param err 8164 */ 8165 addParticipantAsync(i, o, c) { 8166 r.Contracts.throwIfNullOrUndefined(i, "Participant"), (0, e.marshalPromiseToCallbacks)(this.addParticipantImplAsync(i), o, c); 8167 } 8168 /** 8169 * Join a meeting as a participant. 8170 * @param meeting 8171 * @param nickname 8172 * @param lang 8173 * @param cb 8174 * @param err 8175 */ 8176 joinMeetingAsync(i, o, c, u, h) { 8177 try { 8178 r.Contracts.throwIfNullOrWhitespace(i, this.privErrors.invalidArgs.replace("{arg}", "conversationId")), r.Contracts.throwIfNullOrWhitespace(o, this.privErrors.invalidArgs.replace("{arg}", "nickname")), r.Contracts.throwIfNullOrWhitespace(c, this.privErrors.invalidArgs.replace("{arg}", "language")), this.privManager.createOrJoin(this.privProperties, i, (d) => { 8179 r.Contracts.throwIfNullOrUndefined(d, this.privErrors.permissionDeniedConnect), this.privRoom = d, this.privConfig.authorizationToken = d.cognitiveSpeechAuthToken, u && u(d.cognitiveSpeechAuthToken); 8180 }, (d) => { 8181 this.handleError(d, h); 8182 }); 8183 } catch (d) { 8184 this.handleError(d, h); 8185 } 8186 } 8187 /** 8188 * Deletes a meeting 8189 * @param cb 8190 * @param err 8191 */ 8192 deleteMeetingAsync(i, o) { 8193 (0, e.marshalPromiseToCallbacks)(this.deleteMeetingImplAsync(), i, o); 8194 } 8195 async deleteMeetingImplAsync() { 8196 r.Contracts.throwIfNullOrUndefined(this.privProperties, this.privErrors.permissionDeniedConnect), r.Contracts.throwIfNullOrWhitespace(this.privRoom.token, this.privErrors.permissionDeniedConnect), await this.privManager.leave(this.privProperties, this.privRoom.token), this.dispose(); 8197 } 8198 /** 8199 * Issues a request to close the client websockets 8200 * @param cb 8201 * @param err 8202 */ 8203 endMeetingAsync(i, o) { 8204 (0, e.marshalPromiseToCallbacks)(this.endMeetingImplAsync(), i, o); 8205 } 8206 endMeetingImplAsync() { 8207 return this.close(!0); 8208 } 8209 /** 8210 * Issues a request to lock the conversation 8211 * @param cb 8212 * @param err 8213 */ 8214 lockMeetingAsync(i, o) {
8215 try { 8216 r.Contracts.throwIfDisposed(this.privIsDisposed), r.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()), r.Contracts.throwIfNullOrUndefined(this.privRoom, this.privErrors.permissionDeniedSend), this.canSendAsHost || this.handleError(new Error(this.privErrors.permissionDeniedConversation.replace("{command}", "lock")), o), this.privConversationRecognizer && this.privConversationRecognizer.sendRequest(this.getLockCommand(!0), () => { 8217 this.handleCallback(i, o); 8218 }, (c) => { 8219 this.handleError(c, o); 8220 }); 8221 } catch (c) { 8222 this.handleError(c, o); 8223 } 8224 } 8225 /** 8226 * Issues a request to mute the meeting 8227 * @param cb 8228 * @param err 8229 */ 8230 muteAllParticipantsAsync(i, o) { 8231 try { 8232 r.Contracts.throwIfDisposed(this.privIsDisposed), r.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()), r.Contracts.throwIfNullOrUndefined(this.privConversationRecognizer, this.privErrors.permissionDeniedSend), r.Contracts.throwIfNullOrUndefined(this.privRoom, this.privErrors.permissionDeniedSend), this.canSendAsHost || this.handleError(new Error(this.privErrors.permissionDeniedConversation.replace("{command}", "mute")), o), this.privConversationRecognizer && this.privConversationRecognizer.sendRequest(this.getMuteAllCommand(!0), () => { 8233 this.handleCallback(i, o); 8234 }, (c) => { 8235 this.handleError(c, o); 8236 }); 8237 } catch (c) { 8238 this.handleError(c, o); 8239 } 8240 } 8241 /** 8242 * Issues a request to mute a participant in the meeting 8243 * @param userId 8244 * @param cb 8245 * @param err 8246 */ 8247 muteParticipantAsync(i, o, c) { 8248 try { 8249 r.Contracts.throwIfDisposed(this.privIsDisposed), r.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()), r.Contracts.throwIfNullOrWhitespace(i, this.privErrors.invalidArgs.replace("{arg}", "userId")), r.Contracts.throwIfNullOrUndefined(this.privRoom, this.privErrors.permissionDeniedSend), this.canSend || this.handleError(new Error(this.privErrors.permissionDeniedSend), c), !this.me.isHost && this.me.id !== i && this.handleError(new Error(this.privErrors.permissionDeniedParticipant.replace("{command}", "mute")), c), this.privParticipants.getParticipantIndex(i) === -1 && this.handleError(new Error(this.privErrors.invalidParticipantRequest), c), this.privConversationRecognizer && this.privConversationRecognizer.sendRequest(this.getMuteCommand(i, !0), () => { 8250 this.handleCallback(o, c); 8251 }, (h) => { 8252 this.handleError(h, c); 8253 }); 8254 } catch (u) { 8255 this.handleError(u, c); 8256 } 8257 } 8258 /** 8259 * Issues a request to remove a participant from the conversation 8260 * @param userId 8261 * @param cb 8262 * @param err 8263 */ 8264 removeParticipantAsync(i, o, c) { 8265 try { 8266 if (r.Contracts.throwIfDisposed(this.privIsDisposed), this.privTranscriberRecognizer && i.hasOwnProperty("id")) 8267 (0, e.marshalPromiseToCallbacks)(this.removeParticipantImplAsync(i), o, c); 8268 else { 8269 r.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()), r.Contracts.throwIfNullOrUndefined(this.privRoom, this.privErrors.permissionDeniedSend), this.canSendAsHost || this.handleError(new Error(this.privErrors.permissionDeniedParticipant.replace("{command}", "remove")), c); 8270 let u = ""; 8271 typeof i == "string" ? u = i : i.hasOwnProperty("id") ? u = i.id : i.hasOwnProperty("userId") && (u = i.userId), r.Contracts.throwIfNullOrWhitespace(u, this.privErrors.invalidArgs.replace("{arg}", "userId")), this.participants.findIndex((d) => d.id === u) === -1 && this.handleError(new Error(this.privErrors.invalidParticipantRequest), c), this.privConversationRecognizer && this.privConversationRecognizer.sendRequest(this.getEjectCommand(u), () => { 8272 this.handleCallback(o, c); 8273 }, (d) => { 8274 this.handleError(d, c); 8275 }); 8276 } 8277 } catch (u) { 8278 this.handleError(u, c); 8279 } 8280 } 8281 /** 8282 * Issues a request to unlock the meeting 8283 * @param cb 8284 * @param err 8285 */ 8286 unlockMeetingAsync(i, o) {
8287 try { 8288 r.Contracts.throwIfDisposed(this.privIsDisposed), r.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()), r.Contracts.throwIfNullOrUndefined(this.privRoom, this.privErrors.permissionDeniedSend), this.canSendAsHost || this.handleError(new Error(this.privErrors.permissionDeniedConversation.replace("{command}", "unlock")), o), this.privConversationRecognizer && this.privConversationRecognizer.sendRequest(this.getLockCommand(!1), () => { 8289 this.handleCallback(i, o); 8290 }, (c) => { 8291 this.handleError(c, o); 8292 }); 8293 } catch (c) { 8294 this.handleError(c, o); 8295 } 8296 } 8297 /** 8298 * Issues a request to unmute all participants in the meeting 8299 * @param cb 8300 * @param err 8301 */ 8302 unmuteAllParticipantsAsync(i, o) { 8303 try { 8304 r.Contracts.throwIfDisposed(this.privIsDisposed), r.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()), r.Contracts.throwIfNullOrUndefined(this.privRoom, this.privErrors.permissionDeniedSend), this.canSendAsHost || this.handleError(new Error(this.privErrors.permissionDeniedConversation.replace("{command}", "unmute all")), o), this.privConversationRecognizer && this.privConversationRecognizer.sendRequest(this.getMuteAllCommand(!1), () => { 8305 this.handleCallback(i, o); 8306 }, (c) => { 8307 this.handleError(c, o); 8308 }); 8309 } catch (c) { 8310 this.handleError(c, o); 8311 } 8312 } 8313 /** 8314 * Issues a request to unmute a participant in the meeting 8315 * @param userId 8316 * @param cb 8317 * @param err 8318 */ 8319 unmuteParticipantAsync(i, o, c) { 8320 try { 8321 r.Contracts.throwIfDisposed(this.privIsDisposed), r.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()), r.Contracts.throwIfNullOrWhitespace(i, this.privErrors.invalidArgs.replace("{arg}", "userId")), r.Contracts.throwIfNullOrUndefined(this.privRoom, this.privErrors.permissionDeniedSend), this.canSend || this.handleError(new Error(this.privErrors.permissionDeniedSend), c), !this.me.isHost && this.me.id !== i && this.handleError(new Error(this.privErrors.permissionDeniedParticipant.replace("{command}", "mute")), c), this.privParticipants.getParticipantIndex(i) === -1 && this.handleError(new Error(this.privErrors.invalidParticipantRequest), c), this.privConversationRecognizer && this.privConversationRecognizer.sendRequest(this.getMuteCommand(i, !1), () => { 8322 this.handleCallback(o, c); 8323 }, (h) => { 8324 this.handleError(h, c); 8325 }); 8326 } catch (u) { 8327 this.handleError(u, c); 8328 } 8329 } 8330 /** 8331 * Send a text message 8332 * @param message 8333 * @param cb 8334 * @param err 8335 */ 8336 sendTextMessageAsync(i, o, c) { 8337 try { 8338 r.Contracts.throwIfDisposed(this.privIsDisposed), r.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()), r.Contracts.throwIfNullOrWhitespace(i, this.privErrors.invalidArgs.replace("{arg}", "message")), r.Contracts.throwIfNullOrUndefined(this.privRoom, this.privErrors.permissionDeniedSend), this.canSend || this.handleError(new Error(this.privErrors.permissionDeniedSend), c), i.length > this.privTextMessageMaxLength && this.handleError(new Error(this.privErrors.invalidArgs.replace("{arg}", "message length")), c), this.privConversationRecognizer && this.privConversationRecognizer.sendRequest(this.getMessageCommand(i), () => { 8339 this.handleCallback(o, c); 8340 }, (u) => { 8341 this.handleError(u, c); 8342 }); 8343 } catch (u) { 8344 this.handleError(u, c); 8345 } 8346 } 8347 /** 8348 * Set translated to languages 8349 * @param {string[]} languages - languages to translate to 8350 * @param cb 8351 * @param err 8352 */ 8353 setTranslatedLanguagesAsync(i, o, c) { 8354 try { 8355 r.Contracts.throwIfDisposed(this.privIsDisposed), r.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()), r.Contracts.throwIfArrayEmptyOrWhitespace(i, this.privErrors.invalidArgs.replace("{arg}", "languages")), r.Contracts.throwIfNullOrUndefined(this.privRoom, this.privErrors.permissionDeniedSend), this.canSend || this.handleError(new Error(this.privErrors.permissionDeniedSend), c), this.privConversationRecognizer && this.privConversationRecognizer.sendRequest(this.getSetTranslateToLanguagesCommand(i), () => { 8356 this.handleCallback(o, c); 8357 }, (u) => { 8358 this.handleError(u, c); 8359 }); 8360 } catch (u) { 8361 this.handleError(u, c); 8362 } 8363 } 8364 /** 8365 * Change nickname 8366 * @param {string} nickname - new nickname for the room 8367 * @param cb 8368 * @param err 8369 */ 8370 changeNicknameAsync(i, o, c) {
8371 try { 8372 r.Contracts.throwIfDisposed(this.privIsDisposed), r.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()), r.Contracts.throwIfNullOrWhitespace(i, this.privErrors.invalidArgs.replace("{arg}", "nickname")), r.Contracts.throwIfNullOrUndefined(this.privRoom, this.privErrors.permissionDeniedSend), this.canSend || this.handleError(new Error(this.privErrors.permissionDeniedSend), c), this.privConversationRecognizer && this.privConversationRecognizer.sendRequest(this.getChangeNicknameCommand(i), () => { 8373 this.handleCallback(o, c); 8374 }, (u) => { 8375 this.handleError(u, c); 8376 }); 8377 } catch (u) { 8378 this.handleError(u, c); 8379 } 8380 } 8381 isDisposed() { 8382 return this.privIsDisposed; 8383 } 8384 dispose() { 8385 this.isDisposed || (this.privIsDisposed = !0, this.config && this.config.close(), this.privConfig = void 0, this.privLanguage = void 0, this.privProperties = void 0, this.privRoom = void 0, this.privToken = void 0, this.privManager = void 0, this.privIsConnected = !1, this.privIsReady = !1, this.privParticipants = void 0); 8386 } 8387 async connectTranscriberRecognizer(i) { 8388 this.privTranscriberRecognizer && await this.privTranscriberRecognizer.close(), await i.enforceAudioGating(), this.privTranscriberRecognizer = i, this.privTranscriberRecognizer.meeting = this; 8389 } 8390 getKeepAlive() { 8391 const i = this.me ? this.me.displayName : "default_nickname"; 8392 return JSON.stringify({ 8393 id: "0", 8394 nickname: i, 8395 participantId: this.privRoom.participantId, 8396 roomId: this.privRoom.roomId, 8397 type: t.ConversationTranslatorMessageTypes.keepAlive 8398 }); 8399 } 8400 /* eslint-enable @typescript-eslint/typedef */ 8401 addParticipantImplAsync(i) { 8402 if (this.privParticipants.addOrUpdateParticipant(i) !== void 0 && this.privTranscriberRecognizer) { 8403 const c = this.meetingInfo; 8404 return c.participants = [i], this.privTranscriberRecognizer.pushMeetingEvent(c, "join"); 8405 } 8406 } 8407 removeParticipantImplAsync(i) { 8408 this.privParticipants.deleteParticipant(i.id); 8409 const o = this.meetingInfo; 8410 return o.participants = [i], this.privTranscriberRecognizer.pushMeetingEvent(o, "leave"); 8411 } 8412 async close(i) { 8413 var o;
8414 try { 8415 this.privIsConnected = !1, await ((o = this.privConversationRecognizer) == null ? void 0 : o.close()), this.privConversationRecognizer = void 0, this.privConversationTranslator && this.privConversationTranslator.dispose(); 8416 } catch (c) { 8417 throw c; 8418 } 8419 i && this.dispose(); 8420 } 8421 /** Helpers */ 8422 handleCallback(i, o) { 8423 if (i) { 8424 try { 8425 i(); 8426 } catch (c) { 8427 o && o(c); 8428 } 8429 i = void 0; 8430 } 8431 } 8432 handleError(i, o) { 8433 if (o) 8434 if (i instanceof Error) { 8435 const c = i; 8436 o(c.name + ": " + c.message); 8437 } else 8438 o(i); 8439 } 8440 /** Participant Helpers */ 8441 toParticipants(i) { 8442 const o = this.privParticipants.participants.map((c) => this.toParticipant(c)); 8443 return i ? o : o.filter((c) => c.isHost === !1); 8444 } 8445 toParticipant(i) { 8446 return new s.Participant(i.id, i.avatar, i.displayName, i.isHost, i.isMuted, i.isUsingTts, i.preferredLanguage, i.voice); 8447 } 8448 getMuteAllCommand(i) { 8449 return r.Contracts.throwIfNullOrWhitespace(this.privRoom.roomId, "meetingd"), r.Contracts.throwIfNullOrWhitespace(this.privRoom.participantId, "participantId"), JSON.stringify({ 8450 command: t.ConversationTranslatorCommandTypes.setMuteAll, 8451 participantId: this.privRoom.participantId, 8452 roomid: this.privRoom.roomId, 8453 type: t.ConversationTranslatorMessageTypes.participantCommand, 8454 value: i 8455 }); 8456 } 8457 getMuteCommand(i, o) { 8458 return r.Contracts.throwIfNullOrWhitespace(this.privRoom.roomId, "conversationId"), r.Contracts.throwIfNullOrWhitespace(i, "participantId"), JSON.stringify({ 8459 command: t.ConversationTranslatorCommandTypes.setMute, 8460 // eslint-disable-next-line object-shorthand 8461 participantId: i, 8462 roomid: this.privRoom.roomId, 8463 type: t.ConversationTranslatorMessageTypes.participantCommand, 8464 value: o 8465 }); 8466 } 8467 getLockCommand(i) { 8468 return r.Contracts.throwIfNullOrWhitespace(this.privRoom.roomId, "meetingId"), r.Contracts.throwIfNullOrWhitespace(this.privRoom.participantId, "participantId"), JSON.stringify({ 8469 command: t.ConversationTranslatorCommandTypes.setLockState, 8470 participantId: this.privRoom.participantId, 8471 roomid: this.privRoom.roomId, 8472 type: t.ConversationTranslatorMessageTypes.participantCommand, 8473 value: i 8474 }); 8475 } 8476 getEjectCommand(i) { 8477 return r.Contracts.throwIfNullOrWhitespace(this.privRoom.roomId, "meetingId"), r.Contracts.throwIfNullOrWhitespace(i, "participantId"), JSON.stringify({ 8478 command: t.ConversationTranslatorCommandTypes.ejectParticipant, 8479 // eslint-disable-next-line object-shorthand 8480 participantId: i, 8481 roomid: this.privRoom.roomId, 8482 type: t.ConversationTranslatorMessageTypes.participantCommand 8483 }); 8484 } 8485 getSetTranslateToLanguagesCommand(i) { 8486 return r.Contracts.throwIfNullOrWhitespace(this.privRoom.roomId, "meetingId"), r.Contracts.throwIfNullOrWhitespace(this.privRoom.participantId, "participantId"), JSON.stringify({ 8487 command: t.ConversationTranslatorCommandTypes.setTranslateToLanguages, 8488 participantId: this.privRoom.participantId, 8489 roomid: this.privRoom.roomId, 8490 type: t.ConversationTranslatorMessageTypes.participantCommand, 8491 value: i 8492 }); 8493 } 8494 getChangeNicknameCommand(i) { 8495 return r.Contracts.throwIfNullOrWhitespace(this.privRoom.roomId, "meetingId"), r.Contracts.throwIfNullOrWhitespace(i, "nickname"), r.Contracts.throwIfNullOrWhitespace(this.privRoom.participantId, "participantId"), JSON.stringify({ 8496 command: t.ConversationTranslatorCommandTypes.changeNickname, 8497 nickname: i, 8498 participantId: this.privRoom.participantId, 8499 roomid: this.privRoom.roomId, 8500 type: t.ConversationTranslatorMessageTypes.participantCommand, 8501 value: i 8502 }); 8503 } 8504 getMessageCommand(i) { 8505 return r.Contracts.throwIfNullOrWhitespace(this.privRoom.roomId, "meetingId"), r.Contracts.throwIfNullOrWhitespace(this.privRoom.participantId, "participantId"), r.Contracts.throwIfNullOrWhitespace(i, "message"), JSON.stringify({ 8506 participantId: this.privRoom.participantId, 8507 roomId: this.privRoom.roomId, 8508 text: i, 8509 type: t.ConversationTranslatorMessageTypes.instantMessage 8510 }); 8511 } 8512 } 8513 return ke.MeetingImpl = a, ke; 8514} 8515var Lt = {}, ho; 8516function Pv() { 8517 if (ho) return Lt; 8518 ho = 1, Object.defineProperty(Lt, "__esModule", { value: !0 }), Lt.MeetingTranscriptionCanceledEventArgs = void 0; 8519 const t = zr(); 8520 class e extends t.CancellationEventArgsBase { 8521 } 8522 return Lt.MeetingTranscriptionCanceledEventArgs = e, Lt; 8523} 8524var Bt = {}, vo; 8525function Rv() { 8526 if (vo) return Bt; 8527 vo = 1, Object.defineProperty(Bt, "__esModule", { value: !0 }), Bt.MeetingTranscriber = void 0;
8528 const t = A(), e = I(), r = O, s = R(), p = Hn(); 8529 let a = class { 8530 /** 8531 * MeetingTranscriber constructor. 8532 * @constructor 8533 * @param {AudioConfig} audioConfig - An optional audio configuration associated with the recognizer 8534 */ 8535 constructor(i) { 8536 this.privAudioConfig = i, this.privProperties = new s.PropertyCollection(), this.privRecognizer = void 0, this.privDisposedRecognizer = !1; 8537 } 8538 /** 8539 * Gets the spoken language of recognition. 8540 * @member MeetingTranscriber.prototype.speechRecognitionLanguage 8541 * @function 8542 * @public 8543 * @returns {string} The spoken language of recognition. 8544 */ 8545 get speechRecognitionLanguage() { 8546 return r.Contracts.throwIfDisposed(this.privDisposedRecognizer), this.properties.getProperty(s.PropertyId.SpeechServiceConnection_RecoLanguage); 8547 } 8548 /** 8549 * The collection of properties and their values defined for this MeetingTranscriber. 8550 * @member MeetingTranscriber.prototype.properties 8551 * @function 8552 * @public 8553 * @returns {PropertyCollection} The collection of properties and their values defined for this MeetingTranscriber. 8554 */ 8555 get properties() { 8556 return this.privProperties; 8557 } 8558 /** 8559 * @Internal 8560 * Internal data member to support fromRecognizer* pattern methods on other classes. 8561 * Do not use externally, object returned will change without warning or notice. 8562 */ 8563 get internalData() { 8564 return this.privRecognizer.internalData; 8565 } 8566 /** 8567 * @Deprecated 8568 * @Obsolete 8569 * Please use the Connection.fromRecognizer pattern to obtain a connection object 8570 */ 8571 get connection() { 8572 return s.Connection.fromRecognizer(this.privRecognizer); 8573 } 8574 /** 8575 * Gets the authorization token used to communicate with the service. 8576 * @member MeetingTranscriber.prototype.authorizationToken 8577 * @function 8578 * @public 8579 * @returns {string} Authorization token. 8580 */ 8581 get authorizationToken() { 8582 return this.properties.getProperty(s.PropertyId.SpeechServiceAuthorization_Token); 8583 } 8584 /** 8585 * Gets/Sets the authorization token used to communicate with the service. 8586 * @member MeetingTranscriber.prototype.authorizationToken 8587 * @function 8588 * @public 8589 * @param {string} token - Authorization token. 8590 */ 8591 set authorizationToken(i) { 8592 r.Contracts.throwIfNullOrWhitespace(i, "token"), this.properties.setProperty(s.PropertyId.SpeechServiceAuthorization_Token, i); 8593 } 8594 /** 8595 * @param {Meeting} meeting - meeting to be recognized 8596 */ 8597 joinMeetingAsync(i, o, c) { 8598 const u = i; 8599 r.Contracts.throwIfNullOrUndefined(p.MeetingImpl, "Meeting"), this.privRecognizer = new t.TranscriberRecognizer(i.config, this.privAudioConfig), r.Contracts.throwIfNullOrUndefined(this.privRecognizer, "Recognizer"), this.privRecognizer.connectMeetingCallbacks(this), (0, e.marshalPromiseToCallbacks)(u.connectTranscriberRecognizer(this.privRecognizer), o, c); 8600 } 8601 /** 8602 * Starts meeting transcription, until stopTranscribingAsync() is called. 8603 * User must subscribe to events to receive transcription results. 8604 * @member MeetingTranscriber.prototype.startTranscribingAsync 8605 * @function 8606 * @public 8607 * @param cb - Callback invoked once the transcription has started. 8608 * @param err - Callback invoked in case of an error. 8609 */ 8610 startTranscribingAsync(i, o) { 8611 this.privRecognizer.startContinuousRecognitionAsync(i, o); 8612 } 8613 /** 8614 * Starts meeting transcription, until stopTranscribingAsync() is called. 8615 * User must subscribe to events to receive transcription results. 8616 * @member MeetingTranscriber.prototype.stopTranscribingAsync 8617 * @function 8618 * @public 8619 * @param cb - Callback invoked once the transcription has started. 8620 * @param err - Callback invoked in case of an error. 8621 */ 8622 stopTranscribingAsync(i, o) { 8623 this.privRecognizer.stopContinuousRecognitionAsync(i, o); 8624 } 8625 /** 8626 * Leave the current meeting. After this is called, you will no longer receive any events. 8627 */ 8628 leaveMeetingAsync(i, o) { 8629 this.privRecognizer.disconnectCallbacks(), (0, e.marshalPromiseToCallbacks)((async () => { 8630 })(), i, o); 8631 } 8632 /** 8633 * closes all external resources held by an instance of this class. 8634 * @member MeetingTranscriber.prototype.close 8635 * @function 8636 * @public 8637 */ 8638 close(i, o) { 8639 r.Contracts.throwIfDisposed(this.privDisposedRecognizer), (0, e.marshalPromiseToCallbacks)(this.dispose(!0), i, o); 8640 } 8641 /**
8642 * Disposes any resources held by the object. 8643 * @member MeetingTranscriber.prototype.dispose 8644 * @function 8645 * @public 8646 * @param {boolean} disposing - true if disposing the object. 8647 */ 8648 async dispose(i) { 8649 this.privDisposedRecognizer || (this.privRecognizer && (await this.privRecognizer.close(), this.privRecognizer = void 0), i && (this.privDisposedRecognizer = !0)); 8650 } 8651 }; 8652 return Bt.MeetingTranscriber = a, Bt; 8653} 8654var qt = {}, lo; 8655function Ev() { 8656 if (lo) return qt; 8657 lo = 1, Object.defineProperty(qt, "__esModule", { value: !0 }), qt.ConversationTranscriptionResult = void 0; 8658 const t = R(); 8659 let e = class extends t.RecognitionResult { 8660 /** 8661 * Creates and initializes an instance of this class. 8662 * @constructor 8663 * @public 8664 * @param {string} resultId - The result id. 8665 * @param {ResultReason} reason - The reason. 8666 * @param {string} text - The recognized text. 8667 * @param {number} duration - The duration. 8668 * @param {number} offset - The offset into the stream. 8669 * @param {string} language - Primary Language detected, if provided. 8670 * @param {string} languageDetectionConfidence - Primary Language confidence ("Unknown," "Low," "Medium," "High"...), if provided. 8671 * @param {string} speakerId - speaker id for conversation transcription. 8672 * @param {string} errorDetails - Error details, if provided. 8673 * @param {string} json - Additional Json, if provided. 8674 * @param {PropertyCollection} properties - Additional properties, if provided. 8675 */ 8676 constructor(s, p, a, n, i, o, c, u, h, d, v) { 8677 super(s, p, a, n, i, o, c, h, d, v), this.privSpeakerId = u; 8678 } 8679 /** 8680 * speaker id 8681 * @member ConversationTranscriptionResult.prototype.speakerId 8682 * @function 8683 * @public 8684 * @returns {string} id of speaker in given result 8685 */ 8686 get speakerId() { 8687 return this.privSpeakerId; 8688 } 8689 }; 8690 return qt.ConversationTranscriptionResult = e, qt; 8691} 8692var fo; 8693function Hn() { 8694 return fo || (fo = 1, function(t) { 8695 Object.defineProperty(t, "__esModule", { value: !0 }), t.ConversationTranscriptionResult = t.MeetingTranscriber = t.MeetingTranscriptionCanceledEventArgs = t.MeetingImpl = t.Meeting = t.ParticipantChangedReason = t.User = t.Participant = t.ConversationTranscriber = t.ConversationTranslator = t.ConversationTranslationResult = t.ConversationTranslationEventArgs = t.ConversationTranslationCanceledEventArgs = t.ConversationParticipantsChangedEventArgs = t.ConversationExpirationEventArgs = t.ConversationCommon = t.ConversationImpl = t.Conversation = void 0; 8696 var e = hc(); 8697 Object.defineProperty(t, "Conversation", { enumerable: !0, get: function() { 8698 return e.Conversation; 8699 } }), Object.defineProperty(t, "ConversationImpl", { enumerable: !0, get: function() { 8700 return e.ConversationImpl; 8701 } }); 8702 var r = Ni; 8703 Object.defineProperty(t, "ConversationCommon", { enumerable: !0, get: function() { 8704 return r.ConversationCommon; 8705 } }); 8706 var s = uv(); 8707 Object.defineProperty(t, "ConversationExpirationEventArgs", { enumerable: !0, get: function() { 8708 return s.ConversationExpirationEventArgs; 8709 } }); 8710 var p = hv(); 8711 Object.defineProperty(t, "ConversationParticipantsChangedEventArgs", { enumerable: !0, get: function() { 8712 return p.ConversationParticipantsChangedEventArgs; 8713 } }); 8714 var a = dv(); 8715 Object.defineProperty(t, "ConversationTranslationCanceledEventArgs", { enumerable: !0, get: function() { 8716 return a.ConversationTranslationCanceledEventArgs; 8717 } }); 8718 var n = vv(); 8719 Object.defineProperty(t, "ConversationTranslationEventArgs", { enumerable: !0, get: function() { 8720 return n.ConversationTranslationEventArgs; 8721 } }); 8722 var i = lv(); 8723 Object.defineProperty(t, "ConversationTranslationResult", { enumerable: !0, get: function() { 8724 return i.ConversationTranslationResult; 8725 } }); 8726 var o = mv(); 8727 Object.defineProperty(t, "ConversationTranslator", { enumerable: !0, get: function() { 8728 return o.ConversationTranslator; 8729 } }); 8730 var c = Sv();
8731 Object.defineProperty(t, "ConversationTranscriber", { enumerable: !0, get: function() { 8732 return c.ConversationTranscriber; 8733 } }); 8734 var u = Cv(); 8735 Object.defineProperty(t, "Participant", { enumerable: !0, get: function() { 8736 return u.Participant; 8737 } }), Object.defineProperty(t, "User", { enumerable: !0, get: function() { 8738 return u.User; 8739 } }); 8740 var h = lc; 8741 Object.defineProperty(t, "ParticipantChangedReason", { enumerable: !0, get: function() { 8742 return h.ParticipantChangedReason; 8743 } }); 8744 var d = yv(); 8745 Object.defineProperty(t, "Meeting", { enumerable: !0, get: function() { 8746 return d.Meeting; 8747 } }), Object.defineProperty(t, "MeetingImpl", { enumerable: !0, get: function() { 8748 return d.MeetingImpl; 8749 } }); 8750 var v = Pv(); 8751 Object.defineProperty(t, "MeetingTranscriptionCanceledEventArgs", { enumerable: !0, get: function() { 8752 return v.MeetingTranscriptionCanceledEventArgs; 8753 } }); 8754 var f = Rv(); 8755 Object.defineProperty(t, "MeetingTranscriber", { enumerable: !0, get: function() { 8756 return f.MeetingTranscriber; 8757 } }); 8758 var m = Ev();
8759 Object.defineProperty(t, "ConversationTranscriptionResult", { enumerable: !0, get: function() { 8760 return m.ConversationTranscriptionResult; 8761 } }); 8762 }(Cn)), Cn; 8763} 8764var Ne = {}, go; 8765function Kn() { 8766 if (go) return Ne; 8767 go = 1, Object.defineProperty(Ne, "__esModule", { value: !0 }), Ne.SynthesisRequest = Ne.Synthesizer = void 0; 8768 const t = A(), e = I(), r = O, s = R(); 8769 let p = class fc { 8770 /** 8771 * Creates and initializes an instance of a Recognizer 8772 * @constructor 8773 * @param {SpeechConfig} speechConfig - The speech config to initialize the synthesizer. 8774 */ 8775 constructor(i) { 8776 const o = i; 8777 r.Contracts.throwIfNull(o, "speechConfig"), this.privProperties = o.properties.clone(), this.privDisposed = !1, this.privSynthesizing = !1, this.synthesisRequestQueue = new e.Queue(), this.tokenCredential = i.tokenCredential; 8778 } 8779 /** 8780 * Gets the authorization token used to communicate with the service. 8781 * @member Synthesizer.prototype.authorizationToken 8782 * @function 8783 * @public 8784 * @returns {string} Authorization token. 8785 */ 8786 get authorizationToken() { 8787 return this.properties.getProperty(s.PropertyId.SpeechServiceAuthorization_Token); 8788 } 8789 /** 8790 * Gets/Sets the authorization token used to communicate with the service. 8791 * @member Synthesizer.prototype.authorizationToken 8792 * @function 8793 * @public 8794 * @param {string} token - Authorization token. 8795 */ 8796 set authorizationToken(i) { 8797 r.Contracts.throwIfNullOrWhitespace(i, "token"), this.properties.setProperty(s.PropertyId.SpeechServiceAuthorization_Token, i); 8798 } 8799 /** 8800 * The collection of properties and their values defined for this Synthesizer. 8801 * @member Synthesizer.prototype.properties 8802 * @function 8803 * @public 8804 * @returns {PropertyCollection} The collection of properties and their values defined for this SpeechSynthesizer. 8805 */ 8806 get properties() { 8807 return this.privProperties; 8808 } 8809 /** 8810 * Indicates if auto detect source language is enabled 8811 * @member Synthesizer.prototype.autoDetectSourceLanguage 8812 * @function 8813 * @public 8814 * @returns {boolean} if auto detect source language is enabled 8815 */ 8816 get autoDetectSourceLanguage() { 8817 return this.properties.getProperty(s.PropertyId.SpeechServiceConnection_AutoDetectSourceLanguages) === t.AutoDetectSourceLanguagesOpenRangeOptionName; 8818 } 8819 buildSsml(i) { 8820 const o = { 8821 "af-ZA": "af-ZA-AdriNeural", 8822 "am-ET": "am-ET-AmehaNeural", 8823 "ar-AE": "ar-AE-FatimaNeural", 8824 "ar-BH": "ar-BH-AliNeural", 8825 "ar-DZ": "ar-DZ-AminaNeural", 8826 "ar-EG": "ar-EG-SalmaNeural", 8827 "ar-IQ": "ar-IQ-BasselNeural", 8828 "ar-JO": "ar-JO-SanaNeural", 8829 "ar-KW": "ar-KW-FahedNeural", 8830 "ar-LY": "ar-LY-ImanNeural", 8831 "ar-MA": "ar-MA-JamalNeural", 8832 "ar-QA": "ar-QA-AmalNeural", 8833 "ar-SA": "ar-SA-HamedNeural", 8834 "ar-SY": "ar-SY-AmanyNeural", 8835 "ar-TN": "ar-TN-HediNeural", 8836 "ar-YE": "ar-YE-MaryamNeural", 8837 "bg-BG": "bg-BG-BorislavNeural", 8838 "bn-BD": "bn-BD-NabanitaNeural", 8839 "bn-IN": "bn-IN-BashkarNeural", 8840 "ca-ES": "ca-ES-JoanaNeural", 8841 "cs-CZ": "cs-CZ-AntoninNeural", 8842 "cy-GB": "cy-GB-AledNeural", 8843 "da-DK": "da-DK-ChristelNeural", 8844 "de-AT": "de-AT-IngridNeural", 8845 "de-CH": "de-CH-JanNeural", 8846 "de-DE": "de-DE-KatjaNeural", 8847 "el-GR": "el-GR-AthinaNeural", 8848 "en-AU": "en-AU-NatashaNeural", 8849 "en-CA": "en-CA-ClaraNeural", 8850 "en-GB": "en-GB-LibbyNeural", 8851 "en-HK": "en-HK-SamNeural", 8852 "en-IE": "en-IE-ConnorNeural", 8853 "en-IN": "en-IN-NeerjaNeural", 8854 "en-KE": "en-KE-AsiliaNeural", 8855 "en-NG": "en-NG-AbeoNeural", 8856 "en-NZ": "en-NZ-MitchellNeural", 8857 "en-PH": "en-PH-JamesNeural", 8858 "en-SG": "en-SG-LunaNeural", 8859 "en-TZ": "en-TZ-ElimuNeural", 8860 "en-US": "en-US-AvaMultilingualNeural", 8861 "en-ZA": "en-ZA-LeahNeural", 8862 "es-AR": "es-AR-ElenaNeural", 8863 "es-BO": "es-BO-MarceloNeural", 8864 "es-CL": "es-CL-CatalinaNeural", 8865 "es-CO": "es-CO-GonzaloNeural", 8866 "es-CR": "es-CR-JuanNeural", 8867 "es-CU": "es-CU-BelkysNeural", 8868 "es-DO": "es-DO-EmilioNeural", 8869 "es-EC": "es-EC-AndreaNeural", 8870 "es-ES": "es-ES-AlvaroNeural", 8871 "es-GQ": "es-GQ-JavierNeural", 8872 "es-GT": "es-GT-AndresNeural", 8873 "es-HN": "es-HN-CarlosNeural", 8874 "es-MX": "es-MX-DaliaNeural", 8875 "es-NI": "es-NI-FedericoNeural", 8876 "es-PA": "es-PA-MargaritaNeural", 8877 "es-PE": "es-PE-AlexNeural", 8878 "es-PR": "es-PR-KarinaNeural", 8879 "es-PY": "es-PY-MarioNeural", 8880 "es-SV": "es-SV-LorenaNeural", 8881 "es-US": "es-US-AlonsoNeural", 8882 "es-UY": "es-UY-MateoNeural", 8883 "es-VE": "es-VE-PaolaNeural", 8884 "et-EE": "et-EE-AnuNeural", 8885 "fa-IR": "fa-IR-DilaraNeural", 8886 "fi-FI": "fi-FI-SelmaNeural", 8887 "fil-PH": "fil-PH-AngeloNeural", 8888 "fr-BE": "fr-BE-CharlineNeural", 8889 "fr-CA": "fr-CA-SylvieNeural", 8890 "fr-CH": "fr-CH-ArianeNeural", 8891 "fr-FR": "fr-FR-DeniseNeural", 8892 "ga-IE": "ga-IE-ColmNeural", 8893 "gl-ES": "gl-ES-RoiNeural",
8894 "gu-IN": "gu-IN-DhwaniNeural", 8895 "he-IL": "he-IL-AvriNeural", 8896 "hi-IN": "hi-IN-MadhurNeural", 8897 "hr-HR": "hr-HR-GabrijelaNeural", 8898 "hu-HU": "hu-HU-NoemiNeural", 8899 "id-ID": "id-ID-ArdiNeural", 8900 "is-IS": "is-IS-GudrunNeural", 8901 "it-IT": "it-IT-IsabellaNeural", 8902 "ja-JP": "ja-JP-NanamiNeural", 8903 "jv-ID": "jv-ID-DimasNeural", 8904 "kk-KZ": "kk-KZ-AigulNeural", 8905 "km-KH": "km-KH-PisethNeural", 8906 "kn-IN": "kn-IN-GaganNeural", 8907 "ko-KR": "ko-KR-SunHiNeural", 8908 "lo-LA": "lo-LA-ChanthavongNeural", 8909 "lt-LT": "lt-LT-LeonasNeural", 8910 "lv-LV": "lv-LV-EveritaNeural", 8911 "mk-MK": "mk-MK-AleksandarNeural", 8912 "ml-IN": "ml-IN-MidhunNeural", 8913 "mr-IN": "mr-IN-AarohiNeural", 8914 "ms-MY": "ms-MY-OsmanNeural", 8915 "mt-MT": "mt-MT-GraceNeural", 8916 "my-MM": "my-MM-NilarNeural", 8917 "nb-NO": "nb-NO-PernilleNeural", 8918 "nl-BE": "nl-BE-ArnaudNeural", 8919 "nl-NL": "nl-NL-ColetteNeural", 8920 "pl-PL": "pl-PL-AgnieszkaNeural", 8921 "ps-AF": "ps-AF-GulNawazNeural", 8922 "pt-BR": "pt-BR-FranciscaNeural", 8923 "pt-PT": "pt-PT-DuarteNeural", 8924 "ro-RO": "ro-RO-AlinaNeural", 8925 "ru-RU": "ru-RU-SvetlanaNeural", 8926 "si-LK": "si-LK-SameeraNeural", 8927 "sk-SK": "sk-SK-LukasNeural", 8928 "sl-SI": "sl-SI-PetraNeural", 8929 "so-SO": "so-SO-MuuseNeural", 8930 "sr-RS": "sr-RS-NicholasNeural", 8931 "su-ID": "su-ID-JajangNeural", 8932 "sv-SE": "sv-SE-SofieNeural", 8933 "sw-KE": "sw-KE-RafikiNeural", 8934 "sw-TZ": "sw-TZ-DaudiNeural", 8935 "ta-IN": "ta-IN-PallaviNeural", 8936 "ta-LK": "ta-LK-KumarNeural", 8937 "ta-SG": "ta-SG-AnbuNeural", 8938 "te-IN": "te-IN-MohanNeural", 8939 "th-TH": "th-TH-PremwadeeNeural", 8940 "tr-TR": "tr-TR-AhmetNeural", 8941 "uk-UA": "uk-UA-OstapNeural", 8942 "ur-IN": "ur-IN-GulNeural", 8943 "ur-PK": "ur-PK-AsadNeural", 8944 "uz-UZ": "uz-UZ-MadinaNeural", 8945 "vi-VN": "vi-VN-HoaiMyNeural", 8946 "zh-CN": "zh-CN-XiaoxiaoNeural", 8947 "zh-HK": "zh-HK-HiuMaanNeural", 8948 "zh-TW": "zh-TW-HsiaoChenNeural", 8949 "zu-ZA": "zu-ZA-ThandoNeural" 8950 }; 8951 let c = this.properties.getProperty(s.PropertyId.SpeechServiceConnection_SynthLanguage, "en-US"), u = this.properties.getProperty(s.PropertyId.SpeechServiceConnection_SynthVoice, ""), h = fc.XMLEncode(i); 8952 return this.autoDetectSourceLanguage ? c = "en-US" : u = u || o[c], u && (h = `<voice name='${u}'>${h}</voice>`), h = `<speak version='1.0' xmlns='http://www.w3.org/2001/10/synthesis' xmlns:mstts='http://www.w3.org/2001/mstts' xmlns:emo='http://www.w3.org/2009/10/emotionml' xml:lang='${c}'>${h}</speak>`, h; 8953 } 8954 /** 8955 * This method performs cleanup of resources. 8956 * The Boolean parameter disposing indicates whether the method is called 8957 * from Dispose (if disposing is true) or from the finalizer (if disposing is false). 8958 * Derived classes should override this method to dispose resource if needed. 8959 * @member Synthesizer.prototype.dispose 8960 * @function 8961 * @public 8962 * @param {boolean} disposing - Flag to request disposal. 8963 */ 8964 async dispose(i) { 8965 this.privDisposed || (i && this.privAdapter && await this.privAdapter.dispose(), this.privDisposed = !0); 8966 } 8967 async adapterSpeak() { 8968 if (!this.privDisposed && !this.privSynthesizing) { 8969 this.privSynthesizing = !0; 8970 const i = await this.synthesisRequestQueue.dequeue(); 8971 return this.privAdapter.Speak(i.text, i.isSSML, i.requestId, i.cb, i.err, i.dataStream); 8972 } 8973 } 8974 createSynthesizerConfig(i) { 8975 return new t.SynthesizerConfig(i, this.privProperties); 8976 } 8977 // Does the generic synthesizer setup that is common across all synthesizer types. 8978 implCommonSynthesizeSetup() { 8979 let i = typeof window < "u" ? "Browser" : "Node", o = "unknown", c = "unknown"; 8980 typeof navigator < "u" && (i = i + "/" + navigator.platform, o = navigator.userAgent, c = navigator.appVersion); 8981 const u = this.createSynthesizerConfig(new t.SpeechServiceConfig(new t.Context(new t.OS(i, o, c)))), h = this.privProperties.getProperty(s.PropertyId.SpeechServiceConnection_Key, void 0), d = h && h !== "" ? new t.CognitiveSubscriptionKeyAuthentication(h) : this.tokenCredential ? new t.CognitiveTokenAuthentication(async () => { 8982 try { 8983 const v = await this.tokenCredential.getToken("https://cognitiveservices.azure.com/.default"); 8984 return (v == null ? void 0 : v.token) ?? ""; 8985 } catch (v) { 8986 throw v; 8987 } 8988 }, async () => { 8989 try { 8990 const v = await this.tokenCredential.getToken("https://cognitiveservices.azure.com/.default"); 8991 return (v == null ? void 0 : v.token) ?? ""; 8992 } catch (v) { 8993 throw v; 8994 } 8995 }) : new t.CognitiveTokenAuthentication(() => { 8996 const v = this.privProperties.getProperty(s.PropertyId.SpeechServiceAuthorization_Token, void 0); 8997 return Promise.resolve(v); 8998 }, () => { 8999 const v = this.privProperties.getProperty(s.PropertyId.SpeechServiceAuthorization_Token, void 0); 9000 return Promise.resolve(v); 9001 }); 9002 this.privAdapter = this.createSynthesisAdapter(d, this.privConnectionFactory, u), this.privRestAdapter = this.createRestSynthesisAdapter(d, u); 9003 } 9004 static XMLEncode(i) { 9005 return i.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'"); 9006 } 9007 }; 9008 Ne.Synthesizer = p; 9009 class a { 9010 constructor(i, o, c, u, h, d) { 9011 this.requestId = i, this.text = o, this.isSSML = c, this.cb = u, this.err = h, this.dataStream = d; 9012 } 9013 } 9014 return Ne.SynthesisRequest = a, Ne; 9015} 9016var Ft = {}, mo; 9017function Tv() { 9018 if (mo) return Ft; 9019 mo = 1, Object.defineProperty(Ft, "__esModule", { value: !0 }), Ft.SpeechSynthesizer = void 0;
9020 const t = A(), e = I(), r = Nr, s = Ie, p = U, a = O, n = R(), i = Kn(); 9021 let o = class gc extends n.Synthesizer { 9022 /** 9023 * SpeechSynthesizer constructor. 9024 * @constructor 9025 * @param {SpeechConfig} speechConfig - An set of initial properties for this synthesizer. 9026 * @param {AudioConfig} audioConfig - An optional audio configuration associated with the synthesizer. 9027 */ 9028 constructor(u, h) { 9029 super(u), h !== null && (h === void 0 ? this.audioConfig = typeof window > "u" ? void 0 : n.AudioConfig.fromDefaultSpeakerOutput() : this.audioConfig = h), this.privConnectionFactory = new t.SpeechSynthesisConnectionFactory(), this.implCommonSynthesizeSetup(); 9030 } 9031 /** 9032 * SpeechSynthesizer constructor. 9033 * @constructor 9034 * @param {SpeechConfig} speechConfig - an set of initial properties for this synthesizer 9035 * @param {AutoDetectSourceLanguageConfig} autoDetectSourceLanguageConfig - An source language detection configuration associated with the synthesizer 9036 * @param {AudioConfig} audioConfig - An optional audio configuration associated with the synthesizer 9037 */ 9038 static FromConfig(u, h, d) { 9039 const v = u; 9040 return h.properties.mergeTo(v.properties), new gc(u, d); 9041 } 9042 /** 9043 * Executes speech synthesis on plain text. 9044 * The task returns the synthesis result. 9045 * @member SpeechSynthesizer.prototype.speakTextAsync 9046 * @function 9047 * @public 9048 * @param text - Text to be synthesized. 9049 * @param cb - Callback that received the SpeechSynthesisResult. 9050 * @param err - Callback invoked in case of an error. 9051 * @param stream - AudioOutputStream to receive the synthesized audio. 9052 */ 9053 speakTextAsync(u, h, d, v) { 9054 this.speakImpl(u, !1, h, d, v); 9055 } 9056 /** 9057 * Executes speech synthesis on SSML. 9058 * The task returns the synthesis result. 9059 * @member SpeechSynthesizer.prototype.speakSsmlAsync 9060 * @function 9061 * @public 9062 * @param ssml - SSML to be synthesized. 9063 * @param cb - Callback that received the SpeechSynthesisResult. 9064 * @param err - Callback invoked in case of an error. 9065 * @param stream - AudioOutputStream to receive the synthesized audio. 9066 */ 9067 speakSsmlAsync(u, h, d, v) { 9068 this.speakImpl(u, !0, h, d, v); 9069 } 9070 /** 9071 * Get list of synthesis voices available. 9072 * The task returns the synthesis voice result. 9073 * @member SpeechSynthesizer.prototype.getVoicesAsync 9074 * @function 9075 * @async 9076 * @public 9077 * @param locale - Locale of voices in BCP-47 format; if left empty, get all available voices. 9078 * @return {Promise<SynthesisVoicesResult>} - Promise of a SynthesisVoicesResult. 9079 */ 9080 async getVoicesAsync(u = "") { 9081 return this.getVoices(u); 9082 } 9083 /** 9084 * Dispose of associated resources. 9085 * @member SpeechSynthesizer.prototype.close 9086 * @function 9087 * @public 9088 */ 9089 close(u, h) { 9090 a.Contracts.throwIfDisposed(this.privDisposed), (0, e.marshalPromiseToCallbacks)(this.dispose(!0), u, h); 9091 } 9092 /** 9093 * @Internal 9094 * Do not use externally, object returned will change without warning or notice. 9095 */ 9096 get internalData() { 9097 return this.privAdapter; 9098 } 9099 // 9100 // ################################################################################################################ 9101 // IMPLEMENTATION. 9102 // ################################################################################################################ 9103 // 9104 // Creates the synthesis adapter 9105 createSynthesisAdapter(u, h, d) { 9106 return new t.SpeechSynthesisAdapter(u, h, d, this, this.audioConfig); 9107 } 9108 createRestSynthesisAdapter(u, h) { 9109 return new t.SynthesisRestAdapter(h, u); 9110 } 9111 implCommonSynthesizeSetup() { 9112 super.implCommonSynthesizeSetup(), this.privAdapter.audioOutputFormat = s.AudioOutputFormatImpl.fromSpeechSynthesisOutputFormat(n.SpeechSynthesisOutputFormat[this.properties.getProperty(n.PropertyId.SpeechServiceConnection_SynthOutputFormat, void 0)]); 9113 } 9114 speakImpl(u, h, d, v, f) { 9115 try { 9116 a.Contracts.throwIfDisposed(this.privDisposed); 9117 const m = (0, e.createNoDashGuid)(); 9118 let S; 9119 f instanceof n.PushAudioOutputStreamCallback ? S = new p.PushAudioOutputStreamImpl(f) : f instanceof n.PullAudioOutputStream ? S = f : f !== void 0 ? S = new r.AudioFileWriter(f) : S = void 0, this.synthesisRequestQueue.enqueue(new i.SynthesisRequest(m, u, h, (l) => { 9120 if (this.privSynthesizing = !1, d) 9121 try { 9122 d(l); 9123 } catch (g) { 9124 v && v(g); 9125 } 9126 d = void 0, this.adapterSpeak().catch(() => { 9127 }); 9128 }, (l) => { 9129 v && v(l); 9130 }, S)), this.adapterSpeak().catch(() => { 9131 }); 9132 } catch (m) { 9133 if (v) 9134 if (m instanceof Error) { 9135 const S = m; 9136 v(S.name + ": " + S.message); 9137 } else 9138 v(m); 9139 this.dispose(!0).catch(() => { 9140 }); 9141 } 9142 } 9143 async getVoices(u) { 9144 const h = (0, e.createNoDashGuid)(), d = await this.privRestAdapter.getVoicesList(h); 9145 if (d.ok && Array.isArray(d.json)) { 9146 let v = d.json; 9147 return u && u.length > 0 && (v = v.filter((f) => !!f.Locale && f.Locale.toLowerCase() === u.toLowerCase())), new n.SynthesisVoicesResult(h, v, void 0); 9148 } else 9149 return new n.SynthesisVoicesResult(h, void 0, `Error: ${d.status}: ${d.statusText}`); 9150 } 9151 }; 9152 return Ft.SpeechSynthesizer = o, Ft; 9153} 9154var zi = {}; 9155Object.defineProperty(zi, "__esModule", { value: !0 }); 9156zi.SynthesisResult = void 0; 9157class Av { 9158 /** 9159 * Creates and initializes an instance of this class. 9160 * @constructor 9161 * @param {string} resultId - The result id. 9162 * @param {ResultReason} reason - The reason. 9163 * @param {string} errorDetails - Error details, if provided. 9164 * @param {PropertyCollection} properties - Additional properties, if provided. 9165 */ 9166 constructor(e, r, s, p) { 9167 this.privResultId = e, this.privReason = r, this.privErrorDetails = s, this.privProperties = p; 9168 } 9169 /** 9170 * Specifies the result identifier. 9171 * @member SynthesisResult.prototype.resultId 9172 * @function 9173 * @public 9174 * @returns {string} Specifies the result identifier. 9175 */ 9176 get resultId() { 9177 return this.privResultId; 9178 } 9179 /** 9180 * Specifies status of the result. 9181 * @member SynthesisResult.prototype.reason 9182 * @function 9183 * @public 9184 * @returns {ResultReason} Specifies status of the result. 9185 */ 9186 get reason() { 9187 return this.privReason; 9188 } 9189 /** 9190 * In case of an unsuccessful synthesis, provides details of the occurred error. 9191 * @member SynthesisResult.prototype.errorDetails 9192 * @function 9193 * @public 9194 * @returns {string} a brief description of an error. 9195 */ 9196 get errorDetails() { 9197 return this.privErrorDetails; 9198 } 9199 /** 9200 * The set of properties exposed in the result. 9201 * @member SynthesisResult.prototype.properties 9202 * @function 9203 * @public 9204 * @returns {PropertyCollection} The set of properties exposed in the result. 9205 */ 9206 get properties() { 9207 return this.privProperties; 9208 } 9209} 9210zi.SynthesisResult = Av; 9211var Ut = {}, So; 9212function Iv() { 9213 if (So) return Ut; 9214 So = 1, Object.defineProperty(Ut, "__esModule", { value: !0 }), Ut.SpeechSynthesisResult = void 0; 9215 const t = R(); 9216 let e = class extends t.SynthesisResult { 9217 /** 9218 * Creates and initializes an instance of this class. 9219 * @constructor 9220 * @param {string} resultId - The result id. 9221 * @param {ResultReason} reason - The reason. 9222 * @param {ArrayBuffer} audioData - The synthesized audio binary. 9223 * @param {string} errorDetails - Error details, if provided. 9224 * @param {PropertyCollection} properties - Additional properties, if provided. 9225 * @param {number} audioDuration - The audio duration. 9226 */ 9227 constructor(s, p, a, n, i, o) { 9228 super(s, p, n, i), this.privAudioData = a, this.privAudioDuration = o; 9229 } 9230 /** 9231 * The synthesized audio data 9232 * @member SpeechSynthesisResult.prototype.audioData 9233 * @function 9234 * @public 9235 * @returns {ArrayBuffer} The synthesized audio data. 9236 */ 9237 get audioData() { 9238 return this.privAudioData; 9239 } 9240 /** 9241 * The time duration of synthesized audio, in ticks (100 nanoseconds). 9242 * @member SpeechSynthesisResult.prototype.audioDuration 9243 * @function 9244 * @public 9245 * @returns {number} The time duration of synthesized audio. 9246 */ 9247 get audioDuration() { 9248 return this.privAudioDuration; 9249 } 9250 }; 9251 return Ut.SpeechSynthesisResult = e, Ut; 9252} 9253var ji = {}; 9254Object.defineProperty(ji, "__esModule", { value: !0 }); 9255ji.SpeechSynthesisEventArgs = void 0; 9256class wv { 9257 /** 9258 * Creates and initializes an instance of this class. 9259 * @constructor 9260 * @param {SpeechSynthesisResult} result - The speech synthesis result. 9261 */ 9262 constructor(e) { 9263 this.privResult = e; 9264 } 9265 /** 9266 * Specifies the synthesis result. 9267 * @member SpeechSynthesisEventArgs.prototype.result 9268 * @function 9269 * @public 9270 * @returns {SpeechSynthesisResult} the synthesis result. 9271 */ 9272 get result() { 9273 return this.privResult; 9274 } 9275} 9276ji.SpeechSynthesisEventArgs = wv; 9277var Li = {}; 9278Object.defineProperty(Li, "__esModule", { value: !0 }); 9279Li.SpeechSynthesisWordBoundaryEventArgs = void 0; 9280class _v { 9281 /** 9282 * Creates and initializes an instance of this class. 9283 * @constructor 9284 * @param {number} audioOffset - The audio offset. 9285 * @param {number} duration - The audio duration. 9286 * @param {string} text - The text. 9287 * @param {number} wordLength - The length of the word. 9288 * @param {number} textOffset - The text offset. 9289 * @param {SpeechSynthesisBoundaryType} boundaryType - The boundary type 9290 */ 9291 constructor(e, r, s, p, a, n) { 9292 this.privAudioOffset = e, this.privDuration = r, this.privText = s, this.privWordLength = p, this.privTextOffset = a, this.privBoundaryType = n; 9293 } 9294 /** 9295 * Specifies the audio offset. 9296 * @member SpeechSynthesisWordBoundaryEventArgs.prototype.audioOffset 9297 * @function 9298 * @public 9299 * @returns {number} the audio offset. 9300 */ 9301 get audioOffset() { 9302 return this.privAudioOffset; 9303 } 9304 /** 9305 * Specifies the duration, in ticks (100 nanoseconds). 9306 * @member SpeechSynthesisWordBoundaryEventArgs.prototype.duration 9307 * @function 9308 * @public 9309 * @returns {number} Duration in 100 nanosecond increments. 9310 */ 9311 get duration() { 9312 return this.privDuration; 9313 } 9314 /** 9315 * Specifies the text of the word boundary event. 9316 * @member SpeechSynthesisWordBoundaryEventArgs.prototype.text 9317 * @function 9318 * @public 9319 * @returns {string} the text. 9320 */ 9321 get text() { 9322 return this.privText; 9323 } 9324 /** 9325 * Specifies the word length 9326 * @member SpeechSynthesisWordBoundaryEventArgs.prototype.wordLength 9327 * @function 9328 * @public 9329 * @returns {number} the word length 9330 */ 9331 get wordLength() { 9332 return this.privWordLength; 9333 } 9334 /** 9335 * Specifies the text offset. 9336 * @member SpeechSynthesisWordBoundaryEventArgs.prototype.textOffset 9337 * @function 9338 * @public 9339 * @returns {number} the text offset. 9340 */ 9341 get textOffset() { 9342 return this.privTextOffset; 9343 } 9344 /** 9345 * Specifies the boundary type. 9346 * @member SpeechSynthesisWordBoundaryEventArgs.prototype.boundaryType 9347 * @function 9348 * @public 9349 * @returns {SpeechSynthesisBoundaryType} the boundary type. 9350 */ 9351 get boundaryType() { 9352 return this.privBoundaryType; 9353 } 9354} 9355Li.SpeechSynthesisWordBoundaryEventArgs = _v; 9356var Bi = {}; 9357Object.defineProperty(Bi, "__esModule", { value: !0 }); 9358Bi.SpeechSynthesisBookmarkEventArgs = void 0; 9359class bv { 9360 /** 9361 * Creates and initializes an instance of this class. 9362 * @constructor 9363 * @param {number} audioOffset - The audio offset. 9364 * @param {string} text - The bookmark text. 9365 */ 9366 constructor(e, r) { 9367 this.privAudioOffset = e, this.privText = r; 9368 } 9369 /** 9370 * Specifies the audio offset. 9371 * @member SpeechSynthesisBookmarkEventArgs.prototype.audioOffset 9372 * @function 9373 * @public 9374 * @returns {number} the audio offset. 9375 */ 9376 get audioOffset() { 9377 return this.privAudioOffset; 9378 } 9379 /** 9380 * Specifies the bookmark. 9381 * @member SpeechSynthesisBookmarkEventArgs.prototype.text 9382 * @function 9383 * @public 9384 * @returns {string} the bookmark text. 9385 */ 9386 get text() { 9387 return this.privText; 9388 } 9389} 9390Bi.SpeechSynthesisBookmarkEventArgs = bv; 9391var qi = {}; 9392Object.defineProperty(qi, "__esModule", { value: !0 }); 9393qi.SpeechSynthesisVisemeEventArgs = void 0; 9394class Mv { 9395 /** 9396 * Creates and initializes an instance of this class. 9397 * @constructor 9398 * @param {number} audioOffset - The audio offset. 9399 * @param {number} visemeId - The viseme ID. 9400 * @param {string} animation - The animation, could be in svg or other format. 9401 */ 9402 constructor(e, r, s) { 9403 this.privAudioOffset = e, this.privVisemeId = r, this.privAnimation = s; 9404 } 9405 /** 9406 * Specifies the audio offset. 9407 * @member SpeechSynthesisVisemeEventArgs.prototype.audioOffset 9408 * @function 9409 * @public 9410 * @returns {number} the audio offset. 9411 */ 9412 get audioOffset() { 9413 return this.privAudioOffset; 9414 } 9415 /** 9416 * Specifies the viseme ID. 9417 * @member SpeechSynthesisVisemeEventArgs.prototype.visemeId 9418 * @function 9419 * @public 9420 * @returns {number} the viseme ID. 9421 */ 9422 get visemeId() { 9423 return this.privVisemeId; 9424 } 9425 /** 9426 * Specifies the animation. 9427 * @member SpeechSynthesisVisemeEventArgs.prototype.animation 9428 * @function 9429 * @public 9430 * @returns {string} the animation, could be in svg or other format. 9431 */ 9432 get animation() { 9433 return this.privAnimation; 9434 } 9435} 9436qi.SpeechSynthesisVisemeEventArgs = Mv; 9437var mc = {}; 9438(function(t) { 9439 Object.defineProperty(t, "__esModule", { value: !0 }), t.SpeechSynthesisBoundaryType = void 0, function(e) { 9440 e.Word = "WordBoundary", e.Punctuation = "PunctuationBoundary", e.Sentence = "SentenceBoundary"; 9441 }(t.SpeechSynthesisBoundaryType || (t.SpeechSynthesisBoundaryType = {})); 9442})(mc); 9443var xt = {}, Co; 9444function Ov() { 9445 if (Co) return xt; 9446 Co = 1, Object.defineProperty(xt, "__esModule", { value: !0 }), xt.SynthesisVoicesResult = void 0; 9447 const t = R(); 9448 let e = class extends t.SynthesisResult { 9449 /** 9450 * Creates and initializes an instance of this class. 9451 * @constructor 9452 * @param requestId - result id for request. 9453 * @param json - json payload from endpoint. 9454 */ 9455 constructor(s, p, a) { 9456 if (Array.isArray(p)) { 9457 super(s, t.ResultReason.VoicesListRetrieved, void 0, new t.PropertyCollection()), this.privVoices = []; 9458 for (const n of p) 9459 this.privVoices.push(new t.VoiceInfo(n)); 9460 } else 9461 super(s, t.ResultReason.Canceled, a || "Error information unavailable", new t.PropertyCollection()); 9462 } 9463 /** 9464 * The list of voices 9465 * @member SynthesisVoicesResult.prototype.voices 9466 * @function 9467 * @public 9468 * @returns {VoiceInfo[]} List of synthesized voices. 9469 */ 9470 get voices() { 9471 return this.privVoices; 9472 } 9473 }; 9474 return xt.SynthesisVoicesResult = e, xt; 9475} 9476var Sc = {}; 9477(function(t) { 9478 Object.defineProperty(t, "__esModule", { value: !0 }
9478), t.VoiceInfo = t.SynthesisVoiceType = t.SynthesisVoiceGender = void 0; 9479 var e; 9480 (function(n) { 9481 n[n.Unknown = 0] = "Unknown", n[n.Female = 1] = "Female", n[n.Male = 2] = "Male", n[n.Neutral = 3] = "Neutral"; 9482 })(e = t.SynthesisVoiceGender || (t.SynthesisVoiceGender = {})); 9483 var r; 9484 (function(n) { 9485 n[n.Unknown = 0] = "Unknown", n[n.OnlineNeural = 1] = "OnlineNeural", n[n.OnlineStandard = 2] = "OnlineStandard", n[n.OfflineNeural = 3] = "OfflineNeural", n[n.OfflineStandard = 4] = "OfflineStandard", n[n.OnlineNeuralHD = 5] = "OnlineNeuralHD"; 9486 })(r = t.SynthesisVoiceType || (t.SynthesisVoiceType = {})); 9487 const s = { 9488 [e[e.Neutral]]: e.Neutral, 9489 [e[e.Male]]: e.Male, 9490 [e[e.Female]]: e.Female 9491 }, p = { 9492 Neural: r.OnlineNeural, 9493 NeuralHD: r.OnlineNeuralHD 9494 }; 9495 class a { 9496 constructor(i) { 9497 if (this.privStyleList = [], i) { 9498 if (this.privName = i.Name, this.privLocale = i.Locale, this.privShortName = i.ShortName, this.privLocaleName = i.LocaleName, this.privDisplayName = i.DisplayName, this.privLocalName = i.LocalName, this.privVoiceType = p[i.VoiceType] || r.Unknown, this.privGender = s[i.Gender] || e.Unknown, i.StyleList && Array.isArray(i.StyleList)) 9499 for (const o of i.StyleList) 9500 this.privStyleList.push(o); 9501 this.privSampleRateHertz = i.SampleRateHertz, this.privStatus = i.Status, i.ExtendedPropertyMap && (this.privExtendedPropertyMap = i.ExtendedPropertyMap), this.privWordsPerMinute = i.WordsPerMinute, Array.isArray(i.SecondaryLocaleList) && (this.privSecondaryLocaleList = [...i.SecondaryLocaleList]), Array.isArray(i.RolePlayList) && (this.privRolePlayList = [...i.RolePlayList]), i.VoiceTag && (this.privVoiceTag = i.VoiceTag); 9502 } 9503 } 9504 get name() { 9505 return this.privName; 9506 } 9507 get locale() { 9508 return this.privLocale; 9509 } 9510 get shortName() { 9511 return this.privShortName; 9512 } 9513 get displayName() { 9514 return this.privDisplayName; 9515 } 9516 get localName() { 9517 return this.privLocalName; 9518 } 9519 get localeName() { 9520 return this.privLocaleName; 9521 } 9522 get gender() { 9523 return this.privGender; 9524 } 9525 get voiceType() { 9526 return this.privVoiceType; 9527 } 9528 get styleList() { 9529 return this.privStyleList; 9530 } 9531 get sampleRateHertz() { 9532 return this.privSampleRateHertz; 9533 } 9534 get status() { 9535 return this.privStatus; 9536 } 9537 get extendedPropertyMap() { 9538 return this.privExtendedPropertyMap; 9539 } 9540 get wordsPerMinute() { 9541 return this.privWordsPerMinute; 9542 } 9543 get secondaryLocaleList() { 9544 return this.privSecondaryLocaleList; 9545 } 9546 get rolePlayList() { 9547 return this.privRolePlayList; 9548 } 9549 get voiceTag() { 9550 return this.privVoiceTag; 9551 } 9552 } 9553 t.VoiceInfo = a; 9554})(Sc); 9555var Fi = {}; 9556Object.defineProperty(Fi, "__esModule", { value: !0 }); 9557Fi.SpeakerAudioDestination = void 0; 9558const ze = I(), Dv = U, te = Ae, kv = 60 * 30, yo = { 9559 [te.AudioFormatTag.PCM]: "audio/wav", 9560 [te.AudioFormatTag.MuLaw]: "audio/x-wav", 9561 [te.AudioFormatTag.MP3]: "audio/mpeg", 9562 [te.AudioFormatTag.OGG_OPUS]: "audio/ogg", 9563 [te.AudioFormatTag.WEBM_OPUS]: "audio/webm; codecs=opus", 9564 [te.AudioFormatTag.ALaw]: "audio/x-wav", 9565 [te.AudioFormatTag.FLAC]: "audio/flac", 9566 [te.AudioFormatTag.AMR_WB]: "audio/amr-wb", 9567 [te.AudioFormatTag.G722]: "audio/G722" 9568}; 9569class Nv { 9570 constructor(e) { 9571 this.privPlaybackStarted = !1, this.privAppendingToBuffer = !1, this.privMediaSourceOpened = !1, this.privBytesReceived = 0, this.privId = e || (0, ze.createNoDashGuid)(), this.privIsPaused = !1, this.privIsClosed = !1; 9572 } 9573 id() { 9574 return this.privId; 9575 } 9576 write(e, r, s) { 9577 this.privAudioBuffer !== void 0 ? (this.privAudioBuffer.push(e), this.updateSourceBuffer().then(() => { 9578 r && r(); 9579 }, (p) => { 9580 s && s(p); 9581 })) : this.privAudioOutputStream !== void 0 && (this.privAudioOutputStream.write(e), this.privBytesReceived += e.byteLength); 9582 } 9583 close(e, r) { 9584 if (this.privIsClosed = !0, this.privSourceBuffer !== void 0) 9585 this.handleSourceBufferUpdateEnd().then(() => { 9586 e && e(); 9587 }, (s) => { 9588 r && r(s); 9589 }); 9590 else if (this.privAudioOutputStream !== void 0 && typeof window < "u") 9591 if ((this.privFormat.formatTag === te.AudioFormatTag.PCM || this.privFormat.formatTag === te.AudioFormatTag.MuLaw || this.privFormat.formatTag === te.AudioFormatTag.ALaw) && this.privFormat.hasHeader === !1) 9592 console.warn("Play back is not supported for raw PCM, mulaw or alaw format without header."), this.onAudioEnd && this.onAudioEnd(this); 9593 else { 9594 let s = new ArrayBuffer(this.privBytesReceived); 9595 this.privAudioOutputStream.read(s).then(() => { 9596 s = this.privFormat.addHeader(s); 9597 const p = new Blob([s], { type: yo[this.privFormat.formatTag] }); 9598 this.privAudio.src = window.URL.createObjectURL(p), this.notifyPlayback().then(() => { 9599 e && e(); 9600 }, (a) => { 9601 r && r(a); 9602 }); 9603 }, (p) => { 9604 r && r(p); 9605 }); 9606 } 9607 else 9608 this.onAudioEnd && this.onAudioEnd(this); 9609 } 9610 set format(e) { 9611 if (typeof AudioContext < "u" || typeof window < "u" && typeof window.webkitAudioContext < "u") { 9612 this.privFormat = e; 9613 const r = yo[this.privFormat.formatTag]; 9614 r === void 0 ? console.warn(`Unknown mimeType for format ${te.AudioFormatTag[this.privFormat.formatTag]}; playback is not supported.`) : typeof MediaSource < "u" && MediaSource.isTypeSupp
9614orted(r) ? (this.privAudio = new Audio(), this.privAudioBuffer = [], this.privMediaSource = new MediaSource(), this.privAudio.src = URL.createObjectURL(this.privMediaSource), this.privAudio.load(), this.privMediaSource.onsourceopen = () => { 9615 this.privMediaSourceOpened = !0, this.privMediaSource.duration = kv, this.privSourceBuffer = this.privMediaSource.addSourceBuffer(r), this.privSourceBuffer.onupdate = () => { 9616 this.updateSourceBuffer().catch((s) => { 9617 ze.Events.instance.onEvent(new ze.BackgroundEvent(s)); 9618 }); 9619 }, this.privSourceBuffer.onupdateend = () => { 9620 this.handleSourceBufferUpdateEnd().catch((s) => { 9621 ze.Events.instance.onEvent(new ze.BackgroundEvent(s)); 9622 }); 9623 }, this.privSourceBuffer.onupdatestart = () => { 9624 this.privAppendingToBuffer = !1; 9625 }; 9626 }, this.updateSourceBuffer().catch((s) => { 9627 ze.Events.instance.onEvent(new ze.BackgroundEvent(s)); 9628 })) : (console.warn(`Format ${te.AudioFormatTag[this.privFormat.formatTag]} could not be played by MSE, streaming playback is not enabled.`), this.privAudioOutputStream = new Dv.PullAudioOutputStreamImpl(), this.privAudioOutputStream.format = this.privFormat, this.privAudio = new Audio()); 9629 } 9630 } 9631 get volume() { 9632 var e; 9633 return ((e = this.privAudio) == null ? void 0 : e.volume) ?? -1; 9634 } 9635 set volume(e) { 9636 this.privAudio && (this.privAudio.volume = e); 9637 } 9638 mute() { 9639 this.privAudio && (this.privAudio.muted = !0); 9640 } 9641 unmute() { 9642 this.privAudio && (this.privAudio.muted = !1); 9643 } 9644 get isClosed() { 9645 return this.privIsClosed; 9646 } 9647 get currentTime() { 9648 return this.privAudio !== void 0 ? this.privAudio.currentTime : -1; 9649 } 9650 pause() { 9651 !this.privIsPaused && this.privAudio !== void 0 && (this.privAudio.pause(), this.privIsPaused = !0); 9652 } 9653 resume(e, r) { 9654 this.privIsPaused && this.privAudio !== void 0 && (this.privAudio.play().then(() => { 9655 e && e(); 9656 }, (s) => { 9657 r && r(s); 9658 }), this.privIsPaused = !1); 9659 } 9660 get internalAudio() { 9661 return this.privAudio; 9662 } 9663 async updateSourceBuffer() { 9664 if (this.privAudioBuffer !== void 0 && this.privAudioBuffer.length > 0 && this.sourceBufferAvailable()) { 9665 this.privAppendingToBuffer = !0; 9666 const e = this.privAudioBuffer.shift(); 9667 try { 9668 this.privSourceBuffer.appendBuffer(e); 9669 } catch { 9670 this.privAudioBuffer.unshift(e), console.log("buffer filled, pausing addition of binaries until space is made"); 9671 return; 9672 } 9673 await this.notifyPlayback(); 9674 } else this.canEndStream() && await this.handleSourceBufferUpdateEnd(); 9675 } 9676 async handleSourceBufferUpdateEnd() { 9677 this.canEndStream() && this.sourceBufferAvailable() && (this.privMediaSource.endOfStream(), await this.notifyPlayback()); 9678 } 9679 async notifyPlayback() { 9680 !this.privPlaybackStarted && this.privAudio !== void 0 && (this.privPlaybackStarted = !0, this.onAudioStart && this.onAudioStart(this), this.privAudio.onended = () => { 9681 this.onAudioEnd && this.onAudioEnd(this); 9682 }, this.privIsPaused || await this.privAudio.play()); 9683 } 9684 canEndStream() { 9685 return this.isClosed && this.privSourceBuffer !== void 0 && this.privAudioBuffer.length === 0 && this.privMediaSourceOpened && !this.privAppendingToBuffer && this.privMediaSource.readyState === "open"; 9686 } 9687 sourceBufferAvailable() { 9688 return this.privSourceBuffer !== void 0 && !this.privSourceBuffer.updating; 9689 } 9690} 9691Fi.SpeakerAudioDestination = Nv; 9692var Wt = {}, Po; 9693function zv() { 9694 if (Po) return Wt; 9695 Po = 1, Object.defineProperty(Wt, "__esModule", { value: !0 }), Wt.ConversationTranscriptionCanceledEventArgs = void 0; 9696 const t = zr(); 9697 let e = class extends t.CancellationEventArgsBase { 9698 }; 9699 return Wt.ConversationTranscriptionCanceledEventArgs = e, Wt; 9700} 9701var Ht = {}, Ro; 9702function jv() { 9703 if (Ro) return Ht; 9704 Ro = 1, Object.defineProperty(Ht, "__esModule", { value: !0 }), Ht.MeetingTranscriptionCanceledEventArgs = void 0; 9705 const t = zr(); 9706 let e = class extends t.CancellationEventArgsBase { 9707 }; 9708 return Ht.MeetingTranscriptionCanceledEventArgs = e, Ht; 9709} 9710var Cc = {}; 9711(function(t) { 9712 Object.defineProperty(t, "__esModule", { value: !0 }), t.PronunciationAssessmentGradingSystem = void 0, function(e) { 9713 e[e.FivePoint = 1] = "FivePoint", e[e.HundredMark = 2] = "HundredMark"; 9714 }(t.PronunciationAssessmentGradingSystem || (t.PronunciationAssessmentGradingSystem = {})); 9715})(Cc); 9716var yc = {}; 9717(function(t) { 9718 Object.defineProperty(t, "__esModule", { value: !0 }), t.PronunciationAssessmentGranularity = void 0, function(e) { 9719 e[e.Phoneme = 1] = "Phoneme", e[e.Word = 2] = "Word", e[e.FullText = 3] = "FullText"; 9720 }(t.PronunciationAssessmentGranularity || (t.PronunciationAssessmentGranularity = {})); 9721})(yc); 9722var Kt = {}, Eo; 9723function Lv() { 9724 if (Eo) return Kt; 9725 Eo = 1, Object.defineProperty(Kt, "__esModule", { value: !0 }), Kt.PronunciationAssessmentConfig = void 0; 9726 const t = O, e = R(); 9727 let r = class Pc { 9728 /** 9729 * PronunciationAssessmentConfig constructor. 9730 * @constructor 9731 * @param {string} referenceText 9732 * @param gradingSystem 9733 * @param granularity 9734 * @param enableMiscue 9735 */ 9736 constructor(p, a = e.PronunciationAssessmentGradingSystem.FivePoint, n = e.PronunciationAssessmentGranularity.Phoneme, i = !1) { 9737 t.Contracts.throwIfNullOrUndefined(p, "referenceText"), this.privProperties = new e.PropertyCollection(), this.privProperties.setProperty(e.PropertyId.PronunciationAssessment_ReferenceText, p), this.privProperties.setProperty(e.PropertyId.PronunciationAssessment_GradingSystem, e.PronunciationAssessmentGradingSystem[a]), this.privProperties.setProperty(e.PropertyId.PronunciationAssessment_Granularity, e.PronunciationAssessmentGranularity[n]), this.privProperties.setProperty(e.PropertyId.PronunciationAssessment_EnableMiscue, String(i)); 9738 } 9739 /** 9740 * @member PronunciationAssessmentConfig.fromJSON 9741 * @function 9742 * @public 9743 * @param {string}
9743 json The json string containing the pronunciation assessment parameters. 9744 * @return {PronunciationAssessmentConfig} Instance of PronunciationAssessmentConfig 9745 * @summary Creates an instance of the PronunciationAssessmentConfig from json. 9746 * This method is designed to support the pronunciation assessment parameters still in preview. 9747 * Under normal circumstances, use the constructor instead. 9748 */ 9749 static fromJSON(p) { 9750 t.Contracts.throwIfNullOrUndefined(p, "json"); 9751 const a = new Pc(""); 9752 return a.privProperties = new e.PropertyCollection(), a.properties.setProperty(e.PropertyId.PronunciationAssessment_Json, p), a; 9753 } 9754 toJSON() { 9755 return this.updateJson(), this.privProperties.getProperty(e.PropertyId.PronunciationAssessment_Params); 9756 } 9757 applyTo(p) { 9758 this.updateJson(); 9759 const a = p.internalData; 9760 a.speechContext.setPronunciationAssessmentParams(this.properties.getProperty(e.PropertyId.PronunciationAssessment_Params), a.isSpeakerDiarizationEnabled); 9761 } 9762 /** 9763 * Gets the reference text. 9764 * @member PronunciationAssessmentConfig.prototype.referenceText 9765 * @function 9766 * @public 9767 * @returns {string} Reference text. 9768 */ 9769 get referenceText() { 9770 return this.properties.getProperty(e.PropertyId.PronunciationAssessment_ReferenceText); 9771 } 9772 /** 9773 * Gets/Sets the reference text. 9774 * @member PronunciationAssessmentConfig.prototype.referenceText 9775 * @function 9776 * @public 9777 * @param {string} referenceText - Reference text. 9778 */ 9779 set referenceText(p) { 9780 t.Contracts.throwIfNullOrWhitespace(p, "referenceText"), this.properties.setProperty(e.PropertyId.PronunciationAssessment_ReferenceText, p); 9781 } 9782 /** 9783 * Sets the phoneme alphabet. 9784 * The valid values are "SAPI" (default) and "IPA". 9785 * Added in version 1.20.0 9786 * @member PronunciationAssessmentConfig.prototype.phonemeAlphabet 9787 * @function 9788 * @public 9789 * @param {string} phonemeAlphabet - Phoneme alphabet. 9790 */ 9791 set phonemeAlphabet(p) { 9792 t.Contracts.throwIfNullOrWhitespace(p, "phonemeAlphabet"), this.privPhonemeAlphabet = p; 9793 } 9794 /** 9795 * Sets the boolean enableMiscue property. 9796 * Added in version 1.26.0 9797 * @member PronunciationAssessmentConfig.prototype.enableMiscue 9798 * @function 9799 * @public 9800 * @param {boolean} enableMiscue - enable miscue. 9801 */ 9802 set enableMiscue(p) { 9803 const a = p ? "true" : "false"; 9804 this.properties.setProperty(e.PropertyId.PronunciationAssessment_EnableMiscue, a); 9805 } 9806 /** 9807 * Gets the boolean enableMiscue property. 9808 * Added in version 1.26.0 9809 * @member PronunciationAssessmentConfig.prototype.enableMiscue 9810 * @function 9811 * @public 9812 * @return {boolean} enableMiscue - enable miscue. 9813 */ 9814 get enableMiscue() { 9815 return this.properties.getProperty(e.PropertyId.PronunciationAssessment_EnableMiscue, "false").toLowerCase() === "true"; 9816 } 9817 /** 9818 * Sets the nbest phoneme count 9819 * Added in version 1.20.0 9820 * @member PronunciationAssessmentConfig.prototype.nbestPhonemeCount 9821 * @function 9822 * @public 9823 * @param {number} nbestPhonemeCount - NBest phoneme count. 9824 */ 9825 set nbestPhonemeCount(p) { 9826 this.privNBestPhonemeCount = p; 9827 } 9828 /** 9829 * Enables the prosody assessment. 9830 * Added in version 1.34.0 9831 * @member PronunciationAssessmentConfig.prototype.enableProsodyAssessment 9832 * @function 9833 * @public 9834 * @param {boolean} enableProsodyAssessment - enable prosody assessment. 9835 */ 9836 set enableProsodyAssessment(p) { 9837 this.privEnableProsodyAssessment = p; 9838 } 9839 /** 9840 * @member PronunciationAssessmentConfig.prototype.properties 9841 * @function 9842 * @public 9843 * @return {PropertyCollection} Properties of the config. 9844 * @summary Gets a pronunciation assessment config properties 9845 */ 9846 get properties() { 9847 return this.privProperties; 9848 } 9849 updateJson() { 9850 const p = this.privProperties.getProperty(e.PropertyId.PronunciationAssessment_Json, "{}"), a = JSON.parse(p), n = this.privProperties.getProperty(e.PropertyId.PronunciationAssessment_ReferenceText); 9851 n && (a.referenceText = n); 9852 const i = this.privProperties.getProperty(e.PropertyId.PronunciationAssessment_GradingSystem); 9853 i && (a.gradingSystem = i); 9854 const o = this.privProperties.getProperty(e.PropertyId.PronunciationAssessment_Granularity); 9855 o && (a.granularity = o), this.privPhonemeAlphabet && (a.phonemeAlphabet = this.privPhonemeAlphabet), this.privNBestPhoneme
9855Count && (a.nbestPhonemeCount = this.privNBestPhonemeCount), a.enableProsodyAssessment = this.privEnableProsodyAssessment, a.dimension = "Comprehensive", this.privProperties.getProperty(e.PropertyId.PronunciationAssessment_EnableMiscue) && (a.enableMiscue = this.enableMiscue), this.privProperties.setProperty(e.PropertyId.PronunciationAssessment_Params, JSON.stringify(a)); 9856 } 9857 }; 9858 return Kt.PronunciationAssessmentConfig = r, Kt; 9859} 9860var Jt = {}, To; 9861function Bv() { 9862 if (To) return Jt; 9863 To = 1, Object.defineProperty(Jt, "__esModule", { value: !0 }), Jt.PronunciationAssessmentResult = void 0; 9864 const t = O, e = R(); 9865 let r = class Rc { 9866 constructor(p) { 9867 const a = JSON.parse(p); 9868 t.Contracts.throwIfNullOrUndefined(a.NBest[0], "NBest"), this.privPronJson = a.NBest[0]; 9869 } 9870 /** 9871 * @member PronunciationAssessmentResult.fromResult 9872 * @function 9873 * @public 9874 * @param {RecognitionResult} result The recognition result. 9875 * @return {PronunciationAssessmentConfig} Instance of PronunciationAssessmentConfig 9876 * @summary Creates an instance of the PronunciationAssessmentResult from recognition result. 9877 */ 9878 static fromResult(p) { 9879 t.Contracts.throwIfNullOrUndefined(p, "result"); 9880 const a = p.properties.getProperty(e.PropertyId.SpeechServiceResponse_JsonResult); 9881 return t.Contracts.throwIfNullOrUndefined(a, "json"), new Rc(a); 9882 } 9883 /** 9884 * Gets the detail result of pronunciation assessment. 9885 * @member PronunciationAssessmentConfig.prototype.detailResult 9886 * @function 9887 * @public 9888 * @returns {DetailResult} detail result. 9889 */ 9890 get detailResult() { 9891 return this.privPronJson; 9892 } 9893 /** 9894 * The score indicating the pronunciation accuracy of the given speech, which indicates 9895 * how closely the phonemes match a native speaker's pronunciation. 9896 * @member PronunciationAssessmentResult.prototype.accuracyScore 9897 * @function 9898 * @public 9899 * @returns {number} Accuracy score. 9900 */ 9901 get accuracyScore() { 9902 var p; 9903 return (p = this.detailResult.PronunciationAssessment) == null ? void 0 : p.AccuracyScore; 9904 } 9905 /** 9906 * The overall score indicating the pronunciation quality of the given speech. 9907 * This is calculated from AccuracyScore, FluencyScore and CompletenessScore with weight. 9908 * @member PronunciationAssessmentResult.prototype.pronunciationScore 9909 * @function 9910 * @public 9911 * @returns {number} Pronunciation score. 9912 */ 9913 get pronunciationScore() { 9914 var p; 9915 return (p = this.detailResult.PronunciationAssessment) == null ? void 0 : p.PronScore; 9916 } 9917 /** 9918 * The score indicating the completeness of the given speech by calculating the ratio of pronounced words towards entire input. 9919 * @member PronunciationAssessmentResult.prototype.completenessScore 9920 * @function 9921 * @public 9922 * @returns {number} Completeness score. 9923 */ 9924 get completenessScore() { 9925 var p; 9926 return (p = this.detailResult.PronunciationAssessment) == null ? void 0 : p.CompletenessScore; 9927 } 9928 /** 9929 * The score indicating the fluency of the given speech. 9930 * @member PronunciationAssessmentResult.prototype.fluencyScore 9931 * @function 9932 * @public 9933 * @returns {number} Fluency score. 9934 */ 9935 get fluencyScore() { 9936 var p; 9937 return (p = this.detailResult.PronunciationAssessment) == null ? void 0 : p.FluencyScore; 9938 } 9939 /** 9940 * The prosody score, which indicates how nature of the given speech, including stress, intonation, speaking speed and rhythm. 9941 * @member PronunciationAssessmentResult.prototype.prosodyScore 9942 * @function 9943 * @public 9944 * @returns {number} Prosody score. 9945 */ 9946 get prosodyScore() { 9947 var p; 9948 return (p = this.detailResult.PronunciationAssessment) == null ? void 0 : p.ProsodyScore; 9949 } 9950 }; 9951 return Jt.PronunciationAssessmentResult = r, Jt; 9952} 9953var Vt = {}, Ao; 9954function qv() { 9955 if (Ao) return Vt; 9956 Ao = 1, Object.defineProperty(Vt, "__esModule", { value: !0 }), Vt.AvatarConfig = void 0; 9957 const t = O, e = R(); 9958 let r = class { 9959 /** 9960 * Creates and initializes an instance of this class. 9961 * @constructor 9962 * @param {string} character - The avatar character. 9963 * @param {string} style - The avatar style. 9964 * @param {AvatarVideoFormat} videoFormat - The talking avatar output video format. 9965 */ 9966 constructor(p, a, n) { 9967 this.privCustomized = !1, this.privUseBuiltInVoice = !1, t.Contracts.throwIfNullOrWhitespace(p, "character"), this.character = p, this.style = a, n === void 0 && (n = new e.AvatarVideoFormat()), this.videoFormat = n; 9968 } 9969 /** 9970 * Indicates if the talking avatar is customized. 9971 */ 9972 get customized() { 9973 return this.privCustomized; 9974 } 9975 /** 9976 * Sets if the talking avatar is customized. 9977 */ 9978 set customized(p) { 9979 this.privCustomized = p; 9980 } 9981 /** 9982 * Indicates whether to use built-in voice for custom avatar. 9983 */ 9984 get useBuiltInVoice() { 9985 return this.privUseBuiltInVoice; 9986 } 9987 /** 9988 * Sets whether to use built-in voice for custom avatar. 9989 */ 9990 set useBuiltInVoice(p) { 9991 this.privUseBuiltInVoice = p; 9992 } 9993 /** 9994 * Gets the photo avatar base model name. 9995 */ 9996 get photoAvatarBaseModel() { 9997 return this.privPhotoAvatarBaseModel; 9998 } 9999 /** 10000 * Sets the photo avatar base model name. 10001 */ 10002 set photoAvatarBaseModel(p) { 10003 this.privPhotoAvatarBaseModel = p; 10004 } 10005 /** 10006 * Gets the background color. 10007 */ 10008 get backgroundColor() {
10009 return this.privBackgroundColor; 10010 } 10011 /** 10012 * Sets the background color. 10013 */ 10014 set backgroundColor(p) { 10015 this.privBackgroundColor = p; 10016 } 10017 /** 10018 * Gets the background image. 10019 */ 10020 get backgroundImage() { 10021 return this.privBackgroundImage; 10022 } 10023 /** 10024 * Sets the background image. 10025 * @param {URL} value - The background image. 10026 */ 10027 set backgroundImage(p) { 10028 this.privBackgroundImage = p; 10029 } 10030 /** 10031 * Gets the remote ICE servers. 10032 * @remarks This method is designed to be used internally in the SDK. 10033 * @returns {RTCIceServer[]} The remote ICE servers. 10034 */ 10035 get remoteIceServers() { 10036 return this.privRemoteIceServers; 10037 } 10038 /** 10039 * Sets the remote ICE servers. 10040 * @remarks Normally, the ICE servers are gathered from the PeerConnection, 10041 * set this property to override the ICE servers. E.g., the ICE servers are 10042 * different in client and server side. 10043 * @param {RTCIceServer[]} value - The remote ICE servers. 10044 */ 10045 set remoteIceServers(p) { 10046 this.privRemoteIceServers = p; 10047 } 10048 /** 10049 * Gets the scene configuration for avatar positioning and orientation. 10050 * @returns {AvatarSceneConfig} The scene configuration. 10051 */ 10052 get scene() {
10053 return this.privScene; 10054 } 10055 /** 10056 * Sets the scene configuration for avatar positioning and orientation. 10057 * @param {AvatarSceneConfig} value - The scene configuration. 10058 */ 10059 set scene(p) { 10060 this.privScene = p; 10061 } 10062 }; 10063 return Vt.AvatarConfig = r, Vt; 10064} 10065var Ec = {}; 10066(function(t) { 10067 Object.defineProperty(t, "__esModule", { value: !0 }), t.AvatarEventArgs = t.AvatarEventTypes = void 0, function(r) { 10068 r.SwitchedToSpeaking = "SwitchedToSpeaking", r.SwitchedToIdle = "SwitchedToIdle", r.SessionClosed = "SessionClosed"; 10069 }(t.AvatarEventTypes || (t.AvatarEventTypes = {})); 10070 class e { 10071 /** 10072 * Creates and initializes an instance of this class. 10073 * @constructor 10074 * @param {number} audioOffset - The audio offset. 10075 * @param {string} description - The description of the event. 10076 */ 10077 constructor(s, p) { 10078 this.privOffset = s, this.privDescription = p; 10079 } 10080 /** 10081 * The type of the event. 10082 * @public 10083 * @returns {AvatarEventTypes} The type of the event. 10084 */ 10085 get type() { 10086 return this.privType; 10087 } 10088 /** 10089 * The time offset associated with this event. 10090 * @public 10091 * @returns {number} The time offset associated with this event. 10092 */ 10093 get offset() { 10094 return this.privOffset; 10095 } 10096 /** 10097 * The description of the event. 10098 * @public 10099 * @returns {string} The description of the event. 10100 */ 10101 get description() { 10102 return this.privDescription; 10103 } 10104 } 10105 t.AvatarEventArgs = e; 10106})(Ec); 10107var Ui = {}; 10108Object.defineProperty(Ui, "__esModule", { value: !0 }); 10109Ui.AvatarSceneConfig = void 0; 10110class Fv { 10111 /** 10112 * Creates and initializes an instance of this class with default values. 10113 * @constructor 10114 * @param {number} zoom - The zoom level (0-1, default 1.0). 10115 * @param {number} positionX - The horizontal position offset (-1 to 1, default 0.0). 10116 * @param {number} positionY - The vertical position offset (-1 to 1, default 0.0). 10117 * @param {number} rotationX - The rotation around the X axis in radians (default 0.0). 10118 * @param {number} rotationY - The rotation around the Y axis in radians (default 0.0). 10119 * @param {number} rotationZ - The rotation around the Z axis in radians (default 0.0). 10120 * @param {number} amplitude - The amplitude of the avatar's movements (0 to 1, default 1.0). 10121 */ 10122 constructor(e = 1, r = 0, s = 0, p = 0, a = 0, n = 0, i = 1) { 10123 this.zoom = e, this.positionX = r, this.positionY = s, this.rotationX = p, this.rotationY = a, this.rotationZ = n, this.amplitude = i; 10124 } 10125} 10126Ui.AvatarSceneConfig = Fv; 10127var Gt = {}, Qt = {}, Io; 10128function Tc() { 10129 if (Io) return Qt; 10130 Io = 1, Object.defineProperty(Qt, "__esModule", { value: !0 }), Qt.SpeechSynthesisConnectionFactory = void 0; 10131 const t = re(), e = R(), r = Se(), s = A(), p = Y, a = pe; 10132 let n = class { 10133 constructor() { 10134 this.synthesisUri = "/tts/cognitiveservices/websocket/v1"; 10135 } 10136 async create(o, c, u) { 10137 let h = o.parameters.getProperty(e.PropertyId.SpeechServiceConnection_Endpoint, void 0); 10138 const d = o.parameters.getProperty(e.PropertyId.SpeechServiceConnection_Region, void 0), v = r.ConnectionFactoryBase.getHostSuffix(d), f = o.parameters.getProperty(e.PropertyId.SpeechServiceConnection_EndpointId, void 0), m = f === void 0 ? "tts" : "voice", S = o.parameters.getProperty(e.PropertyId.SpeechServiceConnection_Host, "wss://" + d + "." + m + ".speech" + v), l = {}, g = {}; 10139 if (c.token !== void 0 && c.token !== "" && (g[c.headerName] = c.token), g[p.HeaderNames.ConnectionId] = u, f !== void 0 && f !== "" && (!h || h.search(a.QueryParameterNames.CustomVoiceDeploymentId) === -1) && (l[a.QueryParameterNames.CustomVoiceDeploymentId] = f), o.avatarEnabled && (!h || h.search(a.QueryParameterNames.EnableAvatar) === -1) && (l[a.QueryParameterNames.EnableAvatar] = "true"), h) { 10140 const y = new URL(h), P = y.pathname; 10141 (P === "" || P === "/") && (y.pathname = this.synthesisUri, h = await r.ConnectionFactoryBase.getRedirectUrlFromEndpoint(y.toString())); 10142 } 10143 h || (h = S + this.synthesisUri), o.parameters.setProperty(e.PropertyId.SpeechServiceConnection_Url, h); 10144 const C = o.parameters.getProperty("SPEECH-EnableWebsocketCompression", "false") === "true"; 10145 return new t.WebsocketConnection(h, l, g, new s.WebsocketMessageFormatter(), t.ProxyInfo.fromParameters(o.parameters), C, u); 10146 } 10147 }; 10148 return Qt.SpeechSynthesisConnectionFactory = n, Qt; 10149} 10150var wo; 10151function Uv() { 10152 if (wo) return Gt; 10153 wo = 1, Object.defineProperty(Gt, "__esModule", { value: !0 }), Gt.AvatarSynthesizer = void 0; 10154 const t = Tc(), e = A(), r = I(), s = Ie, p = R(), a = O, n = Kn(); 10155 let i = class extends p.Synthesizer { 10156 /** 10157 * Creates and initializes an instance of this class. 10158 * @constructor 10159 * @param {SpeechConfig} speechConfig - The speech config. 10160 * @param {AvatarConfig} avatarConfig - The talking avatar config. 10161 */ 10162 constructor(c, u) { 10163 super(c), a.Contracts.throwIfNullOrUndefined(u, "avatarConfig"), this.privConnectionFactory = new t.SpeechSynthesisConnectionFactory(), this.privAvatarConfig = u, this.implCommonSynthesizeSetup(); 10164 } 10165 implCommonSynthesizeSetup() { 10166 super.implCommonSynthesizeSetup(), this.privAdapter.audioOutputFormat = s.AudioOutputFormatImpl.fromSpeechSynthesisOutputFormat(p.SpeechSynthesisOutputFormat.Riff24Khz16BitMonoPcm); 10167 } 10168 /** 10169 * Starts the talking avatar session and establishes the WebRTC connection. 10170 * @member AvatarSynthesizer.prototype.startAvatarAsync 10171 * @function 10172 * @public 10173 * @param {AvatarWebRTCConnectionInfo} peerConnection - The peer connection. 10174 * @returns {Promise<SynthesisResult>} The promise of the connection result. 10175 */ 10176 async startAvatarAsync(c) { 10177 a.Contracts.throwIfNullOrUndefined(c, "peerConnection"), this.privIceServers = c.getConfiguration().iceServers, a.C
10177ontracts.throwIfNullOrUndefined(this.privIceServers, "Ice servers must be set."); 10178 const u = new r.Deferred(); 10179 c.onicegatheringstatechange = () => { 10180 r.Events.instance.onEvent(new r.PlatformEvent("peer connection: ice gathering state: " + c.iceGatheringState, r.EventType.Debug)), c.iceGatheringState === "complete" && (r.Events.instance.onEvent(new r.PlatformEvent("peer connection: ice gathering complete.", r.EventType.Info)), u.resolve()); 10181 }, c.onicecandidate = (m) => { 10182 m.candidate ? r.Events.instance.onEvent(new r.PlatformEvent("peer connection: ice candidate: " + m.candidate.candidate, r.EventType.Debug)) : (r.Events.instance.onEvent(new r.PlatformEvent("peer connection: ice candidate: complete", r.EventType.Debug)), u.resolve()); 10183 }, setTimeout(() => { 10184 c.iceGatheringState !== "complete" && (r.Events.instance.onEvent(new r.PlatformEvent("peer connection: ice gathering timeout.", r.EventType.Warning)), u.resolve()); 10185 }, 2e3); 10186 const h = await c.createOffer(); 10187 await c.setLocalDescription(h), await u.promise, r.Events.instance.onEvent(new r.PlatformEvent("peer connection: got local SDP.", r.EventType.Info)), this.privProperties.setProperty(p.PropertyId.TalkingAvatarService_WebRTC_SDP, JSON.stringify(c.localDescription)); 10188 const d = await this.speak("", !1); 10189 if (d.reason !== p.ResultReason.SynthesizingAudioCompleted) 10190 return new p.SynthesisResult(d.resultId, d.reason, d.errorDetails, d.properties); 10191 const v = atob(d.properties.getProperty(p.PropertyId.TalkingAvatarService_WebRTC_SDP)), f = new RTCSessionDescription(JSON.parse(v)); 10192 return await c.setRemoteDescription(f), new p.SynthesisResult(d.resultId, d.reason, void 0, d.properties); 10193 } 10194 /** 10195 * Speaks plain text asynchronously. The rendered audio and video will be sent via the WebRTC connection. 10196 * @member AvatarSynthesizer.prototype.speakTextAsync 10197 * @function 10198 * @public 10199 * @param {string} text - The plain text to speak. 10200 * @returns {Promise<SynthesisResult>} The promise of the synthesis result. 10201 */ 10202 async speakTextAsync(c) { 10203 const u = await this.speak(c, !1); 10204 return new p.SynthesisResult(u.resultId, u.reason, u.errorDetails, u.properties); 10205 } 10206 /** 10207 * Speaks SSML asynchronously. The rendered audio and video will be sent via the WebRTC connection. 10208 * @member AvatarSynthesizer.prototype.speakSsmlAsync 10209 * @function 10210 * @public 10211 * @param {string} ssml - The SSML text to speak. 10212 * @returns {Promise<SynthesisResult>} The promise of the synthesis result. 10213 */ 10214 async speakSsmlAsync(c) { 10215 const u = await this.speak(c, !0); 10216 return new p.SynthesisResult(u.resultId, u.reason, u.errorDetails, u.properties); 10217 } 10218 /** 10219 * Speaks text asynchronously. The avatar will switch to idle state. 10220 * @member AvatarSynthesizer.prototype.stopSpeakingAsync 10221 * @function 10222 * @public 10223 * @returns {Promise<void>} The promise of the void result. 10224 */ 10225 async stopSpeakingAsync() { 10226 for (; this.synthesisRequestQueue.length() > 0; ) 10227 (await this.synthesisRequestQueue.dequeue()).err("Synthesis is canceled by user."); 10228 return this.privAdapter.stopSpeaking(); 10229 } 10230 /** 10231 * Updates the avatar scene configuration at runtime. 10232 * This allows changing the avatar's zoom, position, amplitude, and rotation while the session is active. 10233 * @member AvatarSynthesizer.prototype.updateSceneAsync 10234 * @function 10235 * @public 10236 * @param {AvatarSceneConfig}
10236 sceneConfig - The new scene configuration to apply. 10237 * @returns {Promise<void>} The promise of the void result. 10238 */ 10239 async updateSceneAsync(c) { 10240 a.Contracts.throwIfDisposed(this.privDisposed), a.Contracts.throwIfNullOrUndefined(c, "sceneConfig"); 10241 const u = { 10242 avatarScene: { 10243 amplitude: c.amplitude, 10244 positionX: c.positionX, 10245 positionY: c.positionY, 10246 rotationX: c.rotationX, 10247 rotationY: c.rotationY, 10248 rotationZ: c.rotationZ, 10249 zoom: c.zoom 10250 } 10251 }; 10252 return this.privAdapter.sendNetworkMessage("synthesis.control", JSON.stringify(u)); 10253 } 10254 /** 10255 * Stops the talking avatar session and closes the WebRTC connection. 10256 * For now, this is the same as close(). 10257 * You need to create a new AvatarSynthesizer instance to start a new session. 10258 * @member AvatarSynthesizer.prototype.stopAvatarAsync 10259 * @function 10260 * @public 10261 * @returns {Promise<void>} The promise of the void result. 10262 */ 10263 async stopAvatarAsync() { 10264 return a.Contracts.throwIfDisposed(this.privDisposed), this.dispose(!0); 10265 } 10266 /** 10267 * Dispose of associated resources. 10268 * @member AvatarSynthesizer.prototype.close 10269 * @function 10270 * @public 10271 */ 10272 async close() { 10273 if (!this.privDisposed) 10274 return this.dispose(!0); 10275 } 10276 /** 10277 * Gets the ICE servers. Internal use only. 10278 */ 10279 get iceServers() { 10280 return this.privIceServers; 10281 } 10282 // Creates the synthesis adapter 10283 createSynthesisAdapter(c, u, h) { 10284 return new e.AvatarSynthesisAdapter(c, u, h, this, this.privAvatarConfig); 10285 } 10286 createRestSynthesisAdapter(c, u) { 10287 } 10288 createSynthesizerConfig(c) { 10289 const u = super.createSynthesizerConfig(c); 10290 return u.avatarEnabled = !0, u; 10291 } 10292 async speak(c, u) { 10293 const h = (0, r.createNoDashGuid)(), d = new r.Deferred(); 10294 return this.synthesisRequestQueue.enqueue(new n.SynthesisRequest(h, c, u, (v) => { 10295 d.resolve(v), this.privSynthesizing = !1, this.adapterSpeak(); 10296 }, (v) => { 10297 d.reject(v), this.privSynthesizing = !1; 10298 })), this.adapterSpeak(), d.promise; 10299 } 10300 }; 10301 return Gt.AvatarSynthesizer = i, Gt; 10302} 10303var Ke = {}; 10304Object.defineProperty(Ke, "__esModule", { value: !0 }); 10305Ke.AvatarVideoFormat = Ke.Coordinate = void 0; 10306class xv { 10307 constructor(e, r) { 10308 this.x = e, this.y = r; 10309 } 10310} 10311Ke.Coordinate = xv; 10312class Wv { 10313 /** 10314 * Creates and initializes an instance of this class. 10315 * @constructor 10316 * @param {string} codec - The video codec. 10317 * @param {number} bitrate - The video bitrate. 10318 * @param {number} width - The video width. 10319 * @param {number} height - The video height. 10320 */ 10321 constructor(e = "H264", r = 2e6, s = 1920, p = 1080) { 10322 this.codec = e, this.bitrate = r, this.width = s, this.height = p; 10323 } 10324 /** 10325 * Sets the video crop range. 10326 */ 10327 setCropRange(e, r) { 10328 this.cropRange = { 10329 bottomRight: r, 10330 topLeft: e 10331 }; 10332 } 10333} 10334Ke.AvatarVideoFormat = Wv; 10335var Xt = {}, _o; 10336function Hv() { 10337 if (_o) return Xt; 10338 _o = 1, Object.defineProperty(Xt, "__esModule", { value: !0 }), Xt.AvatarWebRTCConnectionResult = void 0; 10339 const t = R(); 10340 let e = class extends t.SynthesisResult { 10341 /** 10342 * Creates and initializes an instance of this class. 10343 * @constructor 10344 * @param {RTCSessionDescriptionInit} SDPAnswer - The SDP answer of WebRTC connection. 10345 * @param {string} resultId - The result id. 10346 * @param {ResultReason} reason - The reason. 10347 * @param {string} errorDetails - Error details, if provided. 10348 * @param {PropertyCollection} properties - Additional properties, if provided. 10349 */ 10350 constructor(s, p, a, n, i) { 10351 super(p, a, n, i), this.privSDPAnswer = s; 10352 } 10353 /** 10354 * Specifies SDP (Session Description Protocol) answer of WebRTC connection. 10355 * @member AvatarWebRTCConnectionResult.prototype.SDPAnswer 10356 * @function 10357 * @public 10358 * @returns {RTCSessionDescriptionInit} Specifies the SDP answer of WebRTC connection. 10359 */ 10360 get SDPAnswer() { 10361 return this.privSDPAnswer; 10362 } 10363 }; 10364 return Xt.AvatarWebRTCConnectionResult = e, Xt; 10365} 10366var Yt = {}, bo; 10367function Kv() { 10368 if (bo) return Yt;
10369 bo = 1, Object.defineProperty(Yt, "__esModule", { value: !0 }), Yt.Diagnostics = void 0; 10370 const t = re(), e = I(); 10371 let r = class { 10372 static SetLoggingLevel(p) { 10373 this.privListener = new t.ConsoleLoggingListener(p), e.Events.instance.attachConsoleListener(this.privListener); 10374 } 10375 static StartConsoleOutput() { 10376 this.privListener && (this.privListener.enableConsoleOutput = !0); 10377 } 10378 static StopConsoleOutput() { 10379 this.privListener && (this.privListener.enableConsoleOutput = !1); 10380 } 10381 static SetLogOutputPath(p) { 10382 if (typeof window > "u") 10383 this.privListener && (this.privListener.logPath = p); 10384 else 10385 throw new Error("File system logging not available in browser."); 10386 } 10387 static set onLogOutput(p) { 10388 this.privListener && (this.privListener.logCallback = p); 10389 } 10390 }; 10391 return Yt.Diagnostics = r, r.privListener = void 0, Yt; 10392} 10393var Mo; 10394function R() { 10395 return Mo || (Mo = 1, function(t) { 10396 Object.defineProperty(t, "__esModule", { value: !0 }), t.CustomCommandsConfig = t.BotFrameworkConfig = t.DialogServiceConfig = t.PhraseListGrammar = t.Connection = t.ServiceEventArgs = t.ConnectionEventArgs = t.CancellationErrorCode = t.CancellationDetails = t.CancellationDetailsBase = t.TranslationRecognitionCanceledEventArgs = t.NoMatchDetails = t.NoMatchReason = t.Translations = t.TranslationRecognizer = t.SpeechRecognizer = t.Recognizer = t.PropertyId = t.PropertyCollection = t.SpeechTranslationConfigImpl = t.SpeechTranslationConfig = t.SpeechConfigImpl = t.SpeechConfig = t.ResultReason = t.TranslationSynthesisResult = t.TranslationRecognitionResult = t.TranslationSynthesisEventArgs = t.TranslationRecognitionEventArgs = t.SpeechRecognitionCanceledEventArgs = t.MeetingTranscriptionEventArgs = t.ConversationTranscriptionEventArgs = t.SpeechRecognitionEventArgs = t.SpeechRecognitionResult = t.RecognitionResult = t.OutputFormat = t.RecognitionEventArgs = t.SessionEventArgs = t.KeywordRecognitionModel = t.PushAudioOutputStreamCallback = t.PullAudioInputStreamCallback = t.CancellationReason = t.PushAudioOutputStream = t.PullAudioOutputStream = t.AudioOutputStream = t.PushAudioInputStream = t.PullAudioInputStream = t.AudioInputStream = t.AudioFormatTag = t.AudioStreamFormat = t.AudioConfig = void 0, t.AvatarSceneConfig = t.AvatarEventArgs = t.AvatarConfig = t.LanguageIdMode = t.PronunciationAssessmentResult = t.PronunciationAssessmentConfig = t.PronunciationAssessmentGranularity = t.PronunciationAssessmentGradingSystem = t.MeetingTranscriptionCanceledEventArgs = t.ConversationTranscriptionCanceledEventArgs = t.SpeakerAudioDestination = t.VoiceInfo = t.SynthesisVoiceType = t.SynthesisVoiceGender = t.SynthesisVoicesResult = t.SpeechSynthesisBoundaryType = t.SpeechSynthesisVisemeEventArgs = t.SpeechSynthesisBookmarkEventArgs = t.SpeechSynthesisWordBoundaryEventArgs = t.SpeechSynthesisEventArgs = t.SpeechSynthesisResult = t.SynthesisResult = t.SpeechSynthesizer = t.SpeechSynthesisOutputFormat = t.Synthesizer = t.User = t.ParticipantChangedReason = t.Participant = t.MeetingTranscriber = t.Meeting = t.ConversationTranscriptionResult = t.ConversationTranscriber = t.ConversationTranslator = t.ConversationTranslationResult = t.ConversationTranslationEventArgs = t.ConversationTranslationCanceledEventArgs = t.ConversationParticipantsChangedEventArgs = t.ConversationExpirationEventArgs = t.Conversation = t.SourceLanguageConfig = t.AutoDetectSourceLanguageResult = t.AutoDetectSourceLanguageConfig = t.ConnectionMessage = t.ConnectionMessageEventArgs = t.BaseAudioPlayer = t.ProfanityOption = t.ServicePropertyChannel = t.TurnStatusReceivedEventArgs = t.ActivityReceivedEventArgs = t.DialogServiceConnector = void 0, t.LogLevel = t.Diagnostics = t.AvatarWebRTCConnectionResult = t.Coordinate = t.AvatarVideoFormat = t.AvatarSynthesizer = void 0; 10397 var e = Id(); 10398 Object.defineProperty(t, "AudioConfig", { enumerable: !0, get: function() { 10399 return e.AudioConfig; 10400 } }); 10401 var r = Ae; 10402 Object.defineProperty(t, "AudioStreamFormat", { enumerable: !0, get: function() { 10403 return r.AudioStreamFormat; 10404 } }), Object.defineProperty(t, "AudioFormatTag", { enumerable: !0, get: function() { 10405 return r.AudioFormatTag; 10406 } }); 10407 var s = xa();
10408 Object.defineProperty(t, "AudioInputStream", { enumerable: !0, get: function() { 10409 return s.AudioInputStream; 10410 } }), Object.defineProperty(t, "PullAudioInputStream", { enumerable: !0, get: function() { 10411 return s.PullAudioInputStream; 10412 } }), Object.defineProperty(t, "PushAudioInputStream", { enumerable: !0, get: function() { 10413 return s.PushAudioInputStream; 10414 } }); 10415 var p = U; 10416 Object.defineProperty(t, "AudioOutputStream", { enumerable: !0, get: function() { 10417 return p.AudioOutputStream; 10418 } }), Object.defineProperty(t, "PullAudioOutputStream", { enumerable: !0, get: function() { 10419 return p.PullAudioOutputStream; 10420 } }), Object.defineProperty(t, "PushAudioOutputStream", { enumerable: !0, get: function() { 10421 return p.PushAudioOutputStream; 10422 } }); 10423 var a = Va; 10424 Object.defineProperty(t, "CancellationReason", { enumerable: !0, get: function() { 10425 return a.CancellationReason; 10426 } }); 10427 var n = Ci; 10428 Object.defineProperty(t, "PullAudioInputStreamCallback", { enumerable: !0, get: function() { 10429 return n.PullAudioInputStreamCallback; 10430 } }); 10431 var i = yi; 10432 Object.defineProperty(t, "PushAudioOutputStreamCallback", { enumerable: !0, get: function() { 10433 return i.PushAudioOutputStreamCallback; 10434 } }); 10435 var o = Pi; 10436 Object.defineProperty(t, "KeywordRecognitionModel", { enumerable: !0, get: function() { 10437 return o.KeywordRecognitionModel; 10438 } }); 10439 var c = Ri; 10440 Object.defineProperty(t, "SessionEventArgs", { enumerable: !0, get: function() { 10441 return c.SessionEventArgs; 10442 } }); 10443 var u = Od(); 10444 Object.defineProperty(t, "RecognitionEventArgs", { enumerable: !0, get: function() { 10445 return u.RecognitionEventArgs; 10446 } }); 10447 var h = Ga; 10448 Object.defineProperty(t, "OutputFormat", { enumerable: !0, get: function() { 10449 return h.OutputFormat; 10450 } }); 10451 var d = Ei; 10452 Object.defineProperty(t, "RecognitionResult", { enumerable: !0, get: function() { 10453 return d.RecognitionResult; 10454 } }); 10455 var v = kd(); 10456 Object.defineProperty(t, "SpeechRecognitionResult", { enumerable: !0, get: function() { 10457 return v.SpeechRecognitionResult; 10458 } }); 10459 var f = Nd(); 10460 Object.defineProperty(t, "SpeechRecognitionEventArgs", { enumerable: !0, get: function() { 10461 return f.SpeechRecognitionEventArgs; 10462 } }), Object.defineProperty(t, "ConversationTranscriptionEventArgs", { enumerable: !0, get: function() { 10463 return f.ConversationTranscriptionEventArgs; 10464 } }), Object.defineProperty(t, "MeetingTranscriptionEventArgs", { enumerable: !0, get: function() { 10465 return f.MeetingTranscriptionEventArgs; 10466 } }); 10467 var m = zd(); 10468 Object.defineProperty(t, "SpeechRecognitionCanceledEventArgs", { enumerable: !0, get: function() { 10469 return m.SpeechRecognitionCanceledEventArgs; 10470 } }); 10471 var S = jd(); 10472 Object.defineProperty(t, "TranslationRecognitionEventArgs", { enumerable: !0, get: function() { 10473 return S.TranslationRecognitionEventArgs; 10474 } }); 10475 var l = Ld(); 10476 Object.defineProperty(t, "TranslationSynthesisEventArgs", { enumerable: !0, get: function() { 10477 return l.TranslationSynthesisEventArgs; 10478 } }); 10479 var g = Xa(); 10480 Object.defineProperty(t, "TranslationRecognitionResult", { enumerable: !0, get: function() { 10481 return g.TranslationRecognitionResult; 10482 } }); 10483 var C = Ti; 10484 Object.defineProperty(t, "TranslationSynthesisResult", { enumerable: !0, get: function() { 10485 return C.TranslationSynthesisResult; 10486 } }); 10487 var y = Ya; 10488 Object.defineProperty(t, "ResultReason", { enumerable: !0, get: function() { 10489 return y.ResultReason; 10490 } }); 10491 var P = qd(); 10492 Object.defineProperty(t, "SpeechConfig", { enumerable: !0, get: function() { 10493 return P.SpeechConfig; 10494 } }), Object.defineProperty(t, "SpeechConfigImpl", { enumerable: !0, get: function() { 10495 return P.SpeechConfigImpl; 10496 } }); 10497 var T = Fd(); 10498 Object.defineProperty(t, "SpeechTranslationConfig", { enumerable: !0, get: function() { 10499 return T.SpeechTranslationConfig; 10500 } }), Object.defineProperty(t, "SpeechTranslationConfigImpl", { enumerable: !0, get: function() { 10501 return T.SpeechTranslationConfigImpl; 10502 } }); 10503 var _ = $a();
10504 Object.defineProperty(t, "PropertyCollection", { enumerable: !0, get: function() { 10505 return _.PropertyCollection; 10506 } }); 10507 var E = Ai; 10508 Object.defineProperty(t, "PropertyId", { enumerable: !0, get: function() { 10509 return E.PropertyId; 10510 } }); 10511 var z = Ud(); 10512 Object.defineProperty(t, "Recognizer", { enumerable: !0, get: function() { 10513 return z.Recognizer; 10514 } }); 10515 var L = xd(); 10516 Object.defineProperty(t, "SpeechRecognizer", { enumerable: !0, get: function() { 10517 return L.SpeechRecognizer; 10518 } }); 10519 var ne = Wd(); 10520 Object.defineProperty(t, "TranslationRecognizer", { enumerable: !0, get: function() { 10521 return ne.TranslationRecognizer; 10522 } }); 10523 var We = Hd(); 10524 Object.defineProperty(t, "Translations", { enumerable: !0, get: function() { 10525 return We.Translations; 10526 } }); 10527 var Z = sc; 10528 Object.defineProperty(t, "NoMatchReason", { enumerable: !0, get: function() { 10529 return Z.NoMatchReason; 10530 } }); 10531 var ns = Kd(); 10532 Object.defineProperty(t, "NoMatchDetails", { enumerable: !0, get: function() { 10533 return ns.NoMatchDetails; 10534 } }); 10535 var Qc = Ii; 10536 Object.defineProperty(t, "TranslationRecognitionCanceledEventArgs", { enumerable: !0, get: function() { 10537 return Qc.TranslationRecognitionCanceledEventArgs; 10538 } }); 10539 var Xc = jr; 10540 Object.defineProperty(t, "CancellationDetailsBase", { enumerable: !0, get: function() { 10541 return Xc.CancellationDetailsBase; 10542 } }); 10543 var Yc = Gd(); 10544 Object.defineProperty(t, "CancellationDetails", { enumerable: !0, get: function() { 10545 return Yc.CancellationDetails; 10546 } }); 10547 var Zc = cc; 10548 Object.defineProperty(t, "CancellationErrorCode", { enumerable: !0, get: function() { 10549 return Zc.CancellationErrorCode; 10550 } }); 10551 var $c = Qd(); 10552 Object.defineProperty(t, "ConnectionEventArgs", { enumerable: !0, get: function() { 10553 return $c.ConnectionEventArgs; 10554 } }); 10555 var ep = Xd(); 10556 Object.defineProperty(t, "ServiceEventArgs", { enumerable: !0, get: function() { 10557 return ep.ServiceEventArgs; 10558 } }); 10559 var tp = ic(); 10560 Object.defineProperty(t, "Connection", { enumerable: !0, get: function() { 10561 return tp.Connection; 10562 } }); 10563 var rp = wi; 10564 Object.defineProperty(t, "PhraseListGrammar", { enumerable: !0, get: function() { 10565 return rp.PhraseListGrammar; 10566 } }); 10567 var ip = Fn(); 10568 Object.defineProperty(t, "DialogServiceConfig", { enumerable: !0, get: function() { 10569 return ip.DialogServiceConfig; 10570 } }); 10571 var np = Zd(); 10572 Object.defineProperty(t, "BotFrameworkConfig", { enumerable: !0, get: function() { 10573 return np.BotFrameworkConfig; 10574 } }); 10575 var sp = $d(); 10576 Object.defineProperty(t, "CustomCommandsConfig", { enumerable: !0, get: function() { 10577 return sp.CustomCommandsConfig; 10578 } }); 10579 var op = tv(); 10580 Object.defineProperty(t, "DialogServiceConnector", { enumerable: !0, get: function() { 10581 return op.DialogServiceConnector; 10582 } }); 10583 var ap = _i; 10584 Object.defineProperty(t, "ActivityReceivedEventArgs", { enumerable: !0, get: function() { 10585 return ap.ActivityReceivedEventArgs; 10586 } }); 10587 var cp = bi; 10588 Object.defineProperty(t, "TurnStatusReceivedEventArgs", { enumerable: !0, get: function() { 10589 return cp.TurnStatusReceivedEventArgs; 10590 } }); 10591 var pp = pc; 10592 Object.defineProperty(t, "ServicePropertyChannel", { enumerable: !0, get: function() { 10593 return pp.ServicePropertyChannel; 10594 } }); 10595 var up = uc; 10596 Object.defineProperty(t, "ProfanityOption", { enumerable: !0, get: function() { 10597 return up.ProfanityOption; 10598 } }); 10599 var hp = sv();
10600 Object.defineProperty(t, "BaseAudioPlayer", { enumerable: !0, get: function() { 10601 return hp.BaseAudioPlayer; 10602 } }); 10603 var dp = Oi; 10604 Object.defineProperty(t, "ConnectionMessageEventArgs", { enumerable: !0, get: function() { 10605 return dp.ConnectionMessageEventArgs; 10606 } }); 10607 var vp = rc(); 10608 Object.defineProperty(t, "ConnectionMessage", { enumerable: !0, get: function() { 10609 return vp.ConnectionMessage; 10610 } }); 10611 var lp = av(); 10612 Object.defineProperty(t, "AutoDetectSourceLanguageConfig", { enumerable: !0, get: function() { 10613 return lp.AutoDetectSourceLanguageConfig; 10614 } }); 10615 var fp = Di; 10616 Object.defineProperty(t, "AutoDetectSourceLanguageResult", { enumerable: !0, get: function() { 10617 return fp.AutoDetectSourceLanguageResult; 10618 } }); 10619 var gp = ki; 10620 Object.defineProperty(t, "SourceLanguageConfig", { enumerable: !0, get: function() { 10621 return gp.SourceLanguageConfig; 10622 } }); 10623 var ee = Hn(); 10624 Object.defineProperty(t, "Conversation", { enumerable: !0, get: function() { 10625 return ee.Conversation; 10626 } }), Object.defineProperty(t, "ConversationExpirationEventArgs", { enumerable: !0, get: function() { 10627 return ee.ConversationExpirationEventArgs; 10628 } }), Object.defineProperty(t, "ConversationParticipantsChangedEventArgs", { enumerable: !0, get: function() { 10629 return ee.ConversationParticipantsChangedEventArgs; 10630 } }), Object.defineProperty(t, "ConversationTranslationCanceledEventArgs", { enumerable: !0, get: function() { 10631 return ee.ConversationTranslationCanceledEventArgs; 10632 } }), Object.defineProperty(t, "ConversationTranslationEventArgs", { enumerable: !0, get: function() { 10633 return ee.ConversationTranslationEventArgs; 10634 } }), Object.defineProperty(t, "ConversationTranslationResult", { enumerable: !0, get: function() { 10635 return ee.ConversationTranslationResult; 10636 } }), Object.defineProperty(t, "ConversationTranslator", { enumerable: !0, get: function() { 10637 return ee.ConversationTranslator; 10638 } }), Object.defineProperty(t, "ConversationTranscriber", { enumerable: !0, get: function() { 10639 return ee.ConversationTranscriber; 10640 } }), Object.defineProperty(t, "ConversationTranscriptionResult", { enumerable: !0, get: function() { 10641 return ee.ConversationTranscriptionResult; 10642 } }), Object.defineProperty(t, "Meeting", { enumerable: !0, get: function() { 10643 return ee.Meeting; 10644 } }), Object.defineProperty(t, "MeetingTranscriber", { enumerable: !0, get: function() { 10645 return ee.MeetingTranscriber; 10646 } }), Object.defineProperty(t, "Participant", { enumerable: !0, get: function() { 10647 return ee.Participant; 10648 } }), Object.defineProperty(t, "ParticipantChangedReason", { enumerable: !0, get: function() { 10649 return ee.ParticipantChangedReason; 10650 } }), Object.defineProperty(t, "User", { enumerable: !0, get: function() { 10651 return ee.User; 10652 } }); 10653 var mp = Kn(); 10654 Object.defineProperty(t, "Synthesizer", { enumerable: !0, get: function() { 10655 return mp.Synthesizer; 10656 } }); 10657 var Sp = jn; 10658 Object.defineProperty(t, "SpeechSynthesisOutputFormat", { enumerable: !0, get: function() { 10659 return Sp.SpeechSynthesisOutputFormat; 10660 } }); 10661 var Cp = Tv(); 10662 Object.defineProperty(t, "SpeechSynthesizer", { enumerable: !0, get: function() { 10663 return Cp.SpeechSynthesizer; 10664 } }); 10665 var yp = zi; 10666 Object.defineProperty(t, "SynthesisResult", { enumerable: !0, get: function() { 10667 return yp.SynthesisResult; 10668 } }); 10669 var Pp = Iv(); 10670 Object.defineProperty(t, "SpeechSynthesisResult", { enumerable: !0, get: function() { 10671 return Pp.SpeechSynthesisResult; 10672 } }); 10673 var Rp = ji; 10674 Object.defineProperty(t, "SpeechSynthesisEventArgs", { enumerable: !0, get: function() { 10675 return Rp.SpeechSynthesisEventArgs; 10676 } }); 10677 var Ep = Li; 10678 Object.defineProperty(t, "SpeechSynthesisWordBoundaryEventArgs", { enumerable: !0, get: function() { 10679 return Ep.SpeechSynthesisWordBoundaryEventArgs; 10680 } }); 10681 var Tp = Bi; 10682 Object.defineProperty(t, "SpeechSynthesisBookmarkEventArgs", { enumerable: !0, get: function() { 10683 return Tp.SpeechSynthesisBookmarkEventArgs; 10684 } }); 10685 var Ap = qi;
10686 Object.defineProperty(t, "SpeechSynthesisVisemeEventArgs", { enumerable: !0, get: function() { 10687 return Ap.SpeechSynthesisVisemeEventArgs; 10688 } }); 10689 var Ip = mc; 10690 Object.defineProperty(t, "SpeechSynthesisBoundaryType", { enumerable: !0, get: function() { 10691 return Ip.SpeechSynthesisBoundaryType; 10692 } }); 10693 var wp = Ov(); 10694 Object.defineProperty(t, "SynthesisVoicesResult", { enumerable: !0, get: function() { 10695 return wp.SynthesisVoicesResult; 10696 } }); 10697 var sn = Sc; 10698 Object.defineProperty(t, "SynthesisVoiceGender", { enumerable: !0, get: function() { 10699 return sn.SynthesisVoiceGender; 10700 } }), Object.defineProperty(t, "SynthesisVoiceType", { enumerable: !0, get: function() { 10701 return sn.SynthesisVoiceType; 10702 } }), Object.defineProperty(t, "VoiceInfo", { enumerable: !0, get: function() { 10703 return sn.VoiceInfo; 10704 } }); 10705 var _p = Fi; 10706 Object.defineProperty(t, "SpeakerAudioDestination", { enumerable: !0, get: function() { 10707 return _p.SpeakerAudioDestination; 10708 } }); 10709 var bp = zv(); 10710 Object.defineProperty(t, "ConversationTranscriptionCanceledEventArgs", { enumerable: !0, get: function() { 10711 return bp.ConversationTranscriptionCanceledEventArgs; 10712 } }); 10713 var Mp = jv();
10714 Object.defineProperty(t, "MeetingTranscriptionCanceledEventArgs", { enumerable: !0, get: function() { 10715 return Mp.MeetingTranscriptionCanceledEventArgs; 10716 } }); 10717 var Op = Cc; 10718 Object.defineProperty(t, "PronunciationAssessmentGradingSystem", { enumerable: !0, get: function() { 10719 return Op.PronunciationAssessmentGradingSystem; 10720 } }); 10721 var Dp = yc; 10722 Object.defineProperty(t, "PronunciationAssessmentGranularity", { enumerable: !0, get: function() { 10723 return Dp.PronunciationAssessmentGranularity; 10724 } }); 10725 var kp = Lv(); 10726 Object.defineProperty(t, "PronunciationAssessmentConfig", { enumerable: !0, get: function() { 10727 return kp.PronunciationAssessmentConfig; 10728 } }); 10729 var Np = Bv(); 10730 Object.defineProperty(t, "PronunciationAssessmentResult", { enumerable: !0, get: function() { 10731 return Np.PronunciationAssessmentResult; 10732 } }); 10733 var zp = xn; 10734 Object.defineProperty(t, "LanguageIdMode", { enumerable: !0, get: function() { 10735 return zp.LanguageIdMode; 10736 } }); 10737 var jp = qv(); 10738 Object.defineProperty(t, "AvatarConfig", { enumerable: !0, get: function() { 10739 return jp.AvatarConfig; 10740 } }); 10741 var Lp = Ec; 10742 Object.defineProperty(t, "AvatarEventArgs", { enumerable: !0, get: function() { 10743 return Lp.AvatarEventArgs; 10744 } }); 10745 var Bp = Ui; 10746 Object.defineProperty(t, "AvatarSceneConfig", { enumerable: !0, get: function() { 10747 return Bp.AvatarSceneConfig; 10748 } }); 10749 var qp = Uv();
10750 Object.defineProperty(t, "AvatarSynthesizer", { enumerable: !0, get: function() { 10751 return qp.AvatarSynthesizer; 10752 } }); 10753 var ss = Ke; 10754 Object.defineProperty(t, "AvatarVideoFormat", { enumerable: !0, get: function() { 10755 return ss.AvatarVideoFormat; 10756 } }), Object.defineProperty(t, "Coordinate", { enumerable: !0, get: function() { 10757 return ss.Coordinate; 10758 } }); 10759 var Fp = Hv(); 10760 Object.defineProperty(t, "AvatarWebRTCConnectionResult", { enumerable: !0, get: function() { 10761 return Fp.AvatarWebRTCConnectionResult; 10762 } }); 10763 var Up = Kv(); 10764 Object.defineProperty(t, "Diagnostics", { enumerable: !0, get: function() { 10765 return Up.Diagnostics; 10766 } }); 10767 var xp = Nn; 10768 Object.defineProperty(t, "LogLevel", { enumerable: !0, get: function() { 10769 return xp.LogLevel; 10770 } }); 10771 }(mn)), mn; 10772} 10773var Oo; 10774function Jv() { 10775 if (Oo) return nt; 10776 Oo = 1, Object.defineProperty(nt, "__esModule", { value: !0 }), nt.ProxyInfo = void 0; 10777 const t = R(); 10778 let e = class Ac { 10779 constructor(s, p, a, n) { 10780 this.privProxyHostName = s, this.privProxyPort = p, this.privProxyUserName = a, this.privProxyPassword = n; 10781 } 10782 static fromParameters(s) { 10783 return new Ac(s.getProperty(t.PropertyId.SpeechServiceConnection_ProxyHostName), parseInt(s.getProperty(t.PropertyId.SpeechServiceConnection_ProxyPort), 10), s.getProperty(t.PropertyId.SpeechServiceConnection_ProxyUserName), s.getProperty(t.PropertyId.SpeechServiceConnection_ProxyPassword)); 10784 } 10785 static fromRecognizerConfig(s) { 10786 return this.fromParameters(s.parameters); 10787 } 10788 get HostName() { 10789 return this.privProxyHostName; 10790 } 10791 get Port() { 10792 return this.privProxyPort; 10793 } 10794 get UserName() { 10795 return this.privProxyUserName; 10796 } 10797 get Password() { 10798 return this.privProxyPassword; 10799 } 10800 }; 10801 return nt.ProxyInfo = e, nt; 10802} 10803var Ic = {}; 10804const Vv = /* @__PURE__ */ new Set(["json", "buffer", "string"]); 10805var Gv = (t) => (...e) => { 10806 const r = /* @__PURE__ */ new Set(); 10807 let s, p, a, n = ""; 10808 return e.forEach((i) => { 10809 if (typeof i == "string") 10810 if (i.toUpperCase() === i) 10811 if (s) { 10812 const o = `Can't set method to ${i}, already set to ${s}.`; 10813 throw new Error(o); 10814 } else 10815 s = i; 10816 else if (i.startsWith("http:") || i.startsWith("https:")) 10817 n = i; 10818 else if (Vv.has(i)) 10819 p = i; 10820 else 10821 throw new Error(`Unknown encoding, ${i}`); 10822 else if (typeof i == "number") 10823 r.add(i); 10824 else if (typeof i == "object") 10825 if (Array.isArray(i) || i instanceof Set) 10826 i.forEach((o) => r.add(o)); 10827 else { 10828 if (a) 10829 throw new Error("Cannot set headers twice."); 10830 a = i; 10831 } 10832 else 10833 throw new Error(`Unknown type: ${typeof i}`); 10834 }), s || (s = "GET"), r.size === 0 && r.add(200), t(r, s, p, a, n); 10835}; 10836const Qv = Gv; 10837class Jn extends Error { 10838 constructor(e, ...r) { 10839 super(...r), Error.captureStackTrace && Error.captureStackTrace(this, Jn), this.name = "StatusError", this.message = e.statusMessage, this.statusCode = e.status, this.res = e, this.json = e.json.bind(e), this.text = e.text.bind(e), this.arrayBuffer = e.arrayBuffer.bind(e); 10840 let s; 10841 Object.defineProperty(this, "responseBody", { get: () => (s || (s = this.arrayBuffer()), s) }), this.headers = {}; 10842 for (const [a, n] of e.headers.entries()) 10843 this.headers[a.toLowerCase()] = n; 10844 } 10845} 10846const Xv = (t, e, r, s, p) => async (a, n, i = {}) => { 10847 a = p + (a || ""); 10848 let o = new URL(a); 10849 if (s || (s = {}), o.username && (s.Authorization = "Basic " + btoa(o.username + ":" + o.password), o = new URL(o.protocol + "//" + o.host + o.pathname + o.search)), o.protocol !== "https:" && o.protocol !== "http:") 10850 throw new Error(`Unknown protocol, ${o.protocol}`); 10851 if (n && !(n instanceof ArrayBuffer || ArrayBuffer.isView(n) || typeof n == "string")) 10852 if (typeof n == "object") 10853 n = JSON.stringify(n), s["Content-Type"] = "application/json"; 10854 else 10855 throw new Error("Unknown body type."); 10856 i = new Headers({ ...s || {}, ...i }); 10857 const c = await fetch(o, { method: e, headers: i, body: n }); 10858 if (c.statusCode = c.status, !t.has(c.status)) 10859 throw new Jn(c); 10860 return r === "json" ? c.json() : r === "buffer" ? c.arrayBuffer() : r === "string" ? c.text() : c; 10861}; 10862var Yv = Qv(Xv); 10863(function(t) { 10864 var e = k && k.__importDefault || function(n) { 10865 return n && n.__esModule ? n : { default: n }; 10866 }; 10867 Object.defineProperty(t, "__esModule", { value: !0 }), t.RestMessageAdapter = t.RestRequestType = void 0; 10868 const r = e(Yv), s = I(); 10869 var p; 10870 (function(n) { 10871 n.Get = "GET", n.Post = "POST", n.Delete = "DELETE", n.File = "file"; 10872 }
10872)(p = t.RestRequestType || (t.RestRequestType = {})); 10873 class a { 10874 constructor(i) { 10875 if (!i) 10876 throw new s.ArgumentNullError("configParams"); 10877 this.privHeaders = i.headers, this.privIgnoreCache = i.ignoreCache; 10878 } 10879 static extractHeaderValue(i, o) { 10880 let c = ""; 10881 try { 10882 const u = o.trim().split(/[\r\n]+/), h = {}; 10883 u.forEach((d) => { 10884 const v = d.split(": "), f = v.shift().toLowerCase(), m = v.join(": "); 10885 h[f] = m; 10886 }), c = h[i.toLowerCase()]; 10887 } catch { 10888 } 10889 return c; 10890 } 10891 set options(i) { 10892 this.privHeaders = i.headers, this.privIgnoreCache = i.ignoreCache; 10893 } 10894 setHeaders(i, o) { 10895 this.privHeaders[i] = o; 10896 } 10897 request(i, o, c = {}, u = null) { 10898 const h = new s.Deferred(), d = i === p.File ? "POST" : i, v = (m, S = {}) => { 10899 const l = m; 10900 return { 10901 data: JSON.stringify(S), 10902 headers: JSON.stringify(m.headers), 10903 json: S, 10904 ok: m.statusCode >= 200 && m.statusCode < 300, 10905 status: m.statusCode, 10906 statusText: S.error ? S.error.message : l.statusText ? l.statusText : l.statusMessage 10907 }; 10908 }, f = (m) => { 10909 const S = (0, r.default)(o, d, this.privHeaders, 200, 201, 202, 204, 400, 401, 402, 403, 404), l = this.queryParams(c) === "" ? "" : `?${this.queryParams(c)}`; 10910 S(l, m).then(async (g) => { 10911 if (i === p.Delete || g.statusCode === 204) 10912 h.resolve(v(g)); 10913 else 10914 try { 10915 const C = await g.json(); 10916 h.resolve(v(g, C)); 10917 } catch { 10918 h.resolve(v(g)); 10919 } 10920 }).catch((g) => { 10921 h.reject(g); 10922 }); 10923 }; 10924 return this.privIgnoreCache && (this.privHeaders["Cache-Control"] = "no-cache"), i === p.Post && u && (this.privHeaders["content-type"] = "application/json", this.privHeaders["Content-Type"] = "application/json"), f(u), h.promise; 10925 } 10926 queryParams(i = {}) { 10927 return Object.keys(i).map((o) => encodeURIComponent(o) + "=" + encodeURIComponent(i[o])).join("&"); 10928 } 10929 } 10930 t.RestMessageAdapter = a; 10931})(Ic); 10932var Br = {}; 10933Object.defineProperty(Br, "__esModule", { value: !0 }); 10934Br.RestConfigBase = void 0; 10935class Pe { 10936 static get requestOptions() { 10937 return Pe.privDefaultRequestOptions; 10938 } 10939 static get configParams() { 10940 return Pe.privDefaultParams; 10941 } 10942 static get restErrors() { 10943 return Pe.privRestErrors; 10944 } 10945} 10946Br.RestConfigBase = Pe; 10947Pe.privDefaultRequestOptions = { 10948 headers: { 10949 Accept: "application/json" 10950 }, 10951 ignoreCache: !1, 10952 timeout: 1e4 10953}; 10954Pe.privRestErrors = { 10955 authInvalidSubscriptionKey: "You must specify either an authentication token to use, or a Cognitive Speech subscription key.", 10956 authInvalidSubscriptionRegion: "You must specify the Cognitive Speech region to use.", 10957 invalidArgs: "Required input not found: {arg}.", 10958 invalidCreateJoinConversationResponse: "Creating/Joining conversation failed with HTTP {status}.", 10959 invalidParticipantRequest: "The requested participant was not found.", 10960 permissionDeniedConnect: "Required credentials not found.", 10961 permissionDeniedConversation: "Invalid operation: only the host can {command} the conversation.", 10962 permissionDeniedParticipant: "Invalid operation: only the host can {command} a participant.", 10963 permissionDeniedSend: "Invalid operation: the conversation is not in a connected state.", 10964 permissionDeniedStart: "Invalid operation: there is already an active conversation." 10965}; 10966Pe.privDefaultParams = { 10967 apiVersion: "api-version", 10968 authorization: "Authorization", 10969 clientAppId: "X-ClientAppId", 10970 contentTypeKey: "Content-Type", 10971 correlationId: "X-CorrelationId", 10972 languageCode: "language", 10973 nickname: "nickname", 10974 profanity: "profanity", 10975 requestId: "X-RequestId", 10976 roomId: "roomid", 10977 sessionToken: "token", 10978 subscriptionKey: "Ocp-Apim-Subscription-Key", 10979 subscriptionRegion: "Ocp-Apim-Subscription-Region", 10980 token: "X-CapitoToken" 10981}; 10982var Do; 10983function re() { 10984 return Do || (Do = 1, function(t) { 10985 var e = k && k.__createBinding || (Object.create ? function(s, p, a, n) { 10986 n === void 0 && (n = a), Object.defineProperty(s, n, { enumerable: !0, get: function() { 10987 return p[a]; 10988 } }); 10989 } : function(s, p, a, n) { 10990 n === void 0 && (n = a), s[n] = p[a]; 10991 }), r = k && k.__exportStar || function(s, p) { 10992 for (var a in s) a !== "default" && !Object.prototype.hasOwnProperty.call(p, a) && e(p, s, a); 10993 };
10994 Object.defineProperty(t, "__esModule", { value: !0 }), r(fi, t), r(Fa, t), r(nd(), t), r(sd(), t), r(gi, t), r(mi, t), r(kr, t), r(Si, t), r(Jv(), t), r(Ic, t), r(Br, t); 10995 }(ln)), ln; 10996} 10997var xe = {}; 10998Object.defineProperty(xe, "__esModule", { value: !0 }); 10999xe.SpeechConnectionMessage = void 0; 11000const Pn = I(), ve = Y; 11001class Vn extends Pn.ConnectionMessage { 11002 constructor(e, r, s, p, a, n, i, o) { 11003 if (!r) 11004 throw new Pn.ArgumentNullError("path"); 11005 if (!s) 11006 throw new Pn.ArgumentNullError("requestId"); 11007 const c = {}; 11008 if (c[ve.HeaderNames.Path] = r, c[ve.HeaderNames.RequestId] = s, c[ve.HeaderNames.RequestTimestamp] = (/* @__PURE__ */ new Date()).toISOString(), p && (c[ve.HeaderNames.ContentType] = p), n && (c[ve.HeaderNames.RequestStreamId] = n), i) 11009 for (const u in i) 11010 u && (c[u] = i[u]); 11011 o ? super(e, a, c, o) : super(e, a, c), this.privPath = r, this.privRequestId = s, this.privContentType = p, this.privStreamId = n, this.privAdditionalHeaders = i; 11012 } 11013 get path() { 11014 return this.privPath; 11015 } 11016 get requestId() { 11017 return this.privRequestId; 11018 } 11019 get contentType() { 11020 return this.privContentType; 11021 } 11022 get streamId() { 11023 return this.privStreamId; 11024 } 11025 get additionalHeaders() { 11026 return this.privAdditionalHeaders; 11027 } 11028 static fromConnectionMessage(e) { 11029 let r = null, s = null, p = null, a = null; 11030 const n = {}; 11031 if (e.headers) 11032 for (const i in e.headers) 11033 i && (i.toLowerCase() === ve.HeaderNames.Path.toLowerCase() ? r = e.headers[i] : i.toLowerCase() === ve.HeaderNames.RequestId.toLowerCase() ? s = e.headers[i] : i.toLowerCase() === ve.HeaderNames.ContentType.toLowerCase() ? p = e.headers[i] : i.toLowerCase() === ve.HeaderNames.RequestStreamId.toLowerCase() ? a = e.headers[i] : n[i] = e.headers[i]); 11034 return new Vn(e.messageType, r, s, p, e.body, a, n, e.id); 11035 } 11036} 11037xe.SpeechConnectionMessage = Vn; 11038var wc = {}; 11039(function(t) { 11040 Object.defineProperty(t, "__esModule", { value: !0 }), t.SegmentationMode = void 0, function(e) { 11041 e.Normal = "Normal", e.Disabled = "Disabled", e.Custom = "Custom", e.Semantic = "Semantic"; 11042 }(t.SegmentationMode || (t.SegmentationMode = {})); 11043})(wc); 11044var _c = {}; 11045(function(t) { 11046 Object.defineProperty(t, "__esModule", { value: !0 }), t.NextAction = void 0, function(e) { 11047 e.None = "None", e.Synthesize = "Synthesize"; 11048 }(t.NextAction || (t.NextAction = {})); 11049})(_c); 11050var bc = {}; 11051(function(t) { 11052 Object.defineProperty(t, "__esModule", { value: !0 }), t.Mode = void 0, function(e) { 11053 e.None = "None", e.Always = "Always"; 11054 }(t.Mode || (t.Mode = {})); 11055})(bc); 11056var Mc = {}; 11057(function(t) { 11058 Object.defineProperty(t, "__esModule", { value: !0 }), t.LanguageIdDetectionPriority = t.LanguageIdDetectionMode = void 0, function(e) { 11059 e.DetectAtAudioStart = "DetectAtAudioStart", e.DetectContinuous = "DetectContinuous", e.DetectSegments = "DetectSegments"; 11060 }(t.LanguageIdDetectionMode || (t.LanguageIdDetectionMode = {})), function(e) { 11061 e.Auto = "Auto", e.PrioritizeLatency = "PrioritizeLatency", e.PrioritizeAccuracy = "PrioritizeAccuracy"; 11062 }(t.LanguageIdDetectionPriority || (t.LanguageIdDetectionPriority = {})); 11063})(Mc); 11064var Oc = {}; 11065(function(t) { 11066 Object.defineProperty(t, "__esModule", { value: !0 }), t.NextAction = void 0, function(e) { 11067 e.Recognize = "Recognize", e.None = "None"; 11068 }(t.NextAction || (t.NextAction = {})); 11069})(Oc); 11070var Dc = {}; 11071(function(t) { 11072 Object.defineProperty(t, "__esModule", { value: !0 }), t.OnUnknownAction = void 0, function(e) { 11073 e.RecognizeWithDefaultLanguage = "RecognizeWithDefaultLanguage", e.None = "None"; 11074 }(t.OnUnknownAction || (t.OnUnknownAction = {})); 11075})(Dc); 11076var kc = {}; 11077(function(t) { 11078 Object.defineProperty(t, "__esModule", { value: !0 }), t.ResultType = void 0, function(e) { 11079 e.Auto = "Auto", e.StableFragment = "StableFragment", e.Hypothesis = "Hypothesis", e.None = "None"; 11080 }(t.ResultType || (t.ResultType = {})); 11081})(kc); 11082var Nc = {}; 11083(function(t) { 11084 Object.defineProperty(t, "__esModule", { value: !0 }), t.PhraseResultOutputType = void 0, function(e) { 11085 e.Always = "Always", e.None = "None"; 11086 }
11086(t.PhraseResultOutputType || (t.PhraseResultOutputType = {})); 11087})(Nc); 11088var zc = {}; 11089(function(t) { 11090 Object.defineProperty(t, "__esModule", { value: !0 }), t.NextAction = void 0, function(e) { 11091 e.None = "None", e.Translate = "Translate"; 11092 }(t.NextAction || (t.NextAction = {})); 11093})(zc); 11094var ko; 11095function Zv() { 11096 if (ko) return tt; 11097 ko = 1, Object.defineProperty(tt, "__esModule", { value: !0 }), tt.ServiceRecognizerBase = void 0; 11098 const t = re(), e = I(), r = R(), s = A(), p = xe, a = wc, n = ae, i = _c, o = bc, c = Mc, u = Oc, h = Dc, d = kc, v = Nc, f = zc; 11099 let m = class Er { 11100 constructor(l, g, C, y, P) { 11101 if (this.privConnectionConfigurationPromise = void 0, this.privConnectionPromise = void 0, this.privSetTimeout = setTimeout, this.privIsLiveAudio = !1, this.privAverageBytesPerMs = 0, this.privEnableSpeakerId = !1, this.privExpectContentAssessmentResponse = !1, this.recognizeOverride = void 0, this.disconnectOverride = void 0, this.receiveMessageOverride = void 0, this.sendPrePayloadJSONOverride = void 0, this.postConnectImplOverride = void 0, this.configConnectionOverride = void 0, this.handleSpeechPhraseMessage = void 0, this.handleSpeechHypothesisMessage = void 0, !l) 11102 throw new e.ArgumentNullError("authentication"); 11103 if (!g) 11104 throw new e.ArgumentNullError("connectionFactory"); 11105 if (!C) 11106 throw new e.ArgumentNullError("audioSource"); 11107 if (!y) 11108 throw new e.ArgumentNullError("recognizerConfig"); 11109 this.privEnableSpeakerId = y.isSpeakerDiarizationEnabled, this.privMustReportEndOfStream = !1, this.privAuthentication = l, this.privConnectionFactory = g, this.privAudioSource = C, this.privRecognizerConfig = y, this.privIsDisposed = !1, this.privRecognizer = P, this.privRequestSession = new s.RequestSession(this.privAudioSource.id()), this.privConnectionEvents = new e.EventSource(), this.privServiceEvents = new e.EventSource(), this.privDynamicGrammar = new s.DynamicGrammarBuilder(), this.privSpeechContext = new s.SpeechContext(this.privDynamicGrammar), this.privAgentConfig = new s.AgentConfig(), this.privRecognizerConfig.parameters.getProperty(r.PropertyId.WebWorkerLoadType, "on").toLowerCase() === "on" && typeof Blob < "u" && typeof Worker < "u" ? this.privSetTimeout = e.Timeout.setTimeout : (typeof window < "u" && (this.privSetTimeout = window.setTimeout.bind(window)), typeof globalThis < "u" && (this.privSetTimeout = globalThis.setTimeout.bind(globalThis))), this.connectionEvents.attach((_) => { 11110 if (_.name === "ConnectionClosedEvent") { 11111 const E = _; 11112 (E.statusCode === 1003 || E.statusCode === 1007 || E.statusCode === 1002 || E.statusCode === 4e3 || this.privRequestSession.numConnectionAttempts > this.privRecognizerConfig.maxRetryCount) && this.cancelRecognitionLocal(r.CancellationReason.Error, E.statusCode === 1007 ? r.CancellationErrorCode.BadRequestParameters : r.CancellationErrorCode.ConnectionFailure, `${E.reason} websocket error code: ${E.statusCode}`); 11113 } 11114 }), this.privEnableSpeakerId && (this.privDiarizationSessionId = (0, e.createNoDashGuid)()); 11115 } 11116 setTranslationJson() { 11117 const l = this.privRecognizerConfig.parameters.getProperty(r.PropertyId.SpeechServiceConnection_TranslationToLanguages, void 0); 11118 if (l !== void 0) { 11119 const g = l.split(","), C = this.privRecognizerConfig.parameters.getProperty(r.PropertyId.SpeechServiceConnection_TranslationVoice, void 0), y = this.privRecognizerConfig.parameters.getProperty(r.PropertyId.SpeechServiceConnection_TranslationCategoryId, void 0), P = C !== void 0 ? i.NextAction.Synthesize : i.NextAction.None; 11120 if (this.privSpeechContext.getContext().translation = { 11121 onPassthrough: { action: P }, 11122 onSuccess: { action: P }, 11123 output: { 11124 includePassThroughResults: !0, 11125 interimResults: { mode: o.Mode.Always } 11126 }, 11127 targetLanguages: g 11128 }, y !== void 0 && (this.privSpeechContext.getContext().translation.category = y), C !== void 0) { 11129 const _ = {}; 11130 for (const E of g) 11131 _[E] = C; 11132 this.privSpeechContext.getContext().synthesis = { 11133 defaultVoices: _ 11134 }; 11135 } 11136 const T = this.privSpeechContext.getContext().phraseDetection || {}; 11137 T.onSuccess = { action: f.NextAction.Translate }, T.onInterim = { action: f.NextAction.Translate }, this.privSpeechContext.getContext().phraseDetection = T; 11138 } 11139 } 11140 setSpeechSegmentationTimeoutJson() { 11141 const l = this.privRecognizerConfig.parameters.getProperty(r.PropertyId.Speech_SegmentationSilenceTimeoutMs, void 0), g = this.privRecognizerConfig.parameters.getProperty(r.PropertyId.Speech_SegmentationMaximumTimeMs, void 0), C = this.privRecognizerConfig.parameters.getProperty(r.PropertyId.Speech_SegmentationStrategy, void 0), y = { 11142 mode: a.SegmentationMode.Normal 11143 }; 11144 let P = !1; 11145 if (C !== void 0) { 11146 P = !0; 11147 let T = a.SegmentationMode.Normal; 11148 switch (C.toLowerCase()) { 11149 case "default": 11150 break; 11151 case "time": 11152 T = a.SegmentationMode.Custom; 11153 break; 11154 case "semantic": 11155 T = a.SegmentationMode.Semantic; 11156 break; 11157 } 11158 y.mode = T; 11159 } 11160 if (l !== void 0) { 11161 P = !0; 11162 const T = parseInt(l, 10); 11163 y.mode = a.SegmentationMode.Custom, y.segmentationSilenceTimeoutMs = T; 11164 } 11165 if (g !== void 0) { 11166 P = !0; 11167 const T = parseInt(g, 10); 11168 y.mode = a.SegmentationMode.Custom, y.segmentationForcedTimeoutMs = T; 11169 } 11170 if (P) { 11171 const T = this.privSpeechContext.getContext().phraseDetection || {}; 11172 switch (T.mode = this.recognitionMode, this.recognitionMode) { 11173 case n.RecognitionMode.Conversation: 11174 T.conversation = T.conversation ?? { segmentation: {} }, T.conversation.segmentation = y; 11175 break; 11176 case n.RecognitionMode.Interactive: 11177 T.interactive = T.interactive ?? { segmentation: {} }, T.interactive.segmentation = y; 11178 break; 11179 case n.RecognitionMode.Dictation: 11180 T.dictation = T.dictation ?? {}, T.dictation.segmentation = y; 11181 break; 11182 } 11183 this.privSpeechContext.getContext().phraseDetection = T; 11184 } 11185 } 11186 setLanguageIdJson() { 11187 const l = this.privSpeechContext.getContext().phraseDetection || {}; 11188 if (this.privRecognizerConfig.autoDetectSourceLanguages !== void 0) { 11189 const g = this.privRecognizerConfig.autoDetectSourceLanguages.split(","); 11190 g.length === 1 && g[0] === s.AutoDetectSourceLanguagesOpenRangeOptionName && (g[0] = "UND"); 11191 let C; 11192 this.privRecognizerConfig.languageIdMode === "Continuous" ? C = c.LanguageIdDetectionMode.DetectContinuous : C = c.LanguageIdDetectionMode.DetectAtAudioStart, this.privSpeechContext.getContext().languageId = { 11193 languages: g, 11194 mode: C, 11195 onSuccess: { action: u.NextAction.Recognize }, 11196 onUnknown: { action: h.OnUnknownAction.None }, 11197 priority: c.LanguageIdDetectionPriority.PrioritizeLatency 11198 }, this.privSpeechContext.getContext().phraseOutput = { 11199 interimResults: { 11200 resultType: d.ResultType.Auto 11201 }, 11202 phraseResults: {
11203 resultType: v.PhraseResultOutputType.Always 11204 } 11205 }; 11206 const y = this.privRecognizerConfig.sourceLanguageModels; 11207 y !== void 0 && (l.customModels = y, l.onInterim = { action: f.NextAction.None }, l.onSuccess = { action: f.NextAction.None }); 11208 } 11209 this.privSpeechContext.getContext().phraseDetection = l; 11210 } 11211 setOutputDetailLevelJson() { 11212 this.privEnableSpeakerId && (this.privRecognizerConfig.parameters.getProperty(r.PropertyId.SpeechServiceResponse_RequestWordLevelTimestamps, "false").toLowerCase() === "true" ? this.privSpeechContext.setWordLevelTimings() : this.privRecognizerConfig.parameters.getProperty(s.OutputFormatPropertyName, r.OutputFormat[r.OutputFormat.Simple]).toLowerCase() === r.OutputFormat[r.OutputFormat.Detailed].toLocaleLowerCase() && this.privSpeechContext.setDetailedOutputFormat()); 11213 } 11214 setSpeechStartEventSensitivityJson() { 11215 const l = this.privRecognizerConfig.parameters.getProperty(r.PropertyId.Speech_StartEventSensitivity, void 0); 11216 if (l !== void 0) { 11217 let g = !1; 11218 switch (l.toLowerCase()) { 11219 case n.SpeechStartEventSensitivity.Low: 11220 case n.SpeechStartEventSensitivity.Medium: 11221 case n.SpeechStartEventSensitivity.High: 11222 g = !0; 11223 break; 11224 } 11225 if (g) { 11226 const C = this.privSpeechContext.getContext().phraseDetection || {}; 11227 C.voiceOnsetSensitivity = l.toLowerCase(), this.privSpeechContext.getContext().phraseDetection = C; 11228 } 11229 } 11230 } 11231 get isSpeakerDiarizationEnabled() { 11232 return this.privEnableSpeakerId; 11233 } 11234 get audioSource() { 11235 return this.privAudioSource; 11236 } 11237 get speechContext() { 11238 return this.privSpeechContext; 11239 } 11240 get dynamicGrammar() { 11241 return this.privDynamicGrammar; 11242 } 11243 get agentConfig() { 11244 return this.privAgentConfig; 11245 } 11246 set conversationTranslatorToken(l) { 11247 this.privRecognizerConfig.parameters.setProperty(r.PropertyId.ConversationTranslator_Token, l); 11248 } 11249 set authentication(l) { 11250 this.privAuthentication = l; 11251 } 11252 isDisposed() { 11253 return this.privIsDisposed; 11254 } 11255 async dispose(l) { 11256 if (this.privIsDisposed = !0, this.privConnectionPromise !== void 0) 11257 try { 11258 await (await this.privConnectionPromise).dispose(l); 11259 } catch { 11260 return; 11261 } 11262 } 11263 get connectionEvents() { 11264 return this.privConnectionEvents; 11265 } 11266 get serviceEvents() { 11267 return this.privServiceEvents; 11268 } 11269 get recognitionMode() { 11270 return this.privRecognizerConfig.recognitionMode; 11271 } 11272 async recognize(l, g, C) { 11273 if (this.recognizeOverride !== void 0) { 11274 await this.recognizeOverride(l, g, C); 11275 return; 11276 } 11277 if (this.privConnectionConfigurationPromise = void 0, this.privRecognizerConfig.recognitionMode = l, this.privRecognizerConfig.recognitionEndpointVersion === "2") { 11278 const E = this.privSpeechContext.getContext().phraseDetection || {}; 11279 E.mode = l, this.privSpeechContext.getContext().phraseDetection = E; 11280 } 11281 this.setLanguageIdJson(), this.setTranslationJson(), this.privRecognizerConfig.autoDetectSourceLanguages !== void 0 && this.privRecognizerConfig.parameters.getProperty(r.PropertyId.SpeechServiceConnection_TranslationToLanguages, void 0) !== void 0 && this.setupTranslationWithLanguageId(), this.setSpeechSegmentationTimeoutJson(), this.setOutputDetailLevelJson(), this.setSpeechStartEventSensitivityJson(), this.privSuccessCallback = g, this.privErrorCallback = C, this.privRequestSession.startNewRecognition(), this.privRequestSession.listenForServiceTelemetry(this.privAudioSource.events); 11282 const y = this.connectImpl(); 11283 let P; 11284 try { 11285 const E = await this.audioSource.attach(this.privRequestSession.audioNodeId), z = await this.audioSource.format, L = await this.audioSource.deviceInfo; 11286 this.privIsLiveAudio = L.type && L.type === s.type.Microphones, P = new t.ReplayableAudioNode(E, z.avgBytesPerSec), await this.privRequestSession.onAudioSourceAttachCompleted(P, !1), this.privRecognizerConfig.SpeechServiceConfig.Context.audio = { source: L }; 11287 } catch (E) {
11288 throw await this.privRequestSession.onStopRecognizing(), E; 11289 } 11290 try { 11291 await y; 11292 } catch (E) { 11293 await this.cancelRecognitionLocal(r.CancellationReason.Error, r.CancellationErrorCode.ConnectionFailure, E); 11294 return; 11295 } 11296 const T = new r.SessionEventArgs(this.privRequestSession.sessionId); 11297 this.privRecognizer.sessionStarted && this.privRecognizer.sessionStarted(this.privRecognizer, T), this.receiveMessage(), this.sendAudio(P).catch(async (E) => { 11298 await this.cancelRecognitionLocal(r.CancellationReason.Error, r.CancellationErrorCode.RuntimeError, E); 11299 }); 11300 } 11301 async stopRecognizing() { 11302 if (this.privRequestSession.isRecognizing) 11303 try { 11304 await this.audioSource.turnOff(), await this.sendFinalAudio(), await this.privRequestSession.onStopRecognizing(), await this.privRequestSession.turnCompletionPromise; 11305 } finally { 11306 await this.privRequestSession.dispose(); 11307 } 11308 } 11309 async connect() { 11310 return await this.connectImpl(), Promise.resolve(); 11311 } 11312 connectAsync(l, g) { 11313 this.connectImpl().then(() => { 11314 try { 11315 l && l(); 11316 } catch (C) { 11317 g && g(C); 11318 } 11319 }, (C) => { 11320 try { 11321 g && g(C); 11322 } catch { 11323 } 11324 }); 11325 } 11326 async disconnect() { 11327 if (await this.cancelRecognitionLocal(r.CancellationReason.Error, r.CancellationErrorCode.NoError, "Disconnecting"), this.disconnectOverride !== void 0 && await this.disconnectOverride(), this.privConnectionPromise !== void 0) 11328 try { 11329 await (await this.privConnectionPromise).dispose(); 11330 } catch { 11331 } 11332 this.privConnectionPromise = void 0; 11333 } 11334 // eslint-disable-next-line @typescript-eslint/no-unused-vars 11335 sendMessage(l) { 11336 } 11337 async sendNetworkMessage(l, g) { 11338 const C = typeof g == "string" ? e.MessageType.Text : e.MessageType.Binary, y = typeof g == "string" ? "application/json" : ""; 11339 return (await this.fetchConnection()).send(new p.SpeechConnectionMessage(C, l, this.privRequestSession.requestId, y, g)); 11340 } 11341 set activityTemplate(l) { 11342 this.privActivityTemplate = l; 11343 } 11344 get activityTemplate() { 11345 return this.privActivityTemplate; 11346 } 11347 set expectContentAssessmentResponse(l) { 11348 this.privExpectContentAssessmentResponse = l; 11349 } 11350 async sendTelemetryData() { 11351 const l = this.privRequestSession.getTelemetry(); 11352 if (Er.telemetryDataEnabled !== !0 || this.privIsDisposed || l === null) 11353 return; 11354 if (Er.telemetryData) 11355 try { 11356 Er.telemetryData(l); 11357 } catch { 11358 } 11359 await (await this.fetchConnection()).send(new p.SpeechConnectionMessage(e.MessageType.Text, "telemetry", this.privRequestSession.requestId, "application/json", l)); 11360 } 11361 // Cancels recognition. 11362 async cancelRecognitionLocal(l, g, C) { 11363 this.privRequestSession.isRecognizing && (await this.privRequestSession.onStopRecognizing(
11363), this.cancelRecognition(this.privRequestSession.sessionId, this.privRequestSession.requestId, l, g, C)); 11364 } 11365 async receiveMessage() { 11366 try { 11367 if (this.privIsDisposed) 11368 return; 11369 let l = await this.fetchConnection(); 11370 const g = await l.read(); 11371 if (this.receiveMessageOverride !== void 0) 11372 return this.receiveMessageOverride(); 11373 if (!g) 11374 return this.receiveMessage(); 11375 this.privServiceHasSentMessage = !0; 11376 const C = p.SpeechConnectionMessage.fromConnectionMessage(g); 11377 if (C.requestId.toLowerCase() === this.privRequestSession.requestId.toLowerCase()) 11378 switch (C.path.toLowerCase()) { 11379 case "turn.start": 11380 this.privMustReportEndOfStream = !0, this.privRequestSession.onServiceTurnStartResponse(); 11381 break; 11382 case "speech.startdetected": 11383 const y = s.SpeechDetected.fromJSON(C.textBody, this.privRequestSession.currentTurnAudioOffset), P = new r.RecognitionEventArgs(y.Offset, this.privRequestSession.sessionId); 11384 this.privRecognizer.speechStartDetected && this.privRecognizer.speechStartDetected(this.privRecognizer, P); 11385 break; 11386 case "speech.enddetected": 11387 let T; 11388 C.textBody.length > 0 ? T = C.textBody : T = "{ Offset: 0 }"; 11389 const _ = s.SpeechDetected.fromJSON(T, this.privRequestSession.currentTurnAudioOffset), E = new r.RecognitionEventArgs(_.Offset + this.privRequestSession.currentTurnAudioOffset, this.privRequestSession.sessionId); 11390 this.privRecognizer.speechEndDetected && this.privRecognizer.speechEndDetected(this.privRecognizer, E); 11391 break; 11392 case "turn.end": 11393 await this.sendTelemetryData(), this.privRequestSession.isSpeechEnded && this.privMustReportEndOfStream && (this.privMustReportEndOfStream = !1, await this.cancelRecognitionLocal(r.CancellationReason.EndOfStream, r.CancellationErrorCode.NoError, void 0)); 11394 const z = new r.SessionEventArgs(this.privRequestSession.sessionId); 11395 if (await this.privRequestSession.onServiceTurnEndResponse(this.privRecognizerConfig.isContinuousRecognition), !this.privRecognizerConfig.isContinuousRecognition || this.privRequestSession.isSpeechEnded || !this.privRequestSession.isRecognizing) { 11396 this.privRecognizer.sessionStopped && this.privRecognizer.sessionStopped(this.privRecognizer, z); 11397 return; 11398 } else 11399 l = await this.fetchConnection(), await this.sendPrePayloadJSON(l); 11400 break; 11401 default: 11402 await this.processTypeSpecificMessages(C) || this.privServiceEvents && this.serviceEvents.onEvent(new e.ServiceEvent(C.path.toLowerCase(), C.textBody)); 11403 } 11404 return this.receiveMessage(); 11405 } catch { 11406 return null; 11407 } 11408 } 11409 updateSpeakerDiarizationAudioOffset() { 11410 const l = this.privRequestSession.recognitionBytesSent, g = this.privAverageBytesPerMs !== 0 ? l / this.privAverageBytesPerMs : 0; 11411 this.privSpeechContext.setSpeakerDiarizationAudioOffsetMs(g); 11412 } 11413 sendSpeechContext(l, g) { 11414 this.privEnableSpeakerId && this.updateSpeakerDiarizationAudioOffset(); 11415 const C = this.speechContext.toJSON(); 11416 if (g && this.privRequestSession.onSpeechContext(), C) 11417 return l.send(new p.SpeechConnectionMessage(e.MessageType.Text, "speech.context", this.privRequestSession.requestId, "application/json", C)); 11418 } 11419 setupTranslationWithLanguageId() { 11420 const l = this.privRecognizerConfig.parameters.getProperty(r.PropertyId.SpeechServiceConnection_TranslationToLanguages, void 0), g = this.privRecognizerConfig.autoDetectSourceLanguages !== void 0; 11421 if (l !== void 0 && g) { 11422 this.privSpeechContext.getContext().phraseOutput = { 11423 interimResults: { 11424 resultType: d.ResultType.None 11425 }, 11426 phraseResults: { 11427 resultType: v.PhraseResultOutputType.None 11428 } 11429 }; 11430 const C = this.privSpeechContext.getContext().translation; 11431 if (C) { 11432 const y = this.privRecognizerConfig.sourceLanguageModels; 11433 if (y !== void 0 && y.length > 0) { 11434 const T = this.privSpeechContext.getContext().phraseDetection || {}; 11435 T.customModels = y, this.privSpeechContext.getContext().phraseDetection = T; 11436 } 11437 this.privRecognizerConfig.parameters.getProperty(r.PropertyId.SpeechServiceConnection_TranslationVoice, void 0) !== void 0 && (C.onSuccess = { action: i.NextAction.Synthesize }, C.onPassthrough = { action: i.NextAction.Synthesize }); 11438 } 11439 } 11440 } 11441 noOp() { 11442 } 11443 // Encapsulated for derived service recognizers that need to send additional JSON 11444 async sendPrePayloadJSON(l, g = !0) { 11445 if (this.sendPrePayloadJSONOverride !== void 0) 11446 return this.sendPrePayloadJSONOverride(l); 11447 await this.sendSpeechContext(l, g), await this.sendWaveHeader(l); 11448 } 11449 async sendWaveHeader(l) { 11450 const g = await this.audioSource.format; 11451 return l.send(new p.SpeechConnectionMessage(e.MessageType.Binary, "audio", this.privRequestSession.requestId, "audio/x-wav", g.header)); 11452 } 11453 // Establishes a websocket connection to the end point. 11454 connectImpl() { 11455 return this.privConnectionPromise !== void 0 ? this.privConnectionPromise.then((l) => l.state() === e.ConnectionState.Disconnected ? (this.privConnectionId = null, this.privConnectionPromise = void 0, this.privServiceHasSentMessage = !1, this.connectImpl()) : this.privConnectionPromise, () => (this.privConnectionId = null, this.privConnectionPromise = void 0, this.privServiceHasSentMessage = !1, this.connectImpl())) : (this.privConnectionPromise = this.retryableConnect(), this.privConnectionPromise.catch(() => { 11456 }), this.postConnectImplOverride !== void 0 ? this.postConnectImplOverride(this.privConnectionPromise) : this.privConnectionPromise); 11457 } 11458 sendSpeechServiceConfig(l, g, C) { 11459 if (g.onSpeechContext(), Er.telemetryDataEnabled !== !0) { 11460 const P = { 11461 context: { 11462 system: JSON.parse(C).context.system 11463 } 11464 }; 11465 C = JSON.stringify(P); 11466 } 11467 if (this.privRecognizerConfig.parameters.getProperty("f0f5debc-f8c9-4892-ac4b-90a7ab359fd2", "false").toLowerCase() === "true") { 11468 const y = JSON.parse(C); 11469 y.context.DisableReferenceChannel = "True", y.context.MicSpec = "1_0_0", C = JSON.stringify(y); 11470 } 11471 if (C) 11472 return l.send(new p.SpeechConnectionMessage(e.MessageType.Text, "speech.config", g.requestId, "application/json", C)); 11473 } 11474 async fetchConnection() { 11475 return this.privConnectionConfigurationPromise !== void 0 ? this.privConnectionConfigurationPromise.then((l) => l.state() === e.ConnectionState.Disconnected ? (this.privConnectionId = null, this.privConnectionConfigurationPromise = void 0, this.privServiceHasSentMessage = !1, this.fetchConnection()) : this.privConnectionConfigurationPromise, () => (this.privConnectionId = null, this.privConnectionConfigurationPromise = void 0, this.privServiceHasSentMessage = !1, this.fetchConnection())) : (this.privConnectionConfigurationPromise = this.configureConnection(), await this.privConnectionConfigurationPromise); 11476 } 11477 async sendAudio(l) { 11478 const g = await this.audioSource.format; 11479 this.privAverageBytesPerMs = g.avgBytesPerSec / 1e3; 11480 let C = Date.now(); 11481 const y = this.privRecognizerConfig.parameters.getProperty("SPEECH-TransmitLengthBeforThrottleMs", "5000"), P = g.avgBytesPerSec / 1e3 * parseInt(y, 10), T = this.privRequestSession.recogNumber, _ = async () => { 11482 if (!this.privIsDisposed && !this.privRequestSession.isSpeechEnded && this.privRequestSession.isRecognizing && this.privRequestSession.recogNumber === T) { 11483 const E = await this.fetchConnection(), z = await l.read(); 11484 if (this.privRequestSession.isSpeechEnded) 11485 return; 11486 let L, ne; 11487 if (!z || z.isEnd ? (L = null, ne = 0) : (L = z.buffer, this.privRequestSession.onAudioSent(L.byteLength), P >= this.privRequestSession.bytesSent ? ne = 0 : ne = Math.max(0, C - Date.now())), ne !== 0 && await this.delay(ne), L !== null && (C = Date.now() + L.byteLength * 1e3 / (g.avgBytesPerSec * 2)), !this.privIsDisposed && !this.privRequestSession.isSpeechEnded && this.privRequestSession.isRecognizing && this.privRequestSession.recogNumber === T) 11488 if (E.send(new p.SpeechConnectionMessage(e.MessageType.Binary, "audio", this.privRequestSession.requestId, null, L)).catch(() => { 11489 this.privRequestSession.onServiceTurnEndResponse(this.privRecognizerConfig.isContinuousRecognition).catch(() => { 11490 }); 11491 }), z != null && z.isEnd) 11492 this.privIsLiveAudio || this.privRequestSession.onSpeechEnded(); 11493 else 11494 return _(); 11495 } 11496 }; 11497 return _(); 11498 } 11499 async retryableConnect() { 11500 let l = !1; 11501 this.privAuthFetchEventId = (0, e.createNoDashGuid)(); 11502 const g = this.privRequestSession.sessionId; 11503 this.privConnectionId = g !== void 0 ? g : (0, e.createNoDashGuid)(), this.privRequestSession.onPreConnectionStart(this.privAuthFetchEventId, this.privConnectionId); 11504 let C = 0, y = ""; 11505 for (; this.privRequestSession.numConnectionAttempts <= this.privRecognizerConfig.maxRetryCount; ) { 11506 this.privRequestSession.onRetryConnection(); 11507 const T = await (l ? this.privAuthentication.fetchOnExpiry(this.privAuthFetchEventId) : this.privAuthentication.fetch(this.privAuthFetchEventId)); 11508 await this.privRequestSession.onAuthCompleted(!1); 11509 const _ = await this.privConnectionFactory.create(this.privRecognizerConfig, T, this.privConnectionId); 11510 this.privRequestSession.listenForServiceTelemetry(_.events), _.events.attach((z) => { 11511 this.connectionEvents.onEvent(z); 11512 });
11513 const E = await _.open(); 11514 if (E.statusCode === 200) 11515 return await this.privRequestSession.onConnectionEstablishCompleted(E.statusCode), Promise.resolve(_); 11516 E.statusCode === 1006 && (l = !0), C = E.statusCode, y = E.reason; 11517 } 11518 return await this.privRequestSession.onConnectionEstablishCompleted(C, y), Promise.reject(`Unable to contact server. StatusCode: ${C}, ${this.privRecognizerConfig.parameters.getProperty(r.PropertyId.SpeechServiceConnection_Endpoint)} Reason: ${y}`); 11519 } 11520 delay(l) { 11521 return new Promise((g) => this.privSetTimeout(g, l)); 11522 } 11523 writeBufferToConsole(l) { 11524 let g = "Buffer Size: "; 11525 if (l === null) 11526 g += "null"; 11527 else { 11528 const C = new Uint8Array(l); 11529 g += `${l.byteLength}\r 11530`; 11531 for (let y = 0; y < l.byteLength; y++) 11532 g += C[y].toString(16).padStart(2, "0") + " ", (y + 1) % 16 === 0 && (console.info(g), g = ""); 11533 } 11534 console.info(g); 11535 } 11536 async sendFinalAudio() { 11537 await (await this.fetchConnection()).send(new p.SpeechConnectionMessage(e.MessageType.Binary, "audio", this.privRequestSession.requestId, null, null)); 11538 } 11539 // Takes an established websocket connection to the endpoint and sends speech configuration information. 11540 async configureConnection() { 11541 const l = await this.connectImpl(); 11542 return this.configConnectionOverride !== void 0 ? this.configConnectionOverride(l) : (await this.sendSpeechServiceConfig(l, this.privRequestSession, this.privRecognizerConfig.SpeechServiceConfig.serialize()), await this.sendPrePayloadJSON(l, !1), l); 11543 } 11544 }; 11545 return tt.ServiceRecognizerBase = m, m.telemetryDataEnabled = !0, tt; 11546} 11547var Zt = {}, No; 11548function $v() { 11549 if (No) return Zt; 11550 No = 1, Object.defineProperty(Zt, "__esModule", { value: !0 }), Zt.ConversationServiceRecognizer = void 0; 11551 const t = R(), e = A(); 11552 let r = class extends e.ServiceRecognizerBase { 11553 constructor(p, a, n, i, o) { 11554 super(p, a, n, i, o), this.handleSpeechPhraseMessage = async (c) => this.handleSpeechPhrase(c), this.handleSpeechHypothesisMessage = (c) => this.handleSpeechHypothesis(c); 11555 } 11556 processTypeSpecificMessages(p) { 11557 } 11558 handleRecognizedCallback(p, a, n) { 11559 } 11560 handleRecognizingCallback(p, a, n) { 11561 } 11562 async processSpeechMessages(p) { 11563 let a = !1; 11564 switch (p.path.toLowerCase()) { 11565 case "speech.hypothesis": 11566 case "speech.fragment": 11567 this.handleSpeechHypothesisMessage && this.handleSpeechHypothesisMessage(p.textBody), a = !0; 11568 break; 11569 case "speech.phrase": 11570 this.handleSpeechPhraseMessage && await this.handleSpeechPhraseMessage(p.textBody), a = !0; 11571 break; 11572 } 11573 return a; 11574 } 11575 cancelRecognition(p, a, n, i, o) { 11576 } 11577 async handleSpeechPhrase(p) { 11578 const a = e.SimpleSpeechPhrase.fromJSON(p, this.privRequestSession.currentTurnAudioOffset), n = e.EnumTranslation.implTranslateRecognitionResult(a.RecognitionStatus); 11579 let i; 11580 const o = new t.PropertyCollection(); 11581 if (o.setProperty(t.PropertyId.SpeechServiceResponse_JsonResult, p), this.privRequestSession.onPhraseRecognized(a.Offset + a.Duration), t.ResultReason.Canceled === n) { 11582 const c = e.EnumTranslation.implTranslateCancelResult(a.RecognitionStatus), u = e.EnumTranslation.implTranslateCancelErrorCode(a.RecognitionStatus); 11583 await this.cancelRecognitionLocal(c, u, e.EnumTranslation.implTranslateErrorDetails(u)); 11584 } else if (a.RecognitionStatus !== e.RecognitionStatus.EndOfDictation) { 11585 if (this.privRecognizerConfig.parameters.getProperty(e.OutputFormatPropertyName) === t.OutputFormat[t.OutputFormat.Simple]) 11586 i = new t.SpeechRecognitionResult(this.privRequestSession.requestId, n, a.DisplayText, a.Duration, a.Offset, a.Language, a.LanguageDetectionConfidence, a.SpeakerId, void 0, a.asJson(), o); 11587 else { 11588 const c = e.DetailedSpeechPhrase.fromJSON(p, this.privRequestSession.currentTurnAudioOffset); 11589 i = new t.SpeechRecognitionResult(this.privRequestSession.requestId, n, c.Text, c.Duration, c.Offset, c.Language, c.LanguageDetectionConfidence, c.SpeakerId, void 0, c.asJson(), o); 11590 } 11591 this.handleRecognizedCallback(i, i.offset, this.privRequestSession.sessionId); 11592 } 11593 } 11594 handleSpeechHypothesis(p) { 11595 const a = e.SpeechHypothesis.fromJSON(p, this.privRequestSession.currentTurnAudioOffset), n = new t.PropertyCollection(); 11596 n.setProperty(t.PropertyId.SpeechServiceResponse_JsonResult, p); 11597 const i = new t.SpeechRecognitionResult(this.privRequestSession.requestId, t.ResultReason.RecognizingSpeech, a.Text, a.Duration, a.Offset, a.Language, a.LanguageDetectionConfidence, a.SpeakerId, void 0, a.asJson(), n); 11598 this.privRequestSession.onHypothesis(a.Offset), this.handleRecognizingCallback(i, a.Duration, this.privRequestSession.sessionId); 11599 } 11600 }; 11601 return Zt.ConversationServiceRecognizer = r, Zt; 11602} 11603var Rn = {}, zo; 11604function el() { 11605 return zo || (zo = 1, function(t) { 11606 Object.defineProperty(t, "__esModule", { value: !0 }), t.RecognizerConfig = t.SpeechResultFormat = void 0; 11607 const e = R(), r = A(), s = ae; 11608 (function(a) { 11609 a[a.Simple = 0] = "Simple", a[a.Detailed = 1] = "Detailed"; 11610 })(t.SpeechResultFormat || (t.SpeechResultFormat = {})); 11611 class p { 11612 constructor(n, i) { 11613 this.privSpeechServiceConfig = n || new r.SpeechServiceConfig(new r.Context(null)), this.privParameters = i, this.privMaxRetryCount = parseInt(i.getProperty("SPEECH-Error-MaxRetryCount", "4"), 10), this.privLanguageIdMode = i.getProperty(e.PropertyId.SpeechServiceConnection_LanguageIdMode, void 0), this.privEnableSpeakerId = !1; 11614 } 11615 get parameters() { 11616 return this.privParameters; 11617 } 11618 get recognitionMode() { 11619 return this.privRecognitionMode; 11620 } 11621 set recognitionMode(n) { 11622 this.privRecognitionMode = n, this.privRecognitionActivityTimeout = n === s.RecognitionMode.Interactive ? 8e3 : 25e3, this.privSpeechServiceConfig.Recognition = s.RecognitionMode[n]; 11623 } 11624 get SpeechServiceConfig() { 11625 return this.privSpeechServiceConfig; 11626 } 11627 get recognitionActivityTimeout() { 11628 return this.privRecognitionActivityTimeout; 11629 } 11630 get isContinuousRecognition() { 11631 return this.privRecognitionMode !== s.RecognitionMode.Interactive; 11632 } 11633 get languageIdMode() { 11634 return this.privLanguageIdMode;
11635 } 11636 get autoDetectSourceLanguages() { 11637 return this.parameters.getProperty(e.PropertyId.SpeechServiceConnection_AutoDetectSourceLanguages, void 0); 11638 } 11639 get recognitionEndpointVersion() { 11640 return this.parameters.getProperty(e.PropertyId.SpeechServiceConnection_RecognitionEndpointVersion, "2"); 11641 } 11642 set recognitionEndpointVersion(n) { 11643 this.parameters.setProperty(e.PropertyId.SpeechServiceConnection_RecognitionEndpointVersion, n); 11644 } 11645 get sourceLanguageModels() { 11646 const n = []; 11647 let i = !1; 11648 if (this.autoDetectSourceLanguages !== void 0) 11649 for (const o of this.autoDetectSourceLanguages.split(",")) { 11650 const c = o + e.PropertyId.SpeechServiceConnection_EndpointId.toString(), u = this.parameters.getProperty(c, void 0); 11651 u !== void 0 ? (n.push({ language: o, endpoint: u }), i = !0) : n.push({ language: o, endpoint: "" }); 11652 } 11653 return i ? n : void 0; 11654 } 11655 get maxRetryCount() { 11656 return this.privMaxRetryCount; 11657 } 11658 get isSpeakerDiarizationEnabled() { 11659 return this.privEnableSpeakerId; 11660 } 11661 set isSpeakerDiarizationEnabled(n) { 11662 this.privEnableSpeakerId = n; 11663 } 11664 } 11665 t.RecognizerConfig = p; 11666 }(Rn)), Rn; 11667} 11668var jc = {}; 11669Object.defineProperty(jc, "__esModule", { value: !0 }); 11670var xi = {}; 11671Object.defineProperty(xi, "__esModule", { value: !0 }); 11672xi.WebsocketMessageFormatter = void 0; 11673const se = I(), jo = `\r 11674`; 11675class tl { 11676 toConnectionMessage(e) { 11677 const r = new se.Deferred(); 11678 try { 11679 if (e.messageType === se.MessageType.Text) { 11680 const s = e.textContent; 11681 let p = {}, a = null; 11682 if (s) { 11683 const n = s.split(`\r 11684\r 11685`); 11686 n && n.length > 0 && (p = this.parseHeaders(n[0]), n.length > 1 && (a = n[1])); 11687 } 11688 r.resolve(new se.ConnectionMessage(e.messageType, a, p, e.id)); 11689 } else if (e.messageType === se.MessageType.Binary) { 11690 const s = e.binaryContent; 11691 let p = {}, a = null; 11692 if (!s || s.byteLength < 2) 11693 throw new Error("Invalid binary message format. Header length missing."); 11694 const n = new DataView(s), i = n.getInt16(0); 11695 if (s.byteLength < i + 2) 11696 throw new Error("Invalid binary message format. Header content missing."); 11697 let o = ""; 11698 for (let c = 0; c < i; c++) 11699 o += String.fromCharCode(n.getInt8(c + 2)); 11700 p = this.parseHeaders(o), s.byteLength > i + 2 && (a = s.slice(2 + i)), r.resolve(new se.ConnectionMessage(e.messageType, a, p, e.id)); 11701 } 11702 } catch (s) { 11703 r.reject(`Error formatting the message. Error: ${s}`); 11704 } 11705 return r.promise; 11706 } 11707 fromConnectionMessage(e) { 11708 const r = new se.Deferred(); 11709 try { 11710 if (e.messageType === se.MessageType.Text) { 11711 const s = `${this.makeHeaders(e)}${jo}${e.textBody ? e.textBody : ""}`; 11712 r.resolve(new se.RawWebsocketMessage(se.MessageType.Text, s, e.id)); 11713 } else if (e.messageType === se.MessageType.Binary) { 11714 const s = this.makeHeaders(e), p = e.binaryBody, a = this.stringToArrayBuffer(s), n = new Int8Array(a), i = n.byteLength, o = new Int8Array(2 + i + (p ? p.byteLength : 0)); 11715 if (o[0] = i >> 8 & 255, o[1] = i & 255, o.set(n, 2), p) { 11716 const u = new Int8Array(p); 11717 o.set(u, 2 + i); 11718 } 11719 const c = o.buffer; 11720 r.resolve(new se.RawWebsocketMessage(se.MessageType.Binary, c, e.id)); 11721 } 11722 } catch (s) { 11723 r.reject(`Error formatting the message. ${s}`); 11724 } 11725 return r.promise; 11726 } 11727 makeHeaders(e) { 11728 let r = ""; 11729 if (e.headers) 11730 for (const s in e.headers) 11731 s && (r += `${s}: ${e.headers[s]}${jo}`); 11732 return r; 11733 } 11734 parseHeaders(e) { 11735 const r = {}; 11736 if (e) { 11737 const s = e.match(/[^\r\n]+/g); 11738 if (r) { 11739 for (const p of s) 11740 if (p) { 11741 const a = p.indexOf(":"), n = a > 0 ? p.substr(0, a).trim().toLowerCase() : p, i = a > 0 && p.length > a + 1 ? p.substr(a + 1).trim() : ""; 11742 r[n] = i; 11743 } 11744 } 11745 } 11746 return r; 11747 } 11748 stringToArrayBuffer(e) { 11749 const r = new ArrayBuffer(e.length), s = new DataView(r); 11750 for (let p = 0; p < e.length; p++) 11751 s.setUint8(p, e.charCodeAt(p)); 11752 return r; 11753 } 11754} 11755xi.WebsocketMessageFormatter = tl; 11756var $t = {}, Lo; 11757function rl() { 11758 if (Lo) return $t; 11759 Lo = 1, Object.defineProperty($t, "__esModule", { value: !0 }), $t.SpeechConnectionFactory = void 0; 11760 const t = re(), e = A(), r = R(), s = Se(), p = A(), a = Y, n = pe, i = ae; 11761 let o = class extends s.ConnectionFactoryBase { 11762 constructor() { 11763 super(...arguments), this.interactiveRelativeUri = "/speech/recognition/interactive/cognitiveservices/v1", this.conversationRelativeUri = "/speech/recognition/conversation/cognitiveservices/v1", this.dictationRelativeUri = "/speech/recognition/dictation/cognitiveservices/v1", this.universalUri = "/stt/speech/universal/v"; 11764 } 11765 async create(u, h, d) { 11766 let v = u.parameters.getProperty(r.PropertyId.SpeechServiceConnection_Endpoint, void 0); 11767 const f = u.parameters.getProperty(r.PropertyId.SpeechServiceConnection_Region, void 0), m = s.ConnectionFactoryBase.getHostSuffix(f), S = u.parameters.getProperty(r.PropertyId.SpeechServiceConnection_Host, "wss://" + f + ".stt.speech" + m), l = {}, g = u.parameters.getProperty(r.PropertyId.SpeechServiceConnection_EndpointId, void 0), C = u.parameters.getProperty(r.PropertyId.SpeechServiceConnection_RecoLanguage, void 0); 11768 if (g ? (!v || v.search(n.QueryParameterNames.CustomSpeechDeploymentId) === -1) && (l[n.QueryParameterNames.CustomSpeechDeploymentId] = g) : C && (!v || v.search(n.QueryParameterNames.Language) === -1) && (l[n.QueryParameterNames.Language] = C), (!v || v.search(n.QueryParameterNames.Format) === -1) && (l[n.QueryParameterNames.Format] = u.parameters.getProperty(e.OutputFormatPropertyName, r.OutputFormat[r.OutputFormat.Simple]).toLowerCase()), u.autoDetectSourceLanguages !== void 0 && (l[n.QueryParameterNames.EnableLanguageId] = "true"), this.setCommonUrlParams(u, l, v), v) { 11769 const E = new URL(v), z = E.pathname; 11770 (z === "" || z === "/") && (E.pathname = this.universalUri + u.recognitionEndpointVersion, v = await s.ConnectionFactoryBase.getRedirectUrlFromEndpoint(E.toString())); 11771 } 11772 if (!v) 11773 switch (u.recognitionMode) { 11774 case i.RecognitionMode.Conversation: 11775 u.parameters.getProperty(e.ForceDictationPropertyName, "false") === "true" ? v = S + this.dictationRelativeUri : u.recognitionEndpointVersion !== void 0 && parseInt(u.recognitionEndpointVersion, 10) > 1 ? v = `${S}${this.universalUri}${u.recognitionEndpointVersion}` : v = S + this.conversationRelativeUri; 11776 break; 11777 case i.RecognitionMode.Dictation: 11778 v = S + this.dictationRelativeUri; 11779 break; 11780 default: 11781 u.recognitionEndpointVersion !== void 0 && parseInt(u.recognitionEndpointVersion, 10) > 1 ? v = `${S}${this.universalUri}${u.recognitionEndpointVersion}` : v = S + this.interactiveRelativeUri; 11782 break; 11783 } 11784 const y = {}; 11785 h.token !== void 0 && h.token !== "" && (y[h.headerName] = h.token), y[a.HeaderNames.ConnectionId] = d, y.c
11785onnectionId = d; 11786 const P = u.parameters.getProperty("SPEECH-EnableWebsocketCompression", "false") === "true", T = new t.WebsocketConnection(v, l, y, new p.WebsocketMessageFormatter(), t.ProxyInfo.fromRecognizerConfig(u), P, d), _ = T.uri; 11787 return u.parameters.setProperty(r.PropertyId.SpeechServiceConnection_Url, _), T; 11788 } 11789 }; 11790 return $t.SpeechConnectionFactory = o, $t; 11791} 11792var er = {}, Bo; 11793function il() { 11794 if (Bo) return er; 11795 Bo = 1, Object.defineProperty(er, "__esModule", { value: !0 }), er.ConversationTranscriberConnectionFactory = void 0; 11796 const t = re(), e = R(), r = A(), s = Se(), p = A(), a = Y, n = pe; 11797 let i = class extends s.ConnectionFactoryBase { 11798 constructor() { 11799 super(...arguments), this.universalUri = "/stt/speech/universal/v2", this.conversationRelativeUriV1 = "/speech/recognition/conversation/cognitiveservices/v1"; 11800 } 11801 async create(c, u, h) { 11802 let d = c.parameters.getProperty(e.PropertyId.SpeechServiceConnection_Endpoint, void 0); 11803 const v = c.parameters.getProperty(e.PropertyId.SpeechServiceConnection_Region, void 0), f = s.ConnectionFactoryBase.getHostSuffix(v), m = c.parameters.getProperty(e.PropertyId.SpeechServiceConnection_Host, "wss://" + v + ".stt.speech" + f), S = {}, l = c.parameters.getProperty(e.PropertyId.SpeechServiceConnection_EndpointId, void 0), g = c.parameters.getProperty(e.PropertyId.SpeechServiceConnection_RecoLanguage, void 0); 11804 if (l ? (!d || d.search(n.QueryParameterNames.CustomSpeechDeploymentId) === -1) && (S[n.QueryParameterNames.CustomSpeechDeploymentId] = l) : g && (!d || d.search(n.QueryParameterNames.Language) === -1) && (S[n.QueryParameterNames.Language] = g), c.autoDetectSourceLanguages !== void 0 && (S[n.QueryParameterNames.EnableLanguageId] = "true"), c.parameters.getProperty(e.PropertyId.SpeechServiceConnection_RecognitionEndpointVersion, void 0) === "1") 11805 d = `${m}${this.universalUri}`; 11806 else { 11807 if (this.setV2UrlParams(c, S, d), d) { 11808 const E = new URL(d), z = E.pathname; 11809 (z === "" || z === "/") && (E.pathname = this.universalUri, d = await s.ConnectionFactoryBase.getRedirectUrlFromEndpoint(E.toString())); 11810 } 11811 d || (d = `${m}${this.conversationRelativeUriV1}`); 11812 } 11813 const y = {}; 11814 u.token !== void 0 && u.token !== "" && (y[u.headerName] = u.token), y[a.HeaderNames.ConnectionId] = h; 11815 const P = c.parameters.getProperty("SPEECH-EnableWebsocketCompression", "false") === "true", T = new t.WebsocketConnection(d, S, y, new p.WebsocketMessageFormatter(), t.ProxyInfo.fromRecognizerConfig(c), P, h), _ = T.uri; 11816 return c.parameters.setProperty(e.PropertyId.SpeechServiceConnection_Url, _), T; 11817 } 11818 setV2UrlParams(c, u, h) { 11819 (/* @__PURE__ */ new Map([ 11820 [e.PropertyId.Speech_SegmentationSilenceTimeoutMs, n.QueryParameterNames.SegmentationSilenceTimeoutMs], 11821 [e.PropertyId.SpeechServiceConnection_EnableAudioLogging, n.QueryParameterNames.EnableAudioLogging], 11822 [e.PropertyId.SpeechServiceConnection_EndSilenceTimeoutMs, n.QueryParameterNames.EndSilenceTimeoutMs], 11823 [e.PropertyId.SpeechServiceConnection_InitialSilenceTimeoutMs, n.QueryParameterNames.InitialSilenceTimeoutMs], 11824 [e.PropertyId.SpeechServiceResponse_PostProcessingOption, n.QueryParameterNames.Postprocessing], 11825 [e.PropertyId.SpeechServiceResponse_ProfanityOption, n.QueryParameterNames.Profanity], 11826 [e.PropertyId.SpeechServiceResponse_StablePartialResultThreshold, n.QueryParameterNames.StableIntermediateThreshold] 11827 ])).forEach((f, m) => { 11828 this.setUrlParameter(m, f, c, u, h); 11829 }); 11830 const v = JSON.parse(c.parameters.getProperty(r.ServicePropertiesPropertyName, "{}")); 11831 Object.keys(v).forEach((f) => { 11832 u[f] = v[f]; 11833 }); 11834 } 11835 }; 11836 return er.ConversationTranscriberConnectionFactory = i, er; 11837} 11838var tr = {}, qo; 11839function nl() { 11840 if (qo) return tr; 11841 qo = 1, Object.defineProperty(tr, "__esModule", { value: !0 }), tr.TranscriberConnectionFactory = void 0; 11842 const t = re(), e = R(), r = Se(), s = A(), p = Y, a = pe; 11843 let n = class extends r.ConnectionFactoryBase { 11844 constructor() { 11845 super(...arguments), this.multiaudioRelativeUri = "/speech/recognition/multiaudio"; 11846 } 11847 create(o, c, u) { 11848 let h = o.parameters.getProperty(e.PropertyId.SpeechServiceConnection_Endpoint, void 0); 11849 const d = o.parameters.getProperty(e.PropertyId.SpeechServiceConnection_Region, "centralus"), v = r.ConnectionFactoryBase.getHostSuffix(d), f = "
11849wss://transcribe." + d + ".cts.speech" + v + this.multiaudioRelativeUri, m = o.parameters.getProperty(e.PropertyId.SpeechServiceConnection_Host, f), S = {}; 11850 this.setQueryParams(S, o, h), h || (h = m); 11851 const l = {}; 11852 c.token !== void 0 && c.token !== "" && (l[c.headerName] = c.token), l[p.HeaderNames.ConnectionId] = u, o.parameters.setProperty(e.PropertyId.SpeechServiceConnection_Url, h); 11853 const g = o.parameters.getProperty("SPEECH-EnableWebsocketCompression", "false") === "true"; 11854 return Promise.resolve(new t.WebsocketConnection(h, S, l, new s.WebsocketMessageFormatter(), t.ProxyInfo.fromRecognizerConfig(o), g, u)); 11855 } 11856 setQueryParams(o, c, u) { 11857 const h = c.parameters.getProperty(e.PropertyId.SpeechServiceConnection_EndpointId, void 0), d = c.parameters.getProperty(e.PropertyId.SpeechServiceConnection_RecoLanguage, void 0); 11858 h && !(a.QueryParameterNames.CustomSpeechDeploymentId in o) && (o[a.QueryParameterNames.CustomSpeechDeploymentId] = h), d && !(a.QueryParameterNames.Language in o) && (o[a.QueryParameterNames.Language] = d); 11859 const v = c.parameters.getProperty(e.PropertyId.SpeechServiceResponse_RequestWordLevelTimestamps, "false").toLowerCase() === "true", f = c.parameters.getProperty(s.OutputFormatPropertyName, e.OutputFormat[e.OutputFormat.Simple]) !== e.OutputFormat[e.OutputFormat.Simple]; 11860 (v || f) && (o[a.QueryParameterNames.Format] = e.OutputFormat[e.OutputFormat.Detailed].toLowerCase()), this.setCommonUrlParams(c, o, u); 11861 } 11862 }; 11863 return tr.TranscriberConnectionFactory = n, tr; 11864} 11865var rr = {}, Fo; 11866function sl() { 11867 if (Fo) return rr; 11868 Fo = 1, Object.defineProperty(rr, "__esModule", { value: !0 }), rr.TranslationConnectionFactory = void 0; 11869 const t = re(), e = Lr, r = R(), s = Se(), p = A(), a = Y, n = pe, i = ae; 11870 let o = class extends s.ConnectionFactoryBase { 11871 constructor() { 11872 super(...arguments), this.universalUri = "/stt/speech/universal/v2", this.translationV1Uri = "/speech/translation/cognitiveservices/v1"; 11873 } 11874 async create(u, h, d) { 11875 let v = this.getEndpointUrl(u); 11876 const f = {}; 11877 if (this.setQueryParams(f, u, v), v) { 11878 const g = new URL(v), C = g.pathname; 11879 (C === "" || C === "/") && (g.pathname = this.universalUri, v = await s.ConnectionFactoryBase.getRedirectUrlFromEndpoint(g.toString())); 11880 } 11881 const m = {}; 11882 h.token !== void 0 && h.token !== "" && (m[h.headerName] = h.token), m[a.HeaderNames.ConnectionId] = d, u.parameters.setProperty(r.PropertyId.SpeechServiceConnection_Url, v); 11883 const S = u.parameters.getProperty("SPEECH-EnableWebsocketCompression", "false") === "true"; 11884 return new t.WebsocketConnection(v, f, m, new p.WebsocketMessageFormatter(), t.ProxyInfo.fromRecognizerConfig(u), S, d); 11885 } 11886 getEndpointUrl(u, h) { 11887 const d = u.parameters.getProperty(r.PropertyId.SpeechServiceConnection_Region), v = s.ConnectionFactoryBase.getHostSuffix(d); 11888 let f = u.parameters.getProperty(r.PropertyId.SpeechServiceConnection_Endpoint, void 0); 11889 return f ? h === !0 ? f : e.StringUtils.formatString(f, { region: d }) : (u.parameters.getProperty("SPEECH-ForceV1Endpoint", "false") === "true" ? f = u.parameters.getProperty(r.PropertyId.SpeechServiceConnection_Host, "wss://{region}.s2s.speech" + v) + this.translationV1Uri : f = u.parameters.getProperty(r.PropertyId.SpeechServiceConnection_Host, "wss://{region}.stt.speech" + v) + this.universalUri, h === !0 ? f : e.StringUtils.formatString(f, { region: d })); 11890 } 11891 setQueryParams(u, h, d) { 11892 u.from = h.parameters.getProperty(r.PropertyId.SpeechServiceConnection_RecoLanguage), u.to = h.parameters.getProperty(r.PropertyId.SpeechServiceConnection_TranslationToLanguages), u.scenario = h.recognitionMode === i.RecognitionMode.Interactive ? "interactive" : h.recognitionMode === i.RecognitionMode.Conversation ? "conversation" : "", this.setCommonUrlParams(h, u, d), this.setUrlParameter(r.PropertyId.SpeechServiceResponse_TranslationRequestStablePartialResult, n.QueryParameterNames.StableTranslation, h, u, d); 11893 const v = h.parameters.getProperty(r.PropertyId.SpeechServiceConnection_TranslationVoice, void 0); 11894 v !== void 0 && (u.voice = v, u.features = "requireVoice"); 11895 } 11896 }; 11897 return rr.TranslationConnectionFactory = o, rr; 11898} 11899var ir = {}, Uo; 11900function ol() { 11901 if (Uo) return ir; 11902 Uo = 1, Object.defineProperty(ir, "__esModule", { value: !0 }), ir.EnumTranslation = void 0; 11903 const t = R(), e = A(); 11904 let r = class { 11905 static implTranslateRecognitionResult(p, a = !1) { 11906 let n = t.ResultReason.Canceled; 11907 switch (p) { 11908 case e.RecognitionStatus.Success: 11909 n = t.ResultReason.RecognizedSpeech; 11910 break; 11911 case e.RecognitionStatus.EndOfDictation: 11912 n = a ? t.ResultReason.RecognizedSpeech : t.ResultReason.NoMatch; 11913 break; 11914 case e.RecognitionStatus.NoMatch: 11915 case e.RecognitionStatus.InitialSilenceTimeout: 11916 case e.RecognitionStatus.BabbleTimeout: 11917 n = t.ResultReason.NoMatch; 11918 break; 11919 case e.RecognitionStatus.Error: 11920 case e.RecognitionStatus.BadRequest: 11921 case e.RecognitionStatus.Forbidden: 11922 default: 11923 n = t.ResultReason.Canceled; 11924 break; 11925 } 11926 return n; 11927 } 11928 static implTranslateCancelResult(p) { 11929 let a = t.CancellationReason.EndOfStream; 11930 switch (p) { 11931 case e.RecognitionStatus.Success: 11932 case e.RecognitionStatus.EndOfDictation: 11933 case e.RecognitionStatus.NoMatch: 11934 a = t.CancellationReason.EndOfStream; 11935 break; 11936 case e.RecognitionStatus.InitialSilenceTimeout: 11937 case e.RecognitionStatus.BabbleTimeout: 11938 case e.RecognitionStatus.Error: 11939 case e.RecognitionStatus.BadRequest: 11940 case e.RecognitionStatus.Forbidden: 11941 default: 11942 a = t.CancellationReason.Error; 11943 break; 11944 } 11945 return a; 11946 } 11947 static implTranslateCancelErrorCode(p) { 11948 let a = t.CancellationErrorCode.NoError; 11949 switch (p) { 11950 case e.RecognitionStatus.Error: 11951 a = t.CancellationErrorCode.ServiceError; 11952 break; 11953 case e.RecognitionStatus.TooManyRequests: 11954 a = t.CancellationErrorCode.TooManyRequests; 11955 break; 11956 case e.RecognitionStatus.BadRequest: 11957 a = t.CancellationErrorCode.BadRequestParameters; 11958 break; 11959 case e.RecognitionStatus.Forbidden: 11960 a = t.CancellationErrorCode.Forbidden; 11961 break; 11962 default: 11963 a = t.CancellationErrorCode.NoError; 11964 break; 11965 } 11966 return a; 11967 } 11968 static implTranslateErrorDetails(p) { 11969 let a = "The speech service encountered an internal error and could not continue."; 11970 switch (p) { 11971 case t.CancellationErrorCode.Forbidden: 11972 a = "The recognizer is using a free subscription that ran out of quota."; 11973 break; 11974 case t.CancellationErrorCode.BadRequestParameters: 11975 a = "Invalid parameter or unsupported audio format in the request."; 11976 break; 11977 case t.CancellationErrorCode.TooManyRequests: 11978 a = "The number of parallel requests exceeded the number of allowed concurrent transcriptions."; 11979 break; 11980 } 11981 return a; 11982 } 11983 }; 11984 return ir.EnumTranslation = r, ir; 11985} 11986var Lc = {}; 11987(function(t) { 11988 Object.defineProperty(t, "__esModule", { value: !0 }), t.RecognitionStatus = t.SynthesisStatus = void 0, function(e) { 11989 e[e.Success = 0] = "Success", e[e.SynthesisEnd = 1] = "SynthesisEnd", e[e.Error = 2] = "Error"; 11990 }(t.SynthesisStatus || (t.SynthesisStatus = {})), function(e) {
11991 e[e.Success = 0] = "Success", e[e.NoMatch = 1] = "NoMatch", e[e.InitialSilenceTimeout = 2] = "InitialSilenceTimeout", e[e.BabbleTimeout = 3] = "BabbleTimeout", e[e.Error = 4] = "Error", e[e.EndOfDictation = 5] = "EndOfDictation", e[e.TooManyRequests = 6] = "TooManyRequests", e[e.BadRequest = 7] = "BadRequest", e[e.Forbidden = 8] = "Forbidden"; 11992 }(t.RecognitionStatus || (t.RecognitionStatus = {})); 11993})(Lc); 11994var nr = {}, xo; 11995function al() { 11996 if (xo) return nr; 11997 xo = 1, Object.defineProperty(nr, "__esModule", { value: !0 }), nr.TranslationSynthesisEnd = void 0; 11998 const t = A(); 11999 let e = class Bc { 12000 constructor(s) { 12001 this.privSynthesisEnd = JSON.parse(s), this.privSynthesisEnd.SynthesisStatus && (this.privSynthesisEnd.SynthesisStatus = t.SynthesisStatus[this.privSynthesisEnd.SynthesisStatus]), this.privSynthesisEnd.Status && (this.privSynthesisEnd.SynthesisStatus = t.SynthesisStatus[this.privSynthesisEnd.Status]); 12002 } 12003 static fromJSON(s) { 12004 return new Bc(s); 12005 } 12006 get SynthesisStatus() { 12007 return this.privSynthesisEnd.SynthesisStatus; 12008 } 12009 get FailureReason() { 12010 return this.privSynthesisEnd.FailureReason; 12011 } 12012 }; 12013 return nr.TranslationSynthesisEnd = e, nr; 12014} 12015var Wi = {}; 12016Object.defineProperty(Wi, "__esModule", { value: !0 }); 12017Wi.TranslationHypothesis = void 0; 12018const cl = O, Wo = hi; 12019class Kr { 12020 constructor(e, r) { 12021 this.privTranslationHypothesis = e, this.privTranslationHypothesis.Off
12021set += r, this.privTranslationHypothesis.Translation.TranslationStatus = this.mapTranslationStatus(this.privTranslationHypothesis.Translation.TranslationStatus); 12022 } 12023 static fromJSON(e, r) { 12024 return new Kr(JSON.parse(e), r); 12025 } 12026 static fromTranslationResponse(e, r) { 12027 cl.Contracts.throwIfNullOrUndefined(e, "translationHypothesis"); 12028 const s = e.SpeechHypothesis; 12029 return e.SpeechHypothesis = void 0, s.Translation = e, new Kr(s, r); 12030 } 12031 get Duration() { 12032 return this.privTranslationHypothesis.Duration; 12033 } 12034 get Offset() { 12035 return this.privTranslationHypothesis.Offset; 12036 } 12037 get Text() { 12038 return this.privTranslationHypothesis.Text; 12039 } 12040 get Translation() { 12041 return this.privTranslationHypothesis.Translation; 12042 } 12043 get Language() { 12044 var e; 12045 return (e = this.privTranslationHypothesis.PrimaryLanguage) == null ? void 0 : e.Language; 12046 } 12047 asJson() { 12048 const e = { ...this.privTranslationHypothesis }; 12049 return e.Translation !== void 0 ? JSON.stringify({ 12050 ...e, 12051 TranslationStatus: Wo.TranslationStatus[e.Translation.TranslationStatus] 12052 }) : JSON.stringify(e); 12053 } 12054 mapTranslationStatus(e) { 12055 if (typeof e == "string") 12056 return Wo.TranslationStatus[e]; 12057 if (typeof e == "number") 12058 return e; 12059 } 12060} 12061Wi.TranslationHypothesis = Kr; 12062var sr = {}, Ho; 12063function pl() { 12064 if (Ho) return sr; 12065 Ho = 1, Object.defineProperty(sr, "__esModule", { value: !0 }), sr.TranslationPhrase = void 0; 12066 const t = O, e = A(), r = hi; 12067 let s = class bn { 12068 constructor(a, n) { 12069 this.privTranslationPhrase = a, this.privTranslationPhrase.Offset += n, this.privTranslationPhrase.RecognitionStatus = this.mapRecognitionStatus(this.privTranslationPhrase.RecognitionStatus), this.privTranslationPhrase.Translation !== void 0 && (this.privTranslationPhrase.Translation.TranslationStatus = this.mapTranslationStatus(this.privTranslationPhrase.Translation.TranslationStatus)); 12070 } 12071 static fromJSON(a, n) { 12072 return new bn(JSON.parse(a), n); 12073 } 12074 static fromTranslationResponse(a, n) { 12075 t.Contracts.throwIfNullOrUndefined(a, "translationResponse"); 12076 const i = a.SpeechPhrase; 12077 return a.SpeechPhrase = void 0, i.Translation = a, i.Text = i.DisplayText, new bn(i, n); 12078 } 12079 get RecognitionStatus() { 12080 return this.privTranslationPhrase.RecognitionStatus; 12081 } 12082 get Offset() { 12083 return this.privTranslationPhrase.Offset; 12084 } 12085 get Duration() { 12086 return this.privTranslationPhrase.Duration; 12087 } 12088 get Text() { 12089 return this.privTranslationPhrase.Text; 12090 } 12091 get Language() { 12092 var a; 12093 return (a = this.privTranslationPhrase.PrimaryLanguage) == null ? void 0 : a.Language; 12094 } 12095 get Confidence() { 12096 var a; 12097 return (a = this.privTranslationPhrase.PrimaryLanguage) == null ? void 0 : a.Confidence; 12098 } 12099 get Translation() { 12100 return this.privTranslationPhrase.Translation; 12101 } 12102 asJson() { 12103 const a = { ...this.privTranslationPhrase }, n = { 12104 ...a, 12105 RecognitionStatus: e.RecognitionStatus[a.RecognitionStatus] 12106 }; 12107 return a.Translation && (n.Translation = { 12108 ...a.Translation, 12109 TranslationStatus: r.TranslationStatus[a.Translation.TranslationStatus] 12110 }), JSON.stringify(n); 12111 } 12112 mapRecognitionStatus(a) { 12113 if (typeof a == "string") 12114 return e.RecognitionStatus[a]; 12115 if (typeof a == "number") 12116 return a; 12117 } 12118 mapTranslationStatus(a) { 12119 if (typeof a == "string") 12120 return r.TranslationStatus[a]; 12121 if (typeof a == "number") 12122 return a; 12123 } 12124 }; 12125 return sr.TranslationPhrase = s, sr; 12126} 12127var or = {}, Ko; 12128function ul() { 12129 if (Ko) return or; 12130 Ko = 1, Object.defineProperty(or, "__esModule", { value: !0 }), or.TranslationServiceRecognizer = void 0; 12131 const t = I(), e = R(), r = A(); 12132 let s = class extends r.ConversationServiceRecognizer { 12133 constructor(a, n, i, o, c) { 12134 super(a, n, i, o, c), this.privTranslationRecognizer = c, this.connectionEvents.attach((u) => { 12135 u.name === "ConnectionEstablishedEvent" && this.privTranslationRecognizer.onConnection(); 12136 }); 12137 } 12138 async processTypeSpecificMessages(a) { 12139 const n = new e.PropertyCollection(); 12140 let i = await this.processSpeechMessages(a); 12141 if (i) 12142 return !0; 12143 const o = async (u) => { 12144 n.setProperty(e.PropertyId.SpeechServiceResponse_JsonResult, u.asJson()); 12145 const h = this.privRequestSession.onPhraseRecognized(u.Offset + u.Duration); 12146 if (h > 0 && n.setProperty(e.PropertyId.SpeechServiceResponse_RecognitionLatencyMs, h.toString()), u.RecognitionStatus === r.RecognitionStatus.Success) { 12147 const d = this.fireEventForResult(u, n); 12148 if (this.privTranslationRecognizer.recognized) 12149 try { 12150 this.privTranslationRecognizer.recognized(this.privTranslationRecognizer, d); 12151 } catch { 12152 } 12153 if (this.privSuccessCallback) { 12154 try { 12155 this.privSuccessCallback(d.result); 12156 } catch (v) { 12157 this.privErrorCallback && this.privErrorCallback(v); 12158 } 12159 this.privSuccessCallback = void 0, this.privErrorCallback = void 0; 12160 } 12161 } else { 12162 const d = r.EnumTranslation.implTranslateRecognitionResult(u.RecognitionStatus), v = new e.TranslationRecognitionResult(void 0, this.privRequestSession.requestId, d, u.Text, u.Duration, u.Offset, u.Language, u.Confidence, void 0, u.asJson(), n); 12163 if (d === e.ResultReason.Canceled) { 12164 const f = r.EnumTranslation.implTranslateCancelResult(u.RecognitionStatus), m = r.EnumTranslation.implTranslateCancelErrorCode(u.RecognitionStatus); 12165 await this.cancelRecognitionLocal(f, m, r.EnumTranslation.implTranslateErrorDetails(m)); 12166 } else if (u.RecognitionStatus !== r.RecognitionStatus.EndOfDictation) { 12167 const f = new e.TranslationRecognitionEventArgs(v, v.offset, this.privRequestSession.sessionId); 12168 if (this.privTranslationRecognizer.recognized) 12169 try { 12170 this.privTranslationRecognizer.recognized(this.privTranslationRecognizer, f); 12171 } catch { 12172 } 12173 if (this.privSuccessCallback) { 12174 try { 12175 this.privSuccessCallback(v); 12176 } catch (m) { 12177 this.privErrorCallback && this.privErrorCallback(m); 12178 } 12179 this.privSuccessCallback = void 0, this.privErrorCallback = void 0; 12180 } 12181 } 12182 i = !0; 12183 } 12184 }, c = (u) => { 12185 n.setProperty(e.PropertyId.SpeechServiceResponse_JsonResult, u.asJson()); 12186 const h = this.privRequestSession.onHypothesis(u.Offset); 12187 h > 0 && n.setProperty(e.PropertyId.SpeechServiceResponse_RecognitionLatencyMs, h.toString()); 12188 const d = this.fireEventForResult(u, n); 12189 if (this.privTranslationRecognizer.recognizing) 12190 try { 12191 this.privTranslationRecognizer.recognizing(this.privTranslationRecognizer, d); 12192 } catch { 12193 } 12194 i = !0; 12195 }; 12196 switch (a.messageType === t.MessageType.Text && n.setProperty(e.PropertyId.SpeechServiceResponse_JsonResult, a.textBody), a.path.toLowerCase()) { 12197 case "translation.hypothesis": 12198 c(r.TranslationHypothesis.fromJSON(a.textBody, this.privRequestSession.currentTurnAudioOffset)); 12199 break; 12200 case "translation.response": 12201 const u = JSON.parse(a.textBody); 12202 if (u.SpeechPhrase) 12203 await o(r.TranslationPhrase.fromTranslationResponse(u, this.privRequestSession.currentTurnAudioOffset)); 12204 else { 12205 const d = JSON.parse(a.textBody); 12206 d.SpeechHypothesis && c(r.TranslationHypothesis.fromTranslationResponse(d, this.privRequestSession.currentTurnAudioOffset)); 12207 } 12208 break; 12209 case "translation.phrase": 12210 await o(r.TranslationPhrase.fromJSON(a.textBody, this.privRequestSession.currentTurnAudioOffset)); 12211 break; 12212 case "translation.synthesis": 12213 case "audio": 12214 this.sendSynthesisAudio(a.binaryBody, this.privRequestSession.sessionId), i = !0; 12215 break; 12216 case "audio.end": 12217 case "translation.synthesis.end": 12218 const h = r.TranslationSynthesisEnd.fromJSON(a.textBody); 12219 switch (h.SynthesisStatus) { 12220 case r.SynthesisStatus.Error: 12221 if (this.privTranslationRecognizer.synthesizing) { 12222 const d = new e.TranslationSynthesisResult(e.ResultReason.Canceled, void 0), v = new e.TranslationSynthesisEventArgs(d, this.privRequestSession.sessionId); 12223 try { 12224 this.privTranslationRecognizer.synthesizing(this.privTranslationRecognizer, v); 12225 } catch { 12226 } 12227 } 12228 if (this.privTranslationRecognizer.canceled) { 12229 const d = new e.TranslationRecognitionCanceledEventArgs(this.privRequestSession.sessionId, e.CancellationReason.Error, h.FailureReason, e.CancellationErrorCode.ServiceError, null); 12230 try { 12231 this.privTranslationRecognizer.canceled(this.privTranslationRecognizer, d); 12232 } catch { 12233 } 12234 } 12235 break; 12236 case r.SynthesisStatus.Success: 12237 this.sendSynthesisAudio(void 0, this.privRequestSession.sessionId); 12238 break; 12239 } 12240 i = !0; 12241 break; 12242 } 12243 return i; 12244 } 12245 // Cancels recognition. 12246 cancelRecognition(a, n, i, o, c) { 12247 const u = new e.PropertyCollection(); 12248 if (u.setProperty(r.CancellationErrorCodePropertyName, e.CancellationErrorCode[o]), this.privTranslationRecognizer.canceled) { 12249 const h = new e.TranslationRecognitionCanceledEventArgs(a, i, c, o, void 0); 12250 try { 12251 this.privTranslationRecognizer.canceled(this.privTranslationRecognizer, h); 12252 } catch { 12253 } 12254 } 12255 if (this.privSuccessCallback) { 12256 const h = new e.TranslationRecognitionResult( 12257 void 0, 12258 // Translations 12259 n, 12260 e.ResultReason.Canceled, 12261 void 0, 12262 // Text 12263 void 0, 12264 // Druation 12265 void 0, 12266 // Offset 12267 void 0, 12268 // Language 12269 void 0, 12270 // LanguageDetectionConfidence 12271 c, 12272 void 0, 12273 // Json 12274 u 12275 ); 12276 try { 12277 this.privSuccessCallback(h), this.privSuccessCallback = void 0; 12278 } catch { 12279 } 12280 } 12281 } 12282 handleRecognizingCallback(a, n, i) {
12283 try { 12284 const o = new e.TranslationRecognitionEventArgs(e.TranslationRecognitionResult.fromSpeechRecognitionResult(a), n, i); 12285 this.privTranslationRecognizer.recognizing(this.privTranslationRecognizer, o); 12286 } catch { 12287 } 12288 } 12289 handleRecognizedCallback(a, n, i) { 12290 try { 12291 const o = new e.TranslationRecognitionEventArgs(e.TranslationRecognitionResult.fromSpeechRecognitionResult(a), n, i); 12292 this.privTranslationRecognizer.recognized(this.privTranslationRecognizer, o); 12293 } catch { 12294 } 12295 } 12296 fireEventForResult(a, n) { 12297 let i; 12298 if (a.Translation.Translations !== void 0) { 12299 i = new e.Translations(); 12300 for (const v of a.Translation.Translations) 12301 i.set(v.Language, v.Text || v.DisplayText); 12302 } 12303 let o, c; 12304 a instanceof r.TranslationPhrase ? (a.Translation && a.Translation.TranslationStatus === t.TranslationStatus.Success ? o = e.ResultReason.TranslatedSpeech : o = e.ResultReason.RecognizedSpeech, c = a.Confidence) : o = e.ResultReason.TranslatingSpeech; 12305 const u = a.Language, h = new e.TranslationRecognitionResult(i, this.privRequestSession.requestId, o, a.Text, a.Duration, a.Offset, u, c, a.Translation.FailureReason, a.asJson(), n); 12306 return new e.TranslationRecognitionEventArgs(h, a.Offset, this.privRequestSession.sessionId); 12307 } 12308 sendSynthesisAudio(a, n) { 12309 const i = a === void 0 ? e.ResultReason.SynthesizingAudioCompleted : e.ResultReason.SynthesizingAudio, o = new e.TranslationSynthesisResult(i, a), c = new e.TranslationSynthesisEventArgs(o, n); 12310 if (this.privTranslationRecognizer.synthesizing) 12311 try { 12312 this.privTranslationRecognizer.synthesizing(this.privTranslationRecognizer, c); 12313 } catch { 12314 } 12315 } 12316 }; 12317 return or.TranslationServiceRecognizer = s, or; 12318} 12319var Hi = {}; 12320Object.defineProperty(Hi, "__esModule", { value: !0 }); 12321Hi.SpeechDetected = void 0; 12322class Gn { 12323 constructor(e, r) { 12324 this.privSpeechStartDetected = JSON.parse(e), this.privSpeechStartDetected.Offset += r; 12325 } 12326 static fromJSON(e, r) { 12327 return new Gn(e, r); 12328 } 12329 get Offset() { 12330 return this.privSpeechStartDetected.Offset; 12331 } 12332} 12333Hi.SpeechDetected = Gn; 12334var Ki = {}; 12335Object.defineProperty(Ki, "__esModule", { value: !0 }); 12336Ki.SpeechHypothesis = void 0; 12337class Qn { 12338 constructor(e, r) { 12339 this.privSpeechHypothesis = JSON.parse(e), this.updateOffset(r); 12340 } 12341 static fromJSON(e, r) { 12342 return new Qn(e, r); 12343 } 12344 updateOffset(e) {
12345 this.privSpeechHypothesis.Offset += e; 12346 } 12347 asJson() { 12348 return JSON.stringify(this.privSpeechHypothesis); 12349 } 12350 get Text() { 12351 return this.privSpeechHypothesis.Text; 12352 } 12353 get Offset() { 12354 return this.privSpeechHypothesis.Offset; 12355 } 12356 get Duration() { 12357 return this.privSpeechHypothesis.Duration; 12358 } 12359 get Language() { 12360 return this.privSpeechHypothesis.PrimaryLanguage === void 0 ? void 0 : this.privSpeechHypothesis.PrimaryLanguage.Language; 12361 } 12362 get LanguageDetectionConfidence() { 12363 return this.privSpeechHypothesis.PrimaryLanguage === void 0 ? void 0 : this.privSpeechHypothesis.PrimaryLanguage.Confidence; 12364 } 12365 get SpeakerId() { 12366 return this.privSpeechHypothesis.SpeakerId; 12367 } 12368} 12369Ki.SpeechHypothesis = Qn; 12370var Ji = {}; 12371Object.defineProperty(Ji, "__esModule", { value: !0 }); 12372Ji.SpeechKeyword = void 0; 12373class Xn { 12374 constructor(e, r) { 12375 this.privSpeechKeyword = JSON.parse(e), this.privSpeechKeyword.Offset += r; 12376 } 12377 static fromJSON(e, r) { 12378 return new Xn(e, r); 12379 } 12380 get Status() { 12381 return this.privSpeechKeyword.Status; 12382 } 12383 get Text() { 12384 return this.privSpeechKeyword.Text; 12385 } 12386 get Offset() { 12387 return this.privSpeechKeyword.Offset; 12388 } 12389 get Duration() { 12390 return this.privSpeechKeyword.Duration; 12391 } 12392 asJson() { 12393 return JSON.stringify(this.privSpeechKeyword); 12394 } 12395} 12396Ji.SpeechKeyword = Xn; 12397var ar = {}, Jo; 12398function hl() { 12399 if (Jo) return ar; 12400 Jo = 1, Object.defineProperty(ar, "__esModule", { value: !0 }), ar.SpeechServiceRecognizer = void 0; 12401 const t = R(), e = A(); 12402 let r = class extends e.ServiceRecognizerBase { 12403 constructor(p, a, n, i, o) { 12404 super(p, a, n, i, o), this.privSpeechRecognizer = o; 12405 } 12406 async processTypeSpecificMessages(p) { 12407 let a; 12408 const n = new t.PropertyCollection(); 12409 let i = !1; 12410 switch (p.path.toLowerCase()) { 12411 case "speech.hypothesis": 12412 case "speech.fragment": 12413 const o = e.SpeechHypothesis.fromJSON(p.textBody, this.privRequestSession.currentTurnAudioOffset); 12414 n.setProperty(t.PropertyId.SpeechServiceResponse_JsonResult, o.asJson()); 12415 const c = this.privRequestSession.onHypothesis(o.Offset); 12416 c > 0 && n.setProperty(t.PropertyId.SpeechServiceResponse_RecognitionLatencyMs, c.toString()), a = new t.SpeechRecognitionResult( 12417 this.privRequestSession.requestId, 12418 t.ResultReason.RecognizingSpeech, 12419 o.Text, 12420 o.Duration, 12421 o.Offset, 12422 o.Language, 12423 o.LanguageDetectionConfidence, 12424 void 0, 12425 // Speaker Id 12426 void 0, 12427 o.asJson(), 12428 n 12429 ); 12430 const u = new t.SpeechRecognitionEventArgs(a, o.Offset, this.privRequestSession.sessionId); 12431 if (this.privSpeechRecognizer.recognizing) 12432 try { 12433 this.privSpeechRecognizer.recognizing(this.privSpeechRecognizer, u); 12434 } catch { 12435 } 12436 i = !0; 12437 break; 12438 case "speech.phrase": 12439 const h = e.SimpleSpeechPhrase.fromJSON(p.textBody, this.privRequestSession.currentTurnAudioOffset); 12440 n.setProperty(t.PropertyId.SpeechServiceResponse_JsonResult, h.asJson()); 12441 const d = e.EnumTranslation.implTranslateRecognitionResult(h.RecognitionStatus, this.privExpectContentAssessmentResponse), v = this.privRequestSession.onPhraseRecognized(h.Offset + h.Duration); 12442 if (v > 0 && n.setProperty(t.PropertyId.SpeechServiceResponse_RecognitionLatencyMs, v.toString()), t.ResultReason.Canceled === d) { 12443 const f = e.EnumTranslation.implTranslateCancelResult(h.RecognitionStatus), m = e.EnumTranslation.implTranslateCancelErrorCode(h.RecognitionStatus); 12444 await this.cancelRecognitionLocal(f, m, e.EnumTranslation.implTranslateErrorDetails(m)); 12445 } else { 12446 if (h.RecognitionStatus === e.RecognitionStatus.EndOfDictation) 12447 break; 12448 if (this.privRecognizerConfig.parameters.getProperty(e.OutputFormatPropertyName) === t.OutputFormat[t.OutputFormat.Simple]) 12449 a = new t.SpeechRecognitionResult( 12450 this.privRequestSession.requestId, 12451 d, 12452 h.DisplayText, 12453 h.Duration, 12454 h.Offset, 12455 h.Language, 12456 h.LanguageDetectionConfidence, 12457 void 0, 12458 // Speaker Id 12459 void 0, 12460 h.asJson(), 12461 n 12462 ); 12463 else { 12464 const m = e.DetailedSpeechPhrase.fromJSON(p.textBody, this.privRequestSession.currentTurnAudioOffset); 12465 n.setProperty(t.PropertyId.SpeechServiceResponse_JsonResult, m.asJson()), a = new t.SpeechRecognitionResult( 12466 this.privRequestSession.requestId, 12467 d, 12468 m.RecognitionStatus === e.RecognitionStatus.Success ? m.NBest[0].Display : "", 12469 m.Duration, 12470 m.Offset, 12471 m.Language, 12472 m.LanguageDetectionConfidence, 12473 void 0, 12474 // Speaker Id 12475 void 0, 12476 m.asJson(), 12477 n 12478 ); 12479 } 12480 const f = new t.SpeechRecognitionEventArgs(a, a.offset, this.privRequestSession.sessionId); 12481 if (this.privSpeechRecognizer.recognized) 12482 try { 12483 this.privSpeechRecognizer.recognized(this.privSpeechRecognizer, f); 12484 } catch { 12485 } 12486 if (this.privSuccessCallback) { 12487 try { 12488 this.privSuccessCallback(a); 12489 } catch (m) { 12490 this.privErrorCallback && this.privErrorCallback(m); 12491 } 12492 this.privSuccessCallback = void 0, this.privErrorCallback = void 0; 12493 } 12494 } 12495 i = !0; 12496 break; 12497 } 12498 return i; 12499 } 12500 // Cancels recognition. 12501 cancelRecognition(p, a, n, i, o) { 12502 const c = new t.PropertyCollection(); 12503 if (c.setProperty(e.CancellationErrorCodePropertyName, t.CancellationErrorCode[i]), this.privSpeechRecognizer.canceled) { 12504 const u = new t.SpeechRecognitionCanceledEventArgs(n, o, i, void 0, p); 12505 try { 12506 this.privSpeechRecognizer.canceled(this.privSpeechRecognizer, u); 12507 } catch { 12508 } 12509 } 12510 if (this.privSuccessCallback) { 12511 const u = new t.SpeechRecognitionResult( 12512 a, 12513 t.ResultReason.Canceled, 12514 void 0, 12515 // Text 12516 void 0, 12517 // Duration 12518 void 0, 12519 // Offset 12520 void 0, 12521 // Language 12522 void 0, 12523 // Language Detection Confidence 12524 void 0, 12525 // Speaker Id 12526 o, 12527 void 0, 12528 // Json 12529 c 12530 ); 12531 try { 12532 this.privSuccessCallback(u), this.privSuccessCallback = void 0; 12533 } catch { 12534 } 12535 } 12536 } 12537 }; 12538 return ar.SpeechServiceRecognizer = r, ar; 12539} 12540var cr = {}, qc = {}; 12541(function(t) { 12542 Object.defineProperty(t, "__esModule", { value: !0 }
12542), t.IdentityProvider = t.SpeakerDiarizationMode = void 0, function(e) { 12543 e.None = "None", e.Identity = "Identity", e.Anonymous = "Anonymous"; 12544 }(t.SpeakerDiarizationMode || (t.SpeakerDiarizationMode = {})), function(e) { 12545 e.CallCenter = "CallCenter"; 12546 }(t.IdentityProvider || (t.IdentityProvider = {})); 12547})(qc); 12548var Vo; 12549function dl() { 12550 if (Vo) return cr; 12551 Vo = 1, Object.defineProperty(cr, "__esModule", { value: !0 }), cr.ConversationTranscriptionServiceRecognizer = void 0; 12552 const t = R(), e = A(), r = qc, s = ae; 12553 let p = class extends e.ServiceRecognizerBase { 12554 constructor(n, i, o, c, u) { 12555 super(n, i, o, c, u), this.privConversationTranscriber = u, this.setSpeakerDiarizationJson(); 12556 } 12557 setSpeakerDiarizationJson() { 12558 if (this.privEnableSpeakerId) { 12559 const n = this.privSpeechContext.getContext().phraseDetection || {}; 12560 n.mode = s.RecognitionMode.Conversation; 12561 const i = {}; 12562 i.mode = r.SpeakerDiarizationMode.Anonymous, i.audioSessionId = this.privDiarizationSessionId, i.audioOffsetMs = 0, i.diarizeIntermediates = this.privRecognizerConfig.parameters.getProperty(t.PropertyId.SpeechServiceResponse_DiarizeIntermediateResults, "false") === "true", n.speakerDiarization = i, this.privSpeechContext.getContext().phraseDetection = n; 12563 } 12564 } 12565 async processTypeSpecificMessages(n) { 12566 let i; 12567 const o = new t.PropertyCollection(); 12568 o.setProperty(t.PropertyId.SpeechServiceResponse_JsonResult, n.textBody); 12569 let c = !1; 12570 switch (n.path.toLowerCase()) { 12571 case "speech.hypothesis": 12572 case "speech.fragment": 12573 const u = e.SpeechHypothesis.fromJSON(n.textBody, this.privRequestSession.currentTurnAudioOffset), h = this.privRequestSession.onHypothesis(u.Offset); 12574 h > 0 && o.setProperty(t.PropertyId.SpeechServiceResponse_RecognitionLatencyMs, h.toString()), i = new t.ConversationTranscriptionResult(this.privRequestSession.requestId, t.ResultReason.RecognizingSpeech, u.Text, u.Duration, u.Offset, u.Language, u.LanguageDetectionConfidence, u.SpeakerId, void 0, u.asJson(), o); 12575 const d = new t.ConversationTranscriptionEventArgs(i, u.Duration, this.privRequestSession.sessionId); 12576 if (this.privConversationTranscriber.transcribing) 12577 try { 12578 this.privConversationTranscriber.transcribing(this.privConversationTranscriber, d); 12579 } catch { 12580 } 12581 c = !0; 12582 break; 12583 case "speech.phrase": 12584 const v = e.SimpleSpeechPhrase.fromJSON(n.textBody, this.privRequestSession.currentTurnAudioOffset), f = e.EnumTranslation.implTranslateRecognitionResult(v.RecognitionStatus), m = this.privRequestSession.onPhraseRecognized(v.Offset + v.Duration); 12585 if (m > 0 && o.setProperty(t.PropertyId.SpeechServiceResponse_RecognitionLatencyMs, m.toString()), t.ResultReason.Canceled === f) { 12586 const S = e.EnumTranslation.implTranslateCancelResult(v.RecognitionStatus), l = e.EnumTranslation.implTranslateCancelErrorCode(v.RecognitionStatus); 12587 await this.cancelRecognitionLocal(S, l, e.EnumTranslation.implTranslateErrorDetails(l)); 12588 } else if (!(this.privRequestSession.isSpeechEnded && f === t.ResultReason.NoMatch && v.RecognitionStatus !== e.RecognitionStatus.InitialSilenceTimeout)) { 12589 if (this.privRecognizerConfig.parameters.getProperty(e.OutputFormatPropertyName) === t.OutputFormat[t.OutputFormat.Simple]) 12590 i = new t.ConversationTranscriptionResult(this.privRequestSession.requestId, f, v.DisplayText, v.Duration, v.Offset, v.Language, v.LanguageDetectionConfidence, v.SpeakerId, void 0, v.asJson(), o); 12591 else { 12592 const l = e.DetailedSpeechPhrase.fromJSON(n.textBody, this.privRequestSession.currentTurnAudioOffset); 12593 i = new t.ConversationTranscriptionResult(this.privRequestSession.requestId, f, l.RecognitionStatus === e.RecognitionStatus.Success ? l.NBest[0].Display : void 0, l.Duration, l.Offset, l.Language, l.LanguageDetectionConfidence, v.SpeakerId, void 0, l.asJson(), o); 12594 } 12595 const S = new t.ConversationTranscriptionEventArgs(i, i.offset, this.privRequestSession.sessionId); 12596 if (this.privConversationTranscriber.transcribed) 12597 try { 12598 this.privConversationTranscriber.transcribed(this.privConversationTranscriber, S); 12599 } catch { 12600 } 12601 } 12602 c = !0; 12603 break; 12604 } 12605 return c; 12606 } 12607 // Cancels recognition. 12608 cancelRecognition(n, i, o, c, u) { 12609 if (new t.PropertyCollection().setProperty(e.CancellationErrorCodePropertyName, t.CancellationErrorCode[c]), this.privConversationTranscriber.canceled) { 12610 const d = new t.ConversationTranscriptionCanceledEventArgs(o, u, c, void 0, n); 12611 try { 12612 this.privConversationTranscriber.canceled(this.privConversationTranscriber, d); 12613 } catch { 12614 } 12615 } 12616 } 12617 }; 12618 return cr.ConversationTranscriptionServiceRecognizer = p, cr; 12619} 12620var pr = {}, Go; 12621function vl() { 12622 if (Go) return pr; 12623 Go = 1, Object.defineProperty(pr, "__esModule", { value: !0 }), pr.TranscriptionServiceRecognizer = void 0; 12624 const t = I(), e = R(), r = A(), s = xe; 12625 let p = class extends r.ConversationServiceRecognizer { 12626 constructor(n, i, o, c, u) { 12627 super(n, i, o, c, u), this.privTranscriberRecognizer = u, this.sendPrePayloadJSONOverride = (h) => this.sendTranscriptionStartJSON(h), this.privRecognizerConfig.parameters.getProperty(e.PropertyId.SpeechServiceResponse_RequestWordLevelTimestamps) === "true" && this.privSpeechContext.setWordLevelTimings(); 12628 } 12629 async sendSpeechEventAsync(n, i) { 12630 if (this.privRequestSession.isRecognizing) { 12631 const o = await this.fetchConnection(); 12632 await this.sendSpeechEvent(o, this.createSpeechEventPayload(n, i)); 12633 } 12634 } 12635 async sendMeetingSpeechEventAsync(n, i) { 12636 if (this.privRequestSession.isRecognizing) { 12637 const o = await this.fetchConnection(); 12638 await this.sendSpeechEvent(o, this.createMeetingSpeechEventPayload(n, i)); 12639 } 12640 } 12641 processTypeSpecificMessages(n) { 12642 return this.processSpeechMessages(n); 12643 } 12644 handleRecognizedCallback(n, i, o) {
12645 try { 12646 const c = new e.SpeechRecognitionEventArgs(n, i, o); 12647 if (this.privTranscriberRecognizer.recognized(this.privTranscriberRecognizer, c), this.privSuccessCallback) { 12648 try { 12649 this.privSuccessCallback(n); 12650 } catch (u) { 12651 this.privErrorCallback && this.privErrorCallback(u); 12652 } 12653 this.privSuccessCallback = void 0, this.privErrorCallback = void 0; 12654 } 12655 } catch { 12656 } 12657 } 12658 handleRecognizingCallback(n, i, o) { 12659 try { 12660 const c = new e.SpeechRecognitionEventArgs(n, i, o); 12661 this.privTranscriberRecognizer.recognizing(this.privTranscriberRecognizer, c); 12662 } catch { 12663 } 12664 } 12665 // Cancels recognition. 12666 cancelRecognition(n, i, o, c, u) { 12667 const h = new e.PropertyCollection(); 12668 if (h.setProperty(r.CancellationErrorCodePropertyName, e.CancellationErrorCode[c]), this.privTranscriberRecognizer.IsMeetingRecognizer()) { 12669 if (this.privTranscriberRecognizer.canceled) { 12670 const d = new e.MeetingTranscriptionCanceledEventArgs(o, u, c, void 0, n); 12671 try { 12672 this.privTranscriberRecognizer.canceled(this.privTranscriberRecognizer, d); 12673 } catch { 12674 } 12675 } 12676 } else if (this.privTranscriberRecognizer.canceled) { 12677 const d = new e.ConversationTranscriptionCanceledEventArgs(o, u, c, void 0, n); 12678 try { 12679 this.privTranscriberRecognizer.canceled(this.privTranscriberRecognizer, d); 12680 } catch { 12681 } 12682 } 12683 if (this.privSuccessCallback) { 12684 const d = new e.SpeechRecognitionResult( 12685 i, 12686 e.ResultReason.Canceled, 12687 void 0, 12688 // Text 12689 void 0, 12690 // Duration 12691 void 0, 12692 // Offset 12693 void 0, 12694 // Language 12695 void 0, 12696 // Language Detection Confidence 12697 void 0, 12698 // Speaker Id 12699 u, 12700 void 0, 12701 // Json 12702 h 12703 ); 12704 try { 12705 this.privSuccessCallback(d), this.privSuccessCallback = void 0; 12706 } catch { 12707 } 12708 } 12709 } 12710 // Encapsulated for derived service recognizers that need to send additional JSON 12711 async sendTranscriptionStartJSON(n) { 12712 if (await this.sendSpeechContext(n, !0), this.privTranscriberRecognizer.IsMeetingRecognizer()) { 12713 const i = this.privTranscriberRecognizer.getMeetingInfo(), o = this.createMeetingSpeechEventPayload(i, "start"); 12714 await this.sendSpeechEvent(n, o); 12715 } else { 12716 const i = this.privTranscriberRecognizer.getConversationInfo(), o = this.createSpeechEventPayload(i, "start"); 12717 await this.sendSpeechEvent(n, o); 12718 } 12719 await this.sendWaveHeader(n); 12720 } 12721 sendSpeechEvent(n, i) { 12722 const o = JSON.stringify(i); 12723 if (o) 12724 return n.send(new s.SpeechConnectionMessage(t.MessageType.Text, "speech.event", this.privRequestSession.requestId, "application/json", o)); 12725 } 12726 createSpeechEventPayload(n, i) { 12727 const o = { id: "meeting", name: i, meeting: n.conversationProperties }; 12728 return o.meeting.id = n.id, o.meeting.attendees = n.participants, o; 12729 } 12730 createMeetingSpeechEventPayload(n, i) { 12731 const o = { id: "meeting", name: i, meeting: n.meetingProperties }; 12732 return o.meeting.id = n.id, o.meeting.attendees = n.participants, o; 12733 } 12734 }; 12735 return pr.TranscriptionServiceRecognizer = p, pr; 12736} 12737var ur = {}, Qo; 12738function ll() { 12739 if (Qo) return ur; 12740 Qo = 1, Object.defineProperty(ur, "__esModule", { value: !0 }), ur.DetailedSpeechPhrase = void 0; 12741 const t = A(); 12742 let e = class Fc { 12743 constructor(s, p) { 12744 this.privDetailedSpeechPhrase = JSON.parse(s), this.privDetailedSpeechPhrase.RecognitionStatus = this.mapRecognitionStatus(this.privDetailedSpeechPhrase.RecognitionStatus), this.updateOffsets(p); 12745 } 12746 static fromJSON(s, p) { 12747 return new Fc(s, p); 12748 } 12749 updateOffsets(s) { 12750 if (this.privDetailedSpeechPhrase.Offset += s, this.privDetailedSpeechPhrase.NBest) 12751 for (const p of this.privDetailedSpeechPhrase.NBest) { 12752 if (p.Words) 12753 for (const a of p.Words) 12754 a.Offset += s; 12755 if (p.DisplayWords) 12756 for (const a of p.DisplayWords) 12757 a.Offset += s; 12758 } 12759 } 12760 asJson() { 12761 const s = { ...this.privDetailedSpeechPhrase }; 12762 return JSON.stringify({ 12763 ...s, 12764 RecognitionStatus: t.RecognitionStatus[s.RecognitionStatus] 12765 }); 12766 } 12767 get RecognitionStatus() { 12768 return this.privDetailedSpeechPhrase.RecognitionStatus; 12769 } 12770 get NBest() { 12771 return this.privDetailedSpeechPhrase.NBest; 12772 } 12773 get Duration() { 12774 return this.privDetailedSpeechPhrase.Duration; 12775 } 12776 get Offset() { 12777 return this.privDetailedSpeechPhrase.Offset; 12778 } 12779 get Language() { 12780 return this.privDetailedSpeechPhrase.PrimaryLanguage === void 0 ? void 0 : this.privDetailedSpeechPhrase.PrimaryLanguage.Language; 12781 } 12782 get LanguageDetectionConfidence() { 12783 return this.privDetailedSpeechPhrase.PrimaryLanguage === void 0 ? void 0 : this.privDetailedSpeechPhrase.PrimaryLanguage.Confidence; 12784 } 12785 get Text() { 12786 return this.privDetailedSpeechPhrase.NBest && this.privDetailedSpeechPhrase.NBest[0] ? this.privDetailedSpeechPhrase.NBest[0].Display || this.privDetailedSpeechPhrase.NBest[0].DisplayText : this.privDetailedSpeechPhrase.DisplayText; 12787 } 12788 get SpeakerId() { 12789 return this.privDetailedSpeechPhrase.SpeakerId; 12790 } 12791 mapRecognitionStatus(s) { 12792 if (typeof s == "string") 12793 return t.RecognitionStatus[s]; 12794 if (typeof s == "number") 12795 return s; 12796 } 12797 }; 12798 return ur.DetailedSpeechPhrase = e, ur; 12799} 12800var hr = {}, Xo; 12801function fl() { 12802 if (Xo) return hr; 12803 Xo = 1, Object.defineProperty(hr, "__esModule", { value: !0 }), hr.SimpleSpeechPhrase = void 0;
12804 const t = A(); 12805 let e = class Uc { 12806 constructor(s, p = 0) { 12807 this.privSimpleSpeechPhrase = JSON.parse(s), this.privSimpleSpeechPhrase.RecognitionStatus = this.mapRecognitionStatus(this.privSimpleSpeechPhrase.RecognitionStatus), this.updateOffset(p); 12808 } 12809 static fromJSON(s, p) { 12810 return new Uc(s, p); 12811 } 12812 updateOffset(s) { 12813 this.privSimpleSpeechPhrase.Offset += s; 12814 } 12815 asJson() { 12816 const s = { ...this.privSimpleSpeechPhrase }; 12817 return JSON.stringify({ 12818 ...s, 12819 RecognitionStatus: t.RecognitionStatus[s.RecognitionStatus] 12820 }); 12821 } 12822 get RecognitionStatus() { 12823 return this.privSimpleSpeechPhrase.RecognitionStatus; 12824 } 12825 get DisplayText() { 12826 return this.privSimpleSpeechPhrase.DisplayText; 12827 } 12828 get Offset() { 12829 return this.privSimpleSpeechPhrase.Offset; 12830 } 12831 get Duration() { 12832 return this.privSimpleSpeechPhrase.Duration; 12833 } 12834 get Language() { 12835 return this.privSimpleSpeechPhrase.PrimaryLanguage === void 0 ? void 0 : this.privSimpleSpeechPhrase.PrimaryLanguage.Language; 12836 } 12837 get LanguageDetectionConfidence() { 12838 return this.privSimpleSpeechPhrase.PrimaryLanguage === void 0 ? void 0 : this.privSimpleSpeechPhrase.PrimaryLanguage.Confidence; 12839 } 12840 get SpeakerId() { 12841 return this.privSimpleSpeechPhrase.SpeakerId; 12842 } 12843 mapRecognitionStatus(s) { 12844 if (typeof s == "string") 12845 return t.RecognitionStatus[s]; 12846 if (typeof s == "number") 12847 return s; 12848 } 12849 }; 12850 return hr.SimpleSpeechPhrase = e, hr; 12851} 12852var Vi = {}, Gi = {}; 12853Object.defineProperty(Gi, "__esModule", { value: !0 }); 12854Gi.ServiceTelemetryListener = void 0; 12855const le = I(), Yo = li; 12856class gl { 12857 constructor(e, r, s) { 12858 this.privIsDisposed = !1, this.privListeningTriggerMetric = null, this.privMicMetric = null, this.privConnectionEstablishMetric = null, this.privRequestId = e, this.privAudioSourceId = r, this.privAudioNodeId = s, this.privReceivedMessages = {}, this.privPhraseLatencies = [], this.privHypothesisLatencies = []; 12859 } 12860 phraseReceived(e) { 12861 e > 0 && this.privPhraseLatencies.push(Date.now() - e); 12862 } 12863 hypothesisReceived(e) { 12864 e > 0 && this.privHypothesisLatencies.push(Date.now() - e); 12865 } 12866 onEvent(e) { 12867 this.privIsDisposed || (e instanceof Yo.RecognitionTriggeredEvent && e.requestId === this.privRequestId && (this.privListeningTriggerMetric = { 12868 End: e.eventTime, 12869 Name: "ListeningTrigger", 12870 Start: e.eventTime 12871 }), e instanceof le.AudioStreamNodeAttachingEvent && e.audioSourceId === this.privAudioSourceId && e.audioNodeId === this.privAudioNodeId && (this.privMicStartTime = e.eventTime), e instanceof le.AudioStreamNodeAttachedEvent && e.audioSourceId === this.privAudioSourceId && e.audioNodeId === this.privAudioNodeId && (this.privMicStartTime = e.eventTime), e instanceof le.AudioSourceErrorEvent && e.audioSourceId === this.privAudioSourceId && (this.privMicMetric || (this.privMicMetric = { 12872 End: e.eventTime, 12873 Error: e.error, 12874 Name: "Microphone", 12875 Start: this.privMicStartTime 12876 })), e instanceof le.AudioStreamNodeErrorEvent && e.audioSourceId === this.privAudioSourceId && e.audioNodeId === this.privAudioNodeId && (this.privMicMetric || (this.privMicMetric = { 12877 End: e.eventTime, 12878 Error: e.error, 12879 Name: "Microphone", 12880 Start: this.privMicStartTime 12881 })), e instanceof le.AudioStreamNodeDetachedEvent && e.audioSourceId === this.privAudioSourceId && e.audioNodeId === this.privAudioNodeId && (this.privMicMetric || (this.privMicMetric = { 12882 End: e.eventTime, 12883 Name: "Microphone", 12884 Start: this.privMicStartTime 12885 })), e instanceof Yo.ConnectingToServiceEvent && e.requestId === this.privRequestId && (this.privConnectionId = e.sessionId), e instanceof le.ConnectionStartEvent && e.connectionId === this.privConnectionId && (this.privConnectionStartTime = e.eventTime), e instanceof le.ConnectionEstablishedEvent && e.connectionId === this.privConnectionId && (this.privConnectionEstablishMetric || (this.privConnectionEstablishMetric = { 12886 End: e.eventTime, 12887 Id: this.privConnectionId, 12888 Name: "Connection", 12889 Start: this.privConnectionStartTime 12890 })), e instanceof le.ConnectionEstablishErrorEvent && e.connectionId === this.privConnectionId && (this.privConnectionEstablishMetric || (this.privConnectionEstablishMetric = { 12891 End: e.eventTime, 12892 Error: this.getConnectionError(e.statusCode), 12893 Id: this.privConnectionId, 12894 Name: "Connection", 12895 Start: this.privConnectionStartTime 12896 })), e instanceof le.ConnectionMessageReceivedEvent && e.connectionId === this.privConnectionId && e.message && e.message.headers && e.message.headers.path && (this.privReceivedMessages[e.message.headers.path] || (this.privReceivedMessages[e.message.headers.path] = new Array()), this.privReceivedMessages[e.message.headers.path].length < 50 && this.privReceivedMessages[e.message.headers.path].push(e.networkReceivedTime))); 12897 } 12898 getTelemetry() { 12899 const e = new Array(); 12900 this.privListeningTriggerMetric && e.push(this.privListeningTriggerMetric), this.privMicMetric && e.push(this.privMicMetric), this.privConnectionEstablishMetric && e.push(this.privConnectionEstablishMetric), this.privPhraseLatencies.length > 0 && e.push({ 12901 PhraseLatencyMs: this.privPhraseLatencies 12902 }), this.privHypothesisLatencies.length > 0 && e.push({ 12903 FirstHypothesisLatencyMs: this.privHypothesisLatencies 12904 }); 12905 const r = { 12906 Metrics: e, 12907 ReceivedMessages: this.privReceivedMessages 12908 }, s = JSON.stringify(r); 12909 return this.privReceivedMessages = {}, this.privListeningTriggerMetric = null, this.privMicMetric = null, this.privConnectionEstablishMetric = null, this.privPhraseLatencies = [], this.privHypothesisLatencies = [], s; 12910 } 12911 // Determines if there are any telemetry events to send to the service. 12912 get hasTelemetry() { 12913 return Object.keys(this.privReceivedMessages).length !== 0 || this.privListeningTriggerMetric !== null || this.privMicMetric !== null || this.privConnectionEstablishMetric !== null || this.privPhraseLatencies.length !== 0 || this.privHypothesisLatencies.length !== 0; 12914 } 12915 dispose() { 12916 this.privIsDisposed = !0; 12917 } 12918 getConnectionError(e) { 12919 switch (e) { 12920 case 400: 12921 case 1002: 12922 case 1003: 12923 case 1005: 12924 case 1007: 12925 case 1008: 12926 case 1009: 12927 return "BadRequest";
12928 case 401: 12929 return "Unauthorized"; 12930 case 403: 12931 return "Forbidden"; 12932 case 503: 12933 case 1001: 12934 return "ServerUnavailable"; 12935 case 500: 12936 case 1011: 12937 return "ServerError"; 12938 case 408: 12939 case 504: 12940 return "Timeout"; 12941 default: 12942 return "statuscode:" + e.toString(); 12943 } 12944 } 12945} 12946Gi.ServiceTelemetryListener = gl; 12947Object.defineProperty(Vi, "__esModule", { value: !0 }); 12948Vi.RequestSession = void 0; 12949const He = I(), xr = li, ml = Gi; 12950class Sl { 12951 constructor(e) { 12952 this.privIsDisposed = !1, this.privDetachables = new Array(), this.privIsAudioNodeDetached = !1, this.privIsRecognizing = !1, this.privIsSpeechEnded = !1, this.privTurnStartAudioOffset = 0, this.privLastRecoOffset = 0, this.privHypothesisReceived = !1, this.privBytesSent = 0, this.privRecognitionBytesSent = 0, this.privRecogNumber = 0, this.privInTurn = !1, this.privConnectionAttempts = 0, this.privAudioSourceId = e, this.privRequestId = (0, He.createNoDashGuid)(), this.privAudioNodeId = (0, He.createNoDashGuid)(), this.privTurnDeferral = new He.Deferred(), this.privTurnDeferral.resolve(); 12953 } 12954 get sessionId() { 12955 return this.privSessionId; 12956 } 12957 get requestId() { 12958 return this.privRequestId; 12959 } 12960 get audioNodeId() { 12961 return this.privAudioNodeId; 12962 } 12963 get turnCompletionPromise() { 12964 return this.privTurnDeferral.promise; 12965 } 12966 get isSpeechEnded() { 12967 return this.privIsSpeechEnded; 12968 }
12969 get isRecognizing() { 12970 return this.privIsRecognizing; 12971 } 12972 get currentTurnAudioOffset() { 12973 return this.privTurnStartAudioOffset; 12974 } 12975 get recogNumber() { 12976 return this.privRecogNumber; 12977 } 12978 get numConnectionAttempts() { 12979 return this.privConnectionAttempts; 12980 } 12981 // The number of bytes sent for the current connection. 12982 // Counter is reset to 0 each time a connection is established. 12983 get bytesSent() { 12984 return this.privBytesSent; 12985 } 12986 // The number of bytes sent for the current recognition. 12987 // Counter is reset to 0 each time recognition is started. 12988 get recognitionBytesSent() { 12989 return this.privRecognitionBytesSent; 12990 } 12991 listenForServiceTelemetry(e) { 12992 this.privServiceTelemetryListener && this.privDetachables.push(e.attachListener(this.privServiceTelemetryListener)); 12993 } 12994 startNewRecognition() { 12995 this.privRecognitionBytesSent = 0, this.privIsSpeechEnded = !1, this.privIsRecognizing = !0, this.privTurnStartAudioOffset = 0, this.privLastRecoOffset = 0, this.privRecogNumber++, this.privServiceTelemetryListener = new ml.ServiceTelemetryListener(this.privRequestId, this.privAudioSourceId, this.privAudioNodeId), this.onEvent(new xr.RecognitionTriggeredEvent(this.requestId, this.privSessionId, this.privAudioSourceId, this.privAudioNodeId)); 12996 } 12997 async onAudioSourceAttachCompleted(e, r) { 12998 this.privAudioNode = e, this.privIsAudioNodeDetached = !1, r ? await this.onComplete() : this.onEvent(new xr.ListeningStartedEvent(this.privRequestId, this.privSessionId, this.privAudioSourceId, this.privAudioNodeId)); 12999 } 13000 onPreConnectionStart(e, r) { 13001 this.privAuthFetchEventId = e, this.privSessionId = r, this.onEvent(new xr.ConnectingToServiceEvent(this.privRequestId, this.privAuthFetchEventId, this.privSessionId)); 13002 } 13003 async onAuthCompleted(e) { 13004 e && await this.onComplete(); 13005 } 13006 // eslint-disable-next-line @typescript-eslint/no-unused-vars 13007 async onConnectionEstablishCompleted(e, r) { 13008 if (e === 200) { 13009 this.onEvent(new xr.RecognitionStartedEvent(this.requestId, this.privAudioSourceId, this.privAudioNodeId, this.privAuthFetchEventId, this.privSessionId)), this.privAudioNode && this.privAudioNode.replay(), this.privTurnStartAudioOffset = this.privLastRecoOffset, this.privBytesSent = 0; 13010 return; 13011 } else e === 403 && await this.onComplete(); 13012 } 13013 async onServiceTurnEndResponse(e) { 13014 this.privTurnDeferral.resolve(), !e || this.isSpeechEnded ? (await this.onComplete(), this.privInTurn = !1) : (this.privTurnStartAudioOffset = this.privLastRecoOffset, this.privAudioNode.replay()); 13015 } 13016 onSpeechContext() { 13017 this.privRequestId = (0, He.createNoDashGuid)(); 13018 } 13019 onServiceTurnStartResponse() { 13020 this.privTurnDeferral && this.privInTurn && (this.privTurnDeferral.reject("Another turn started before current completed."), this.privTurnDeferral.promise.then().catch(() => { 13021 })), this.privInTurn = !0, this.privTurnDeferral = new He.Deferred(); 13022 } 13023 onHypothesis(e) { 13024 const r = this.privAudioNode.findTimeAtOffset(e); 13025 return this.privHypothesisReceived || (this.privHypothesisReceived = !0, this.privServiceTelemetryListener.hypothesisReceived(r)), r > 0 ? Date.now() - r : 0; 13026 } 13027 onPhraseRecognized(e) { 13028 const r = this.privAudioNode.findTimeAtOffset(e); 13029 return this.privServiceTelemetryListener.phraseReceived(r), this.onServiceRecognized(e), r > 0 ? Date.now() - r : 0; 13030 } 13031 onServiceRecognized(e) { 13032 this.privLastRecoOffset = e, this.privHypothesisReceived = !1, this.privAudioNode.shrinkBuffers(e), this.privConnectionAttempts = 0; 13033 } 13034 onAudioSent(e) { 13035 this.privBytesSent += e, this.privRecognitionBytesSent += e; 13036 } 13037 onRetryConnection() { 13038 this.privConnectionAttempts++; 13039 } 13040 async dispose() { 13041 if (!this.privIsDisposed) { 13042 this.privIsDisposed = !0; 13043 for (const e of this.privDetachables) 13044 await e.detach(); 13045 this.privServiceTelemetryListener && this.privServiceTelemetryListener.dispose(), this.privIsRecognizing = !1; 13046 } 13047 } 13048 getTelemetry() { 13049 return this.privServiceTelemetryListener.hasTelemetry ? this.privServiceTelemetryListener.getTelemetry() : null; 13050 }
13051 async onStopRecognizing() { 13052 await this.onComplete(); 13053 } 13054 // Should be called with the audioNode for this session has indicated that it is out of speech. 13055 onSpeechEnded() { 13056 this.privIsSpeechEnded = !0; 13057 } 13058 onEvent(e) { 13059 this.privServiceTelemetryListener && this.privServiceTelemetryListener.onEvent(e), He.Events.instance.onEvent(e); 13060 } 13061 async onComplete() { 13062 this.privIsRecognizing && (this.privIsRecognizing = !1, await this.detachAudioNode()); 13063 } 13064 async detachAudioNode() { 13065 this.privIsAudioNodeDetached || (this.privIsAudioNodeDetached = !0, this.privAudioNode && await this.privAudioNode.detach()); 13066 } 13067} 13068Vi.RequestSession = Sl; 13069var Qi = {}, xc = {}; 13070(function(t) { 13071 Object.defineProperty(t, "__esModule", { value: !0 }), t.TentativePhraseResultsOption = t.OutputFormat = t.PhraseExtension = t.PhraseOption = void 0, function(e) { 13072 e.WordTimings = "WordTimings", e.SNR = "SNR", e.Pronunciation = "Pronunciation", e.WordPronunciation = "WordPronunciation", e.WordConfidence = "WordConfidence", e.Words = "Words", e.Sentiment = "Sentiment", e.PronunciationAssessment = "PronunciationAssessment", e.ContentAssessment = "ContentAssessment", e.PhraseAMScore = "PhraseAMScore", e.PhraseLMScore = "PhraseLMScore", e.WordAMScore = "WordAMScore", e.WordLMScore = "WordLMScore", e.RuleTree = "RuleTree", e.NBestTimings = "NBestTimings", e.DecoderDiagnostics = "DecoderDiagnostics", e.DisplayWordTimings = "DisplayWordTimings", e.DisplayWords = "DisplayWords"; 13073 }(t.PhraseOption || (t.PhraseOption = {})), function(e) { 13074 e.Graph = "Graph", e.Corrections = "Corrections", e.Sentiment = "Sentiment"; 13075 }(t.PhraseExtension || (t.PhraseExtension = {})), function(e) { 13076 e.Simple = "Simple", e.Detailed = "Detailed"; 13077 }(t.OutputFormat || (t.OutputFormat = {})), function(e) { 13078 e.None = "None", e.Always = "Always"; 13079 }(t.TentativePhraseResultsOption || (t.TentativePhraseResultsOption = {})); 13080})(xc); 13081Object.defineProperty(Qi, "__esModule", { value: !0 }); 13082Qi.SpeechContext = void 0; 13083const Cl = ae, je = xc; 13084class yl { 13085 constructor(e) { 13086 this.privContext = {}, this.privDynamicGrammar = e; 13087 } 13088 getContext() { 13089 return this.privContext; 13090 } 13091 /** 13092 * @Internal 13093 * This is only used by pronunciation assessment config. 13094 * Do not use externally, object returned will change without warning or notice. 13095 */ 13096 setPronunciationAssessmentParams(e, r = !1) { 13097 this.privContext.phraseDetection === void 0 && (this.privContext.phraseDetection = { 13098 enrichment: { 13099 pronunciationAssessment: {} 13100 } 13101 }), this.privContext.phraseDetection.enrichment === void 0 && (this.privContext.phraseDetection.enrichment = { 13102 pronunciationAssessment: {} 13103 }), this.privContext.phraseDetection.enrichment.pronunciationAssessment = JSON.parse(e) || {}, r && (this.privContext.phraseDetection.mode = Cl.RecognitionMode.Conversation), this.setWordLevelTimings(), this.privContext.phraseOutput.detailed.options.push(je.PhraseOption.PronunciationAssessment), this.privContext.phraseOutput.detailed.options.indexOf(je.PhraseOption.SNR) === -1 && this.privContext.phraseOutput.detailed.options.push(je.PhraseOption.SNR); 13104 } 13105 setDetailedOutputFormat() { 13106 this.privContext.phraseOutput === void 0 && (this.privContext.phraseOutput = { 13107 detailed: { 13108 options: [] 13109 } 13110 }), this.privContext.phraseOutput.detailed === void 0 && (this.privContext.phraseOutput.detailed = { 13111 options: [] 13112 }), this.privContext.phraseOutput.format = je.OutputFormat.Detailed; 13113 } 13114 setWordLevelTimings() { 13115 this.privContext.phraseOutput === void 0 && (this.privContext.phraseOutput = { 13116 detailed: { 13117 options: [] 13118 } 13119 }), this.privContext.phraseOutput.detailed === void 0 && (this.privContext.phraseOutput.detailed = { 13120 options: [] 13121 }), this.privContext.phraseOutput.format = je.OutputFormat.Detailed, this.privContext.phraseOutput.detailed.options.indexOf(je.PhraseOption.WordTimings) === -1 && this.privContext.phraseOutput.detailed.options.push(je.PhraseOption.WordTimings); 13122 } 13123 setSpeakerDiarizationAudioOffsetMs(e) { 13124 this.privContext.phraseDetection.speakerDiarization.audioOffsetMs = e; 13125 } 13126 toJSON() { 13127 const e = this.privDynamicGrammar.generateGrammarObject(); 13128 return this.privContext.dgi = e, JSON.stringify(this.privContext); 13129 } 13130} 13131Qi.SpeechContext = yl; 13132var Xi = {}, Wc = {}; 13133(function(t) { 13134 Object.defineProperty(t, "__esModule", { value: !0 }), t.SubstringMatchType = t.GroupType = void 0, function(e) { 13135 e.IntentText = "IntentText", e.IntentEntity = "IntentEntity", e.Generic = "Generic", e.People = "People", e.Place = "Place", e.DynamicEntity = "DynamicEntity"; 13136 }(t.GroupType || (t.GroupType = {})), function(e) { 13137 e.None = "None", e.LeftRooted = "LeftRooted", e.PartialName = "PartialName", e.MiddleOfSentence = "MiddleOfSentence"; 13138 }(t.SubstringMatchType || (t.SubstringMatchType = {})); 13139})(Wc); 13140Object.defineProperty(Xi, "__esModule", { value: !0 }); 13141Xi.DynamicGrammarBuilder = void 0; 13142const Pl = Wc; 13143class Rl { 13144 constructor() { 13145 this.privWeight = 1; 13146 } 13147 // Adds one more reference phrases to the dynamic grammar to send. 13148 // All added phrases are generic phrases. 13149 addPhrase(e) { 13150 this.privPhrases || (this.privPhrases = []), e instanceof Array ? this.privPhrases = this.privPhrases.concat(e) : this.privPhrases.push(e); 13151 } 13152 // Clears all phrases stored in the current object. 13153 clearPhrases() { 13154 this.privPhrases = void 0; 13155 } 13156 // Adds one or more reference grammars to the current grammar. 13157 addReferenceGrammar(e) { 13158 this.privGrammars || (this.privGrammars = []), e instanceof Array ? this.privGrammars = this.privGrammars.concat(e) : this.privGrammars.push(e); 13159 } 13160 // clears all grammars stored on the recognizer. 13161 clearGrammars() { 13162 this.privGrammars = void 0; 13163 } 13164 // Sets the weight for the dynamic grammar. 13165 setWeight(e) { 13166 this.privWeight = e; 13167 } 13168 // Generates an object that represents the dynamic grammar used by the Speech Service. 13169 // This is done by building an object with the correct layout based on the phrases and reference grammars added to this instance 13170 // of a DynamicGrammarBuilder 13171 generateGrammarObject() { 13172 if (this.privGrammars === void 0 && this.privPhrases === void 0) 13173 return; 13174 const e = {}; 13175 if (e.referenceGrammars = this.privGrammars, this.privPhrases !== void 0 && this.privPhrases.length !== 0) { 13176 const r = [];
13177 this.privPhrases.forEach((s) => { 13178 r.push({ 13179 text: s 13180 }); 13181 }), e.groups = [{ type: Pl.GroupType.Generic, items: r }], e.bias = this.privWeight; 13182 } 13183 return e; 13184 } 13185} 13186Xi.DynamicGrammarBuilder = Rl; 13187var dr = {}, Yi = {}, Zi = {}, Yn = {}; 13188(function(t) { 13189 Object.defineProperty(t, "__esModule", { value: !0 }), t.MessageDataStreamType = t.ActivityPayloadResponse = void 0; 13190 class e { 13191 constructor(s) { 13192 this.privActivityResponse = JSON.parse(s); 13193 } 13194 static fromJSON(s) { 13195 return new e(s); 13196 } 13197 get conversationId() { 13198 return this.privActivityResponse.conversationId; 13199 } 13200 get messageDataStreamType() { 13201 return this.privActivityResponse.messageDataStreamType; 13202 } 13203 get messagePayload() { 13204 return this.privActivityResponse.messagePayload; 13205 } 13206 get version() { 13207 return this.privActivityResponse.version; 13208 } 13209 } 13210 t.ActivityPayloadResponse = e, function(r) { 13211 r[r.None = 0] = "None", r[r.TextToSpeechAudio = 1] = "TextToSpeechAudio"; 13212 }(t.MessageDataStreamType || (t.MessageDataStreamType = {})); 13213})(Yn); 13214Object.defineProperty(Zi, "__esModule", { value: !0 }); 13215Zi.DialogServiceTurnState = void 0; 13216const El = Ie, Tl = U, Al = Yn; 13217class Il { 13218 constructor(e, r) { 13219 this.privRequestId = r, this.privIsCompleted = !1, this.privAudioStream = null, this.privTurnManager = e, this.resetTurnEndTimeout(); 13220 } 13221 get audioStream() { 13222 return this.resetTurnEndTimeout(), this.privAudioStream; 13223 } 13224 processActivityPayload(e, r) { 13225 return e.messageDataStreamType === Al.MessageDataStreamType.TextToSpeechAudio && (this.privAudioStream = Tl.AudioOutputStream.createPullStream(), this.privAudioStream.format = r !== void 0 ? r : El.AudioOutputFormatImpl.getDefaultOutputFormat()), this.privAudioStream; 13226 } 13227 endAudioStream() { 13228 this.privAudioStream !== null && !this.privAudioStream.isClosed && this.privAudioStream.close(); 13229 } 13230 complete() { 13231 this.privTimeoutToken !== void 0 && clearTimeout(this.privTimeoutToken), this.endAudioStream(); 13232 } 13233 resetTurnEndTimeout() { 13234 this.privTimeoutToken !== void 0 && clearTimeout(this.privTimeoutToken), this.privTimeoutToken = setTimeout(() => { 13235 this.privTurnManager.CompleteTurn(this.privRequestId); 13236 }, 2e3); 13237 } 13238} 13239Zi.DialogServiceTurnState = Il; 13240Object.defineProperty(Yi, "__esModule", { value: !0 }); 13241Yi.DialogServiceTurnStateManager = void 0; 13242const Zo = x, wl = Zi; 13243class _l { 13244 constructor() { 13245 this.privTurnMap = /* @__PURE__ */ new Map(); 13246 } 13247 StartTurn(e) { 13248 if (this.privTurnMap.has(e)) 13249 throw new Zo.InvalidOperationError("Service error: There is already a turn with id:" + e); 13250 const r = new wl.DialogServiceTurnState(this, e); 13251 return this.privTurnMap.set(e, r), this.privTurnMap.get(e); 13252 } 13253 GetTurn(e) { 13254 return this.privTurnMap.get(e); 13255 } 13256 CompleteTurn(e) { 13257 if (!this.privTurnMap.has(e)) 13258 throw new Zo.InvalidOperationError("Service error: Received turn end for an unknown turn id:" + e); 13259 const r = this.privTurnMap.get(e); 13260 return r.complete(), this.privTurnMap.delete(e), r; 13261 } 13262} 13263Yi.DialogServiceTurnStateManager = _l; 13264var Hc = {}; 13265(function(t) { 13266 Object.defineProperty(t, "__esModule", { value: !0 }), t.InvocationSource = void 0, function(e) { 13267 e.None = "None", e.VoiceActivationWithKeyword = "VoiceActivationWithKeyword"; 13268 }(t.InvocationSource || (t.InvocationSource = {})); 13269})(Hc); 13270var Kc = {}; 13271(function(t) { 13272 Object.defineProperty(t, "__esModule", { value: !0 }), t.OnRejectAction = t.KeywordDetectionType = void 0, function(e) { 13273 e.StartTrigger = "StartTrigger"; 13274 }(t.KeywordDetectionType || (t.KeywordDetectionType = {})), function(e) { 13275 e.EndOfTurn = "EndOfTurn", e.Continue = "Continue"; 13276 }(t.OnRejectAction || (t.OnRejectAction = {})); 13277})(Kc); 13278var $o; 13279function bl() { 13280 if ($o) return dr; 13281 $o = 1, Object.defineProperty(dr, "__esModule", { value: !0 }), dr.DialogServiceAdapter = void 0; 13282 const t = re(), e = qe, r = I(), s = Ie, p = R(), a = Yi, n = A(), i = Yn, o = Hc, c = Kc, u = xe; 13283 let h = class extends n.ServiceRecognizerBase { 13284 constructor(v, f, m, S, l) { 13285 super(v, f, m, S, l), this.privEvents = new r.EventSource(), this.privDialogServiceConnector = l, this.receiveMessageOverride = () => this.receiveDialogMessageOverride(), this.privTurnStateManager = new a.DialogServiceTurnStateManager(), this.recognizeOverride = (g, C, y) => this.listenOnce(g, C, y), this.postConnectImplOverride = (g) => this.dialogConnectImpl(g), this.configConnectionOverride = (g) => this.configConnection(g), this.disconnectOverride = () => this.privDisconnect(), this.privDialogAudioSource = m, this.agentConfigSent = !1, this.privLastResult = null, this.connectionEvents.attach((g) => { 13286 g.name === "ConnectionClosedEvent" && (this.terminateMessageLoop = !0); 13287 }); 13288 } 13289 async sendMessage(v) { 13290 const f = (0, r.createGuid)(), m = (0, r.createNoDashGuid)(), S = { 13291 context: { 13292 interactionId: f 13293 }, 13294 // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment 13295 messagePayload: JSON.parse(v), 13296 version: 0.5 13297 }, l = JSON.stringify(S); 13298 await (await this.fetchConnection()).send(new u.SpeechConnectionMessage(r.MessageType.Text, "agent", m, "application/json", l)); 13299 } 13300 async privDisconnect() { 13301 await this.cancelRecognition(this.privRequestSession.sessionId, this.privRequestSession.requestId, p.CancellationReason.Error, p.CancellationErrorCode.NoError, "Disconnecting"), this.terminateMessageLoop = !0, this.agentConfigSent = !1; 13302 } 13303 processTypeSpecificMessages(v) { 13304 const f = new p.PropertyCollection(); 13305 v.messageType === r.MessageType.Text && f.setProperty(p.PropertyId.SpeechServiceResponse_JsonResult, v.textBody); 13306 let m, S; 13307 switch (v.path.toLowerCase()) { 13308 case "speech.phrase": 13309 const g = n.SimpleSpeechPhrase.fromJSON(v.textBody, this.privRequestSession.currentTurnAudioOffset); 13310 if (this.privRequestSession.onPhraseRecognized(g.Offset + g.Duration), g.RecognitionStatus !== n.RecognitionStatus.TooManyRequests && g.RecognitionStatus !== n.RecognitionStatus.Error) { 13311 const _ = this.fireEventForResult(g, f); 13312 if (this.privLastResult = _.result, this.privDialogServiceConnector.re
13312cognized) 13313 try { 13314 this.privDialogServiceConnector.recognized(this.privDialogServiceConnector, _); 13315 } catch { 13316 } 13317 } 13318 S = !0; 13319 break; 13320 case "speech.hypothesis": 13321 const C = n.SpeechHypothesis.fromJSON(v.textBody, this.privRequestSession.currentTurnAudioOffset); 13322 m = new p.SpeechRecognitionResult(this.privRequestSession.requestId, p.ResultReason.RecognizingSpeech, C.Text, C.Duration, C.Offset, C.Language, C.LanguageDetectionConfidence, void 0, void 0, C.asJson(), f), this.privRequestSession.onHypothesis(C.Offset); 13323 const y = new p.SpeechRecognitionEventArgs(m, C.Offset, this.privRequestSession.sessionId); 13324 if (this.privDialogServiceConnector.recognizing) 13325 try { 13326 this.privDialogServiceConnector.recognizing(this.privDialogServiceConnector, y); 13327 } catch { 13328 } 13329 S = !0; 13330 break; 13331 case "speech.keyword": 13332 const P = n.SpeechKeyword.fromJSON(v.textBody, this.privRequestSession.currentTurnAudioOffset); 13333 m = new p.SpeechRecognitionResult(this.privRequestSession.requestId, P.Status === "Accepted" ? p.ResultReason.RecognizedKeyword : p.ResultReason.NoMatch, P.Text, P.Duration, P.Offset, void 0, void 0, void 0, void 0, P.asJson(), f), P.Status !== "Accepted" && (this.privLastResult = m); 13334 const T = new p.SpeechRecognitionEventArgs(m, m.duration, m.resultId); 13335 if (this.privDialogServiceConnector.recognized) 13336 try { 13337 this.privDialogServiceConnector.recognized(this.privDialogServiceConnector, T); 13338 } catch { 13339 } 13340 S = !0; 13341 break; 13342 case "audio": 13343 { 13344 const _ = v.requestId.toUpperCase(), E = this.privTurnStateManager.GetTurn(_); 13345 try { 13346 v.binaryBody ? E.audioStream.write(v.binaryBody) : E.endAudioStream(); 13347 } catch { 13348 } 13349 } 13350 S = !0; 13351 break; 13352 case "response": 13353 this.handleResponseMessage(v), S = !0; 13354 break; 13355 } 13356 const l = new r.Deferred(); 13357 return l.resolve(S), l.promise; 13358 } 13359 // Cancels recognition. 13360 async cancelRecognition(v, f, m, S, l) { 13361 if (this.terminateMessageLoop = !0, this.privRequestSession.isRecognizing && await this.privRequestSession.onStopRecognizing(
13361), this.privDialogServiceConnector.canceled) { 13362 const g = new p.PropertyCollection(); 13363 g.setProperty(n.CancellationErrorCodePropertyName, p.CancellationErrorCode[S]); 13364 const C = new p.SpeechRecognitionCanceledEventArgs(m, l, S, void 0, v); 13365 try { 13366 this.privDialogServiceConnector.canceled(this.privDialogServiceConnector, C); 13367 } catch { 13368 } 13369 if (this.privSuccessCallback) { 13370 const y = new p.SpeechRecognitionResult( 13371 void 0, 13372 // ResultId 13373 p.ResultReason.Canceled, 13374 void 0, 13375 // Text 13376 void 0, 13377 // Duration 13378 void 0, 13379 // Offset 13380 void 0, 13381 // Language 13382 void 0, 13383 // Language Detection Confidence 13384 void 0, 13385 // Speaker Id 13386 l, 13387 void 0, 13388 // Json 13389 g 13390 ); 13391 try { 13392 this.privSuccessCallback(y), this.privSuccessCallback = void 0; 13393 } catch { 13394 } 13395 } 13396 } 13397 } 13398 async listenOnce(v, f, m) { 13399 this.privRecognizerConfig.recognitionMode = v, this.privSuccessCallback = f, this.privErrorCallback = m, this.privRequestSession.startNewRecognition(), this.privRequestSession.listenForServiceTelemetry(this.privDialogAudioSource.events), this.privRecognizerConfig.parameters.setProperty(p.PropertyId.Speech_SessionId, this.privRequestSession.sessionId); 13400 const S = this.connectImpl(), l = this.sendPreAudioMessages(), g = await this.privDialogAudioSource.attach(this.privRequestSession.audioNodeId), C = await this.privDialogAudioSource.format, y = await this.privDialogAudioSource.deviceInfo, P = new t.ReplayableAudioNode(g, C.avgBytesPerSec); 13401 await this.privRequestSession.onAudioSourceAttachCompleted(P, !1), this.privRecognizerConfig.SpeechServiceConfig.Context.audio = { source: y };
13402 try { 13403 await S, await l; 13404 } catch (E) { 13405 return await this.cancelRecognition(this.privRequestSession.sessionId, this.privRequestSession.requestId, p.CancellationReason.Error, p.CancellationErrorCode.ConnectionFailure, E), Promise.resolve(); 13406 } 13407 const T = new p.SessionEventArgs(this.privRequestSession.sessionId); 13408 this.privRecognizer.sessionStarted && this.privRecognizer.sessionStarted(this.privRecognizer, T), this.sendAudio(P).then(() => { 13409 }, async (E) => { 13410 await this.cancelRecognition(this.privRequestSession.sessionId, this.privRequestSession.requestId, p.CancellationReason.Error, p.CancellationErrorCode.RuntimeError, E); 13411 }); 13412 } 13413 // Establishes a websocket connection to the end point. 13414 dialogConnectImpl(v) { 13415 return this.privConnectionLoop = this.startMessageLoop(), v; 13416 } 13417 receiveDialogMessageOverride() { 13418 const v = new r.Deferred(), f = async () => { 13419 try { 13420 const m = this.isDisposed(), S = !this.isDisposed() && this.terminateMessageLoop; 13421 if (m || S) { 13422 v.resolve(void 0); 13423 return; 13424 } 13425 const g = await (await this.fetchConnection()).read(); 13426 if (!g) 13427 return f(); 13428 const C = u.SpeechConnectionMessage.fromConnectionMessage(g); 13429 switch (C.path.toLowerCase()) { 13430 case "turn.start": 13431 { 13432 const L = C.requestId.toUpperCase(), ne = this.privRequestSession.requestId.toUpperCase(); 13433 L !== ne ? this.privTurnStateManager.StartTurn(L) : this.privRequestSession.onServiceTurnStartResponse(); 13434 } 13435 break; 13436 case "speech.startdetected": 13437 const P = n.SpeechDetected.fromJSON(C.textBody, this.privRequestSession.currentTurnAudioOffset), T = new p.RecognitionEventArgs(P.Offset, this.privRequestSession.sessionId); 13438 this.privRecognizer.speechStartDetected && this.privRecognizer.speechStartDetected(this.privRecognizer, T); 13439 break; 13440 case "speech.enddetected": 13441 let _; 13442 C.textBody.length > 0 ? _ = C.textBody : _ = "{ Offset: 0 }"; 13443 const E = n.SpeechDetected.fromJSON(_, this.privRequestSession.currentTurnAudioOffset); 13444 this.privRequestSession.onServiceRecognized(E.Offset); 13445 const z = new p.RecognitionEventArgs(E.Offset, this.privRequestSession.sessionId); 13446 this.privRecognizer.speechEndDetected && this.privRecognizer.speechEndDetected(this.privRecognizer, z); 13447 break; 13448 case "turn.end": 13449 { 13450 const L = C.requestId.toUpperCase(), ne = this.privRequestSession.requestId.toUpperCase(); 13451 if (L !== ne) 13452 this.privTurnStateManager.CompleteTurn(L); 13453 else { 13454 const We = new p.SessionEventArgs(this.privRequestSession.sessionId); 13455 if (await this.privRequestSession.onServiceTurnEndResponse(!1), (!this.privRecognizerConfig.isContinuousRecognition || this.privRequestSession.isSpeechEnded || !this.privRequestSession.isRecognizing) && this.privRecognizer.sessionStopped && this.privRecognizer.sessionStopped(this.privRecognizer, We), this.privSuccessCallback && this.privLastResult) { 13456 try { 13457 this.privSuccessCallback(this.privLastResult), this.privLastResult = null; 13458 } catch (Z) { 13459 this.privErrorCallback && this.privErrorCallback(Z); 13460 } 13461 this.privSuccessCallback = void 0, this.privErrorCallback = void 0; 13462 } 13463 } 13464 } 13465 break; 13466 default: 13467 try { 13468 await this.processTypeSpecificMessages(C) || this.serviceEvents && this.serviceEvents.onEvent(new r.ServiceEvent(C.path.toLowerCase(), C.textBody)); 13469 } catch { 13470 } 13471 } 13472 return f(); 13473 } catch { 13474 this.terminateMessageLoop = !0, v.resolve(); 13475 } 13476 }; 13477 return f().catch((m) => {
13478 r.Events.instance.onEvent(new r.BackgroundEvent(m)); 13479 }), v.promise; 13480 } 13481 async startMessageLoop() { 13482 this.terminateMessageLoop = !1; 13483 try { 13484 await this.receiveDialogMessageOverride(); 13485 } catch (v) { 13486 await this.cancelRecognition(this.privRequestSession.sessionId, this.privRequestSession.requestId, p.CancellationReason.Error, p.CancellationErrorCode.RuntimeError, v); 13487 } 13488 return Promise.resolve(); 13489 } 13490 // Takes an established websocket connection to the endpoint and sends speech configuration information. 13491 async configConnection(v) { 13492 return this.terminateMessageLoop ? (this.terminateMessageLoop = !1, Promise.reject("Connection to service terminated.")) : (await this.sendSpeechServiceConfig(v, this.privRequestSession, this.privRecognizerConfig.SpeechServiceConfig.serialize()), await this.sendAgentConfig(v), v); 13493 } 13494 async sendPreAudioMessages() { 13495 const v = await this.fetchConnection(); 13496 this.addKeywordContextData(), await this.sendSpeechContext(v, !0), await this.sendAgentContext(v), await this.sendWaveHeader(v); 13497 } 13498 sendAgentConfig(v) { 13499 if (this.agentConfig && !this.agentConfigSent) { 13500 if (this.privRecognizerConfig.parameters.getProperty(p.PropertyId.Conversation_DialogType) === p.DialogServiceConfig.DialogTypes.CustomCommands) { 13501 const m = this.agentConfig.get(); 13502 m.botInfo.commandsCulture = this.privRecognizerConfig.parameters.getProperty(p.PropertyId.SpeechServiceConnection_RecoLanguage, "en-us"), this.agentConfig.set(m); 13503 } 13504 this.onEvent(new e.SendingAgentContextMessageEvent(this.agentConfig)); 13505 const f = this.agentConfig.toJsonString(); 13506 return this.agentConfigSent = !0, v.send(new u.SpeechConnectionMessage(r.MessageType.Text, "agent.config", this.privRequestSession.requestId, "application/json", f)); 13507 } 13508 } 13509 sendAgentContext(v) { 13510 const f = (0, r.createGuid)(), m = this.privDialogServiceConnector.properties.getProperty(p.PropertyId.Conversation_Speech_Activity_Template), l = JSON.stringify({ 13511 channelData: "", 13512 context: { 13513 interactionId: f 13514 }, 13515 messagePayload: typeof m === void 0 ? void 0 : m, 13516 version: 0.5 13517 }); 13518 return v.send(new u.SpeechConnectionMessage(r.MessageType.Text, "speech.agent.context", this.privRequestSession.requestId, "application/json", l)); 13519 } 13520 fireEventForResult(v, f) { 13521 const m = n.EnumTranslation.implTranslateRecognitionResult(v.RecognitionStatus), S = new p.SpeechRecognitionResult(this.privRequestSession.requestId, m, v.DisplayText, v.Duration, v.Offset, v.Language, v.LanguageDetectionConfidence, void 0, void 0, v.asJson(), f); 13522 return new p.SpeechRecognitionEventArgs(S, v.Offset, this.privRequestSession.sessionId); 13523 } 13524 handleResponseMessage(v) { 13525 const f = JSON.parse(v.textBody); 13526 switch (f.messageType.toLowerCase()) { 13527 case "message": 13528 const m = v.requestId.toUpperCase(), S = i.ActivityPayloadResponse.fromJSON(v.textBody), l = this.privTurnStateManager.GetTurn(m); 13529 if (S.conversationId) { 13530 const y = this.agentConfig.get(); 13531 y.botInfo.conversationId = S.conversationId, this.agentConfig.set(y); 13532 } 13533 const g = l.processActivityPayload(S, s.AudioOutputFormatImpl.fromSpeechSynthesisOutputFormatString(this.privDialogServiceConnector.properties.getProperty(p.PropertyId.SpeechServiceConnection_SynthOutputFormat, void 0))), C = new p.ActivityReceivedEventArgs(S.messagePayload, g); 13534 if (this.privDialogServiceConnector.activityReceived) 13535 try { 13536 this.privDialogServiceConnector.activityReceived(this.privDialogServiceConnector, C); 13537 } catch { 13538 } 13539 break; 13540 case "messagestatus": 13541 if (this.privDialogServiceConnector.turnStatusReceived) 13542 try { 13543 this.privDialogServiceConnector.turnStatusReceived(this.privDialogServiceConnector, new p.TurnStatusReceivedEventArgs(v.textBody)); 13544 } catch { 13545 } 13546 break; 13547 default:
13548 r.Events.instance.onEvent(new r.BackgroundEvent(`Unexpected response of type ${f.messageType}. Ignoring.`)); 13549 break; 13550 } 13551 } 13552 onEvent(v) { 13553 this.privEvents.onEvent(v), r.Events.instance.onEvent(v); 13554 } 13555 addKeywordContextData() { 13556 const v = this.privRecognizerConfig.parameters.getProperty("SPEECH-KeywordsToDetect"); 13557 if (v === void 0) 13558 return; 13559 const f = this.privRecognizerConfig.parameters.getProperty("SPEECH-KeywordsToDetect-Offsets"), m = this.privRecognizerConfig.parameters.getProperty("SPEECH-KeywordsToDetect-Durations"), S = v.split(";"), l = f === void 0 ? [] : f.split(";"), g = m === void 0 ? [] : m.split(";"), C = []; 13560 for (let y = 0; y < S.length; y++) { 13561 const P = { 13562 text: S[y] 13563 }; 13564 y < l.length && (P.startOffset = Number(l[y])), y < g.length && (P.duration = Number(g[y])), C.push(P); 13565 } 13566 this.speechContext.getContext().invocationSource = o.InvocationSource.VoiceActivationWithKeyword, this.speechContext.getContext().keywordDetection = [{ 13567 clientDetectedKeywords: C, 13568 onReject: { action: c.OnRejectAction.EndOfTurn }, 13569 type: c.KeywordDetectionType.StartTrigger 13570 }]; 13571 } 13572 }; 13573 return dr.DialogServiceAdapter = h, dr; 13574} 13575var $i = {}; 13576Object.defineProperty($i, "__esModule", { value: !0 }); 13577$i.AgentConfig = void 0; 13578class Ml { 13579 toJsonString() { 13580 return JSON.stringify(this.iPrivConfig); 13581 } 13582 get() { 13583 return this.iPrivConfig; 13584 } 13585 /** 13586 * Setter for the agent.config object. 13587 * @param value a JSON serializable object. 13588 */ 13589 set(e) { 13590 this.iPrivConfig = e; 13591 } 13592} 13593$i.AgentConfig = Ml; 13594var En = {}, vr = {}, Ye = {}; 13595Object.defineProperty(Ye, "__esModule", { value: !0 }); 13596Ye.ConversationConnectionConfig = void 0; 13597const Ol = Br; 13598class X extends Ol.RestConfigBase { 13599 static get host() { 13600 return X.privHost; 13601 } 13602 static get apiVersion() { 13603 return X.privApiVersion; 13604 } 13605 static get clientAppId() { 13606 return X.privClientAppId; 13607 } 13608 static get defaultLanguageCode() { 13609 return X.privDefaultLanguageCode; 13610 } 13611 static get restPath() { 13612 return X.privRestPath; 13613 } 13614 static get webSocketPath() { 13615 return X.privWebSocketPath; 13616 } 13617 static get transcriptionEventKeys() { 13618 return X.privTranscriptionEventKeys; 13619 } 13620} 13621Ye.ConversationConnectionConfig = X; 13622X.privHost = "dev.microsofttranslator.com"; 13623X.privRestPath = "/capito/room"; 13624X.privApiVersion = "2.0"; 13625X.privDefaultLanguageCode = "en-US"; 13626X.privClientAppId = "FC539C22-1767-4F1F-84BC-B4D811114F15"; 13627X.privWebSocketPath = "/capito/translate"; 13628X.privTranscriptionEventKeys = ["iCalUid", "callId", "organizer", "FLAC", "MTUri", "DifferentiateGuestSpeakers", "audiorecording", "Threadid", "OrganizerMri", "OrganizerTenantId", "UserToken"]; 13629var ea; 13630function Dl() { 13631 if (ea) return vr; 13632 ea = 1, Object.defineProperty(vr, "__esModule", { value: !0 }), vr.ConversationManager = void 0; 13633 const t = re(), e = O, r = R(), s = Ye; 13634 let p = class { 13635 constructor() {
13636 this.privRequestParams = s.ConversationConnectionConfig.configParams, this.privErrors = s.ConversationConnectionConfig.restErrors, this.privHost = s.ConversationConnectionConfig.host, this.privApiVersion = s.ConversationConnectionConfig.apiVersion, this.privRestPath = s.ConversationConnectionConfig.restPath, this.privRestAdapter = new t.RestMessageAdapter({}); 13637 } 13638 /** 13639 * Make a POST request to the Conversation Manager service endpoint to create or join a conversation. 13640 * @param args 13641 * @param conversationCode 13642 * @param callback 13643 * @param errorCallback 13644 */ 13645 createOrJoin(n, i, o, c) { 13646 try { 13647 e.Contracts.throwIfNullOrUndefined(n, "args"); 13648 const u = n.getProperty(r.PropertyId.SpeechServiceConnection_RecoLanguage, s.ConversationConnectionConfig.defaultLanguageCode), h = n.getProperty(r.PropertyId.ConversationTranslator_Name, "conversation_host"), d = n.getProperty(r.PropertyId.ConversationTranslator_Host, this.privHost), v = n.getProperty(r.PropertyId.ConversationTranslator_CorrelationId), f = n.getProperty(r.PropertyId.SpeechServiceConnection_Key), m = n.getProperty(r.PropertyId.SpeechServiceConnection_Region), S = n.getProperty(r.PropertyId.SpeechServiceAuthorization_Token); 13649 e.Contracts.throwIfNullOrWhitespace(u, "languageCode"), e.Contracts.throwIfNullOrWhitespace(h, "nickname"), e.Contracts.throwIfNullOrWhitespace(d, "endpointHost"); 13650 const l = {};
13651 l[this.privRequestParams.apiVersion] = this.privApiVersion, l[this.privRequestParams.languageCode] = u, l[this.privRequestParams.nickname] = h; 13652 const g = {}; 13653 v && (g[this.privRequestParams.correlationId] = v), g[this.privRequestParams.clientAppId] = s.ConversationConnectionConfig.clientAppId, i !== void 0 ? l[this.privRequestParams.roomId] = i : (e.Contracts.throwIfNullOrUndefined(m, this.privErrors.authInvalidSubscriptionRegion), g[this.privRequestParams.subscriptionRegion] = m, f ? g[this.privRequestParams.subscriptionKey] = f : S ? g[this.privRequestParams.authorization] = `Bearer ${S}` : e.Contracts.throwIfNullOrUndefined(f, this.privErrors.authInvalidSubscriptionKey)); 13654 const C = {}; 13655 C.headers = g, this.privRestAdapter.options = C; 13656 const y = `https://${d}${this.privRestPath}`; 13657 this.privRestAdapter.request(t.RestRequestType.Post, y, l, null).then((P) => { 13658 const T = t.RestMessageAdapter.extractHeaderValue(this.privRequestParams.requestId, P.headers); 13659 if (!P.ok) { 13660 if (c) { 13661 let E = this.privErrors.invalidCreateJoinConversationResponse.replace("{status}", P.status.toString()), z; 13662 try { 13663 z = JSON.parse(P.data), E += ` [${z.error.code}: ${z.error.message}]`; 13664 } catch { 13665 E += ` [${P.data}]`; 13666 } 13667 T && (E += ` ${T}`), c(E); 13668 } 13669 return; 13670 } 13671 const _ = JSON.parse(P.data); 13672 if (_ && (_.requestId = T), o) { 13673 try { 13674 o(_); 13675 } catch (E) { 13676 c && c(E); 13677 } 13678 o = void 0; 13679 } 13680 }).catch(() => { 13681 }); 13682 } catch (u) { 13683 if (c) 13684 if (u instanceof Error) { 13685 const h = u; 13686 c(h.name + ": " + h.message); 13687 } else 13688 c(u); 13689 } 13690 } 13691 /** 13692 * Make a DELETE request to the Conversation Manager service endpoint to leave the conversation. 13693 * @param args 13694 * @param sessionToken 13695 * @param callback 13696 */ 13697 leave(n, i) { 13698 return new Promise((o, c) => { 13699 try { 13700 e.Contracts.throwIfNullOrUndefined(n, this.privErrors.invalidArgs.replace("{arg}", "config")), e.Contracts.throwIfNullOrWhitespace(i, this.privErrors.invalidArgs.replace("{arg}", "token")); 13701 const u = n.getProperty(r.PropertyId.ConversationTranslator_Host, this.privHost), h = n.getProperty(r.PropertyId.ConversationTranslator_CorrelationId), d = {};
13702 d[this.privRequestParams.apiVersion] = this.privApiVersion, d[this.privRequestParams.sessionToken] = i; 13703 const v = {}; 13704 h && (v[this.privRequestParams.correlationId] = h); 13705 const f = {}; 13706 f.headers = v, this.privRestAdapter.options = f; 13707 const m = `https://${u}${this.privRestPath}`; 13708 this.privRestAdapter.request(t.RestRequestType.Delete, m, d, null).then((S) => { 13709 S.ok, o(); 13710 }).catch(() => { 13711 }); 13712 } catch (u) { 13713 if (u instanceof Error) { 13714 const h = u; 13715 c(h.name + ": " + h.message); 13716 } else 13717 c(u); 13718 } 13719 }); 13720 } 13721 }; 13722 return vr.ConversationManager = p, vr; 13723} 13724var Le = {}, lr = {}, en = {}, qr = {}; 13725Object.defineProperty(qr, "__esModule", { value: !0 }); 13726qr.ConversationConnectionMessage = void 0; 13727const kl = I(); 13728class Nl extends kl.ConnectionMessage { 13729 constructor(e, r, s, p) { 13730 super(e, r, s, p); 13731 const a = JSON.parse(this.textBody); 13732 a.type !== void 0 && (this.privConversationMessageType = a.type); 13733 } 13734 get conversationMessageType() { 13735 return this.privConversationMessageType; 13736 } 13737} 13738qr.ConversationConnectionMessage = Nl; 13739Object.defineProperty(en, "__esModule", { value: !0 }); 13740en.ConversationWebsocketMessageFormatter = void 0; 13741const Be = I(), ta = qr; 13742class zl { 13743 /** 13744 * Format incoming messages: text (speech partial/final, IM) or binary (tts) 13745 */ 13746 toConnectionMessage(e) { 13747 const r = new Be.Deferred(); 13748 try { 13749 if (e.messageType === Be.MessageType.Text) { 13750 const s = new ta.ConversationConnectionMessage(e.messageType, e.textContent, {}, e.id); 13751 r.resolve(s); 13752 } else e.messageType === Be.MessageType.Binary && r.resolve(new ta.ConversationConnectionMessage(e.messageType, e.binaryContent, void 0, e.id)); 13753 } catch (s) { 13754 r.reject(`Error formatting the message. Error: ${s}`); 13755 } 13756 return r.promise; 13757 } 13758 /** 13759 * Format outgoing messages: text (commands or IM) 13760 */ 13761 fromConnectionMessage(e) { 13762 const r = new Be.Deferred(); 13763 try { 13764 if (e.messageType === Be.MessageType.Text) { 13765 const s = `${e.textBody ? e.textBody : ""}`; 13766 r.resolve(new Be.RawWebsocketMessage(Be.MessageType.Text, s, e.id)); 13767 } 13768 } catch (s) { 13769 r.reject(`Error formatting the message. ${s}`); 13770 } 13771 return r.promise; 13772 } 13773} 13774en.ConversationWebsocketMessageFormatter = zl; 13775var ra; 13776function jl() { 13777 if (ra) return lr; 13778 ra = 1, Object.defineProperty(lr, "__esModule", { value: !0 }), lr.ConversationConnectionFactory = void 0; 13779 const t = re(), e = I(), r = O, s = R(), p = Se(), a = Ye, n = en; 13780 let i = class extends p.ConnectionFactoryBase { 13781 create(c, u, h) { 13782 const d = c.parameters.getProperty(s.PropertyId.ConversationTranslator_Host, a.ConversationConnectionConfig.host), v = c.parameters.getProperty(s.PropertyId.ConversationTranslator_CorrelationId, (0, e.createGuid)()), f = `wss://${d}${a.ConversationConnectionConfig.webSocketPath}`, m = c.parameters.getProperty(s.PropertyId.ConversationTranslator_Token, void 0); 13783 r.Contracts.throwIfNullOrUndefined(m, "token"); 13784 const S = {}; 13785 S[a.ConversationConnectionConfig.configParams.apiVersion] = a.ConversationConnectionConfig.apiVersion, S[a.ConversationConnectionConfig.configParams.token] = m, S[a.ConversationConnectionConfig.configParams.correlationId] = v; 13786 const l = c.parameters.getProperty("SPEECH-EnableWebsocketCompression", "false") === "true"; 13787 return Promise.resolve(new t.WebsocketConnection(f, S, {}, new n.ConversationWebsocketMessageFormatter(), t.ProxyInfo.fromRecognizerConfig(c), l, h)); 13788 } 13789 }; 13790 return lr.ConversationConnectionFactory = i, lr; 13791} 13792var fr = {}, tn = {}; 13793Object.defineProperty(tn, "__esModule", { value: !0 }); 13794tn.ConversationRequestSession = void 0; 13795const Tn = I(); 13796class Ll { 13797 constructor(e) { 13798 this.privIsDisposed = !1, this.privDetachables = new Array(), this.privSessionId = e, this.privRequestId = (0, Tn.createNoDashGuid)(), this.privRequestCompletionDeferral = new Tn.Deferred(); 13799 } 13800 get sessionId() { 13801 return this.privSessionId; 13802 } 13803 get requestId() { 13804 return this.privRequestId; 13805 } 13806 get completionPromise() { 13807 return this.privRequestCompletionDeferral.promise; 13808 } 13809 onPreConnectionStart(e, r) { 13810 this.privSessionId = r; 13811 } 13812 onAuthCompleted(e) { 13813 e && this.onComplete(); 13814 } 13815 onConnectionEstablishCompleted(e) { 13816 e !== 200 && e === 403 && this.onComplete(); 13817 } 13818 onServiceTurnEndResponse(e) { 13819 e ? this.privRequestId = (0, Tn.createNoDashGuid)() : this.onComplete(); 13820 } 13821 async dispose() { 13822 if (!this.privIsDisposed) { 13823 this.privIsDisposed = !0; 13824 for (const e of this.privDetachables) 13825 await e.detach(); 13826 } 13827 } 13828 onComplete() { 13829 } 13830} 13831tn.ConversationRequestSession = Ll; 13832var $ = {}, ia;
13833function Jc() { 13834 if (ia) return $; 13835 ia = 1, Object.defineProperty($, "__esModule", { value: !0 }), $.ConversationReceivedTranslationEventArgs = $.ParticipantsListEventArgs = $.ParticipantAttributeEventArgs = $.ParticipantEventArgs = $.LockRoomEventArgs = $.MuteAllEventArgs = void 0; 13836 const t = R(); 13837 class e extends t.SessionEventArgs { 13838 constructor(o, c) { 13839 super(c), this.privIsMuted = o; 13840 } 13841 get isMuted() { 13842 return this.privIsMuted; 13843 } 13844 } 13845 $.MuteAllEventArgs = e; 13846 class r extends t.SessionEventArgs { 13847 constructor(o, c) { 13848 super(c), this.privIsLocked = o; 13849 } 13850 get isMuted() { 13851 return this.privIsLocked; 13852 } 13853 } 13854 $.LockRoomEventArgs = r; 13855 class s extends t.SessionEventArgs { 13856 constructor(o, c) { 13857 super(c), this.privParticipant = o; 13858 } 13859 get participant() { 13860 return this.privParticipant; 13861 } 13862 } 13863 $.ParticipantEventArgs = s; 13864 class p extends t.SessionEventArgs { 13865 constructor(o, c, u, h) { 13866 super(h), this.privKey = c, this.privValue = u, this.privParticipantId = o; 13867 } 13868 get value() { 13869 return this.privValue; 13870 } 13871 get key() { 13872 return this.privKey; 13873 } 13874 get id() { 13875 return this.privParticipantId; 13876 } 13877 } 13878 $.ParticipantAttributeEventArgs = p; 13879 class a extends t.SessionEventArgs { 13880 constructor(o, c, u, h, d, v, f, m, S) { 13881 super(S), this.privRoomId = o, this.privSessionToken = c, this.privTranslateTo = u, this.privProfanityFilter = h, this.privRoomProfanityFilter = d, this.privIsRoomLocked = v, this.privIsRoomLocked = f, this.privParticipants = m; 13882 } 13883 get sessionToken() { 13884 return this.privSessionToken; 13885 } 13886 get conversationId() { 13887 return this.privRoomId; 13888 } 13889 get translateTo() { 13890 return this.privTranslateTo; 13891 } 13892 get profanityFilter() { 13893 return this.privProfanityFilter; 13894 } 13895 get roomProfanityFilter() { 13896 return this.privRoomProfanityFilter; 13897 } 13898 get isRoomLocked() { 13899 return this.privIsRoomLocked; 13900 } 13901 get isMuteAll() { 13902 return this.privIsMuteAll; 13903 } 13904 get participants() { 13905 return this.privParticipants; 13906 } 13907 } 13908 $.ParticipantsListEventArgs = a; 13909 class n { 13910 constructor(o, c, u) { 13911 this.privPayload = c, this.privCommand = o, this.privSessionId = u; 13912 } 13913 get payload() { 13914 return this.privPayload; 13915 } 13916 get command() { 13917 return this.privCommand; 13918 } 13919 get sessionId() { 13920 return this.privSessionId; 13921 } 13922 } 13923 return $.ConversationReceivedTranslationEventArgs = n, $; 13924} 13925var ge = {}; 13926Object.defineProperty(ge, "__esModule", { value: !0 }); 13927ge.ConversationTranslatorCommandTypes = ge.ConversationTranslatorMessageTypes = ge.InternalParticipants = void 0; 13928class Bl { 13929 constructor(e = [], r) { 13930 this.participants = e, this.meId = r; 13931 } 13932 /** 13933 * Add or update a participant 13934 * @param value 13935 */ 13936 addOrUpdateParticipant(e) { 13937 if (e === void 0) 13938 return; 13939 const r = this.getParticipantIndex(e.id); 13940 return r > -1 ? this.participants.splice(r, 1, e) : this.participants.push(e), this.getParticipant(e.id); 13941 } 13942 /** 13943 * Find the participant's position in the participants list. 13944 * @param id 13945 */ 13946 getParticipantIndex(e) { 13947 return this.participants.findIndex((r) => r.id === e); 13948 } 13949 /** 13950 * Find the participant by id. 13951 * @param id 13952 */ 13953 getParticipant(e) { 13954 return this.participants.find((r) => r.id === e); 13955 } 13956 /** 13957 * Remove a participant from the participants list. 13958 */ 13959 deleteParticipant(e) { 13960 this.participants = this.participants.filter((r) => r.id !== e); 13961 } 13962 /** 13963 * Helper to return the conversation host. 13964 */ 13965 get host() { 13966 return this.participants.find((e) => e.isHost === !0); 13967 } 13968 /** 13969 * Helper to return the current user. 13970 */ 13971 get me() { 13972 return this.getParticipant(this.meId); 13973 } 13974} 13975ge.InternalParticipants = Bl; 13976ge.ConversationTranslatorMessageTypes = { 13977 command: "command", 13978 final: "final", 13979 info: "info", 13980 instantMessage: "instant_message", 13981 keepAlive: "keep_alive", 13982 partial: "partial", 13983 participantCommand: "participant_command", 13984 translatedMessage: "translated_message" 13985}; 13986ge.ConversationTranslatorCommandTypes = { 13987 changeNickname: "ChangeNickname", 13988 disconnectSession: "DisconnectSession", 13989 ejectParticipant: "EjectParticipant", 13990 instant_message: "instant_message", 13991 joinSession: "JoinSession", 13992 leaveSession: "LeaveSession", 13993 participantList: "ParticipantList", 13994 roomExpirationWarning: "RoomExpirationWarning", 13995 setLockState: "SetLockState", 13996 setMute: "SetMute", 13997 setMuteAll: "SetMuteAll", 13998 setProfanityFiltering: "SetProfanityFiltering", 13999 setTranslateToLanguages: "SetTranslateToLanguages", 14000 setUseTTS: "SetUseTTS" 14001}; 14002var Vc = {}, rn = {}; 14003Object.defineProperty(rn, "__esModule", { value: !0 }); 14004rn.CommandResponsePayload = void 0; 14005const ql = (t) => JSON.parse(t); 14006class Zn { 14007 constructor(e) { 14008 this.privCommandResponse = ql(e); 14009 } 14010 get type() { 14011 return this.privCommandResponse.type; 14012 } 14013 get command() { 14014 return this.privCommandResponse.command; 14015 } 14016 get id() { 14017 return this.privCommandResponse.id; 14018 } 14019 get nickname() { 14020 return this.privCommandResponse.nickname; 14021 } 14022 get participantId() { 14023 return this.privCommandResponse.participantId; 14024 } 14025 get roomid() { 14026 return this.privCommandResponse.roomid; 14027 } 14028 get value() { 14029 return this.privCommandResponse.value; 14030 } 14031 get token() { 14032 return this.privCommandResponse.token; 14033 } 14034 static fromJSON(e) { 14035 return new Zn(e); 14036 } 14037} 14038rn.CommandResponsePayload = Zn; 14039var Je = {}; 14040Object.defineProperty(Je, "__esModule", { value: !0 }); 14041Je.ParticipantPayloadResponse = Je.ParticipantsListPayloadResponse = void 0; 14042const Fl = (t) => JSON.parse(t), Ul = (t) => JSON.parse(t); 14043class $n { 14044 constructor(e) { 14045 this.privParticipantsPayloadResponse = Fl(e); 14046 } 14047 get roomid() { 14048 return this.privParticipantsPayloadResponse.roomid; 14049 } 14050 get id() { 14051 return this.privParticipantsPayloadResponse.id; 14052 } 14053 get command() { 14054 return this.privParticipantsPayloadResponse.command; 14055 } 14056 get participants() { 14057 return this.privParticipantsPayloadResponse.participants; 14058 } 14059 get token() { 14060 return this.privParticipantsPayloadResponse.token; 14061 } 14062 get translateTo() { 14063 return this.privParticipantsPayloadResponse.translateTo; 14064 } 14065 get profanityFilter() { 14066 return this.privParticipantsPayloadResponse.profanityFilter; 14067 } 14068 get roomProfanityFilter() { 14069 return this.privParticipantsPayloadResponse.roomProfanityFilter; 14070 } 14071 get roomLocked() { 14072 return this.privParticipantsPayloadResponse.roomLocked; 14073 } 14074 get muteAll() { 14075 return this.privParticipantsPayloadResponse.muteAll; 14076 } 14077 get type() { 14078 return this.privParticipantsPayloadResponse.type; 14079 } 14080 static fromJSON(e) { 14081 return new $n(e); 14082 } 14083} 14084Je.ParticipantsListPayloadResponse = $n; 14085class es { 14086 constructor(e) { 14087 this.privParticipantPayloadResponse = Ul(e); 14088 } 14089 get nickname() { 14090 return this.privParticipantPayloadResponse.nickname; 14091 } 14092 get locale() { 14093 return this.privParticipantPayloadResponse.locale; 14094 } 14095 get usetts() { 14096 return this.privParticipantPayloadResponse.usetts; 14097 } 14098 get ismuted() { 14099 return this.privParticipantPayloadResponse.ismuted; 14100 } 14101 get ishost() { 14102 return this.privParticipantPayloadResponse.ishost; 14103 } 14104 get participantId() { 14105 return this.privParticipantPayloadResponse.participantId; 14106 } 14107 get avatar() { 14108 return this.privParticipantPayloadResponse.avatar; 14109 } 14110 static fromJSON(e) { 14111 return new es(e); 14112 } 14113} 14114Je.ParticipantPayloadResponse = es; 14115var Ve = {}; 14116Object.defineProperty(Ve, "__esModule", { value: !0 }); 14117Ve.TextResponsePayload = Ve.SpeechResponsePayload = void 0; 14118const xl = (t) => JSON.parse(t), Wl = (t) => JSON.parse(t); 14119class ts { 14120 constructor(e) { 14121 this.privSpeechResponse = xl(e); 14122 } 14123 get recognition() { 14124 return this.privSpeechResponse.recognition; 14125 } 14126 get translations() { 14127 return this.privSpeechResponse.translations; 14128 } 14129 get id() { 14130 return this.privSpeechResponse.id; 14131 } 14132 get language() { 14133 return this.privSpeechResponse.language; 14134 } 14135 get nickname() { 14136 return this.privSpeechResponse.nickname; 14137 } 14138 get participantId() { 14139 return this.privSpeechResponse.participantId; 14140 } 14141 get roomid() { 14142 return this.privSpeechResponse.roomid; 14143 } 14144 get timestamp() { 14145 return this.privSpeechResponse.timestamp; 14146 } 14147 get type() { 14148 return this.privSpeechResponse.type; 14149 } 14150 get isFinal() { 14151 return this.privSpeechResponse.type === "final"; 14152 } 14153 static fromJSON(e) { 14154 return new ts(e); 14155 } 14156} 14157Ve.SpeechResponsePayload = ts; 14158class rs { 14159 constructor(e) { 14160 this.privTextResponse = Wl(e); 14161 } 14162 get originalText() { 14163 return this.privTextResponse.originalText; 14164 } 14165 get translations() { 14166 return this.privTextResponse.translations; 14167 } 14168 get id() { 14169 return this.privTextResponse.id; 14170 } 14171 get language() { 14172 return this.privTextResponse.language; 14173 } 14174 get nickname() { 14175 return this.privTextResponse.nickname; 14176 } 14177 get participantId() { 14178 return this.privTextResponse.participantId; 14179 } 14180 get roomid() { 14181 return this.privTextResponse.roomid; 14182 } 14183 get timestamp() { 14184 return this.privTextResponse.timestamp; 14185 } 14186 get type() { 14187 return this.privTextResponse.type; 14188 } 14189 static fromJSON(e) { 14190 return new rs(e); 14191 } 14192} 14193Ve.TextResponsePayload = rs; 14194(function(t) { 14195 Object.defineProperty(t, "__esModule", { value: !0 }), t.TextResponsePayload = t.SpeechResponsePayload = t.ParticipantPayloadResponse = t.ParticipantsListPayloadResponse = t.CommandResponsePayload = void 0; 14196 var e = rn; 14197 Object.defineProperty(t, "CommandResponsePayload", { enumerable: !0, get: function() { 14198 return e.CommandResponsePayload; 14199 } }); 14200 var r = Je; 14201 Object.defineProperty(t, "ParticipantsListPayloadResponse", { enumerable: !0, get: function() { 14202 return r.ParticipantsListPayloadResponse; 14203 } }), Object.defineProperty(t, "ParticipantPayloadResponse", { enumerable: !0, get: function() { 14204 return r.ParticipantPayloadResponse; 14205 } }); 14206 var s = Ve; 14207 Object.defineProperty(t, "SpeechResponsePayload", { enumerable: !0, get: function() { 14208 return s.SpeechResponsePayload; 14209 } }), Object.defineProperty(t, "TextResponsePayload", { enumerable: !0, get: function() { 14210 return s.TextResponsePayload; 14211 } }); 14212})(Vc); 14213var na; 14214function Hl() { 14215 if (na) return fr;
14216 na = 1, Object.defineProperty(fr, "__esModule", { value: !0 }), fr.ConversationServiceAdapter = void 0; 14217 const t = I(), e = R(), r = A(), s = qr, p = tn, a = Jc(), n = ge, i = Vc; 14218 let o = class extends r.ServiceRecognizerBase { 14219 constructor(u, h, d, v, f) { 14220 super(u, h, d, v, f), this.privConnectionConfigPromise = void 0, this.privLastPartialUtteranceId = "", this.privConversationServiceConnector = f, this.privConversationAuthentication = u, this.receiveMessageOverride = () => this.receiveConversationMessageOverride(), this.recognizeOverride = () => this.noOp(), this.postConnectImplOverride = (m) => this.conversationConnectImpl(m), this.configConnectionOverride = () => this.configConnection(), this.disconnectOverride = () => this.privDisconnect(), this.privConversationRequestSession = new p.ConversationRequestSession((0, t.createNoDashGuid)()), this.privConversationConnectionFactory = h, this.privConversationIsDisposed = !1; 14221 } 14222 isDisposed() { 14223 return super.isDisposed() || this.privConversationIsDisposed; 14224 } 14225 async dispose(u) { 14226 this.privConversationIsDisposed = !0, this.privConnectionConfigPromise !== void 0 && await (await this.privConnectionConfigPromise).dispose(u), await super.dispose(u); 14227 } 14228 async sendMessage(u) { 14229 return (await this.fetchConnection()).send(new s.ConversationConnectionMessage(t.MessageType.Text, u)); 14230 } 14231 async sendMessageAsync(u) { 14232 await (await this.fetchConnection()).send(new s.ConversationConnectionMessage(t.MessageType.Text, u)); 14233 } 14234 privDisconnect() { 14235 if (!this.terminateMessageLoop) 14236 return this.cancelRecognition(this.privConversationRequestSession.sessionId, this.privConversationRequestSession.requestId, e.CancellationReason.Error, e.CancellationErrorCode.NoError, "Disconnecting"), this.terminateMessageLoop = !0, Promise.resolve(); 14237 } 14238 // eslint-disable-next-line @typescript-eslint/require-await 14239 async processTypeSpecificMessages() { 14240 return !0; 14241 } 14242 // Cancels recognition. 14243 cancelRecognition(u, h, d, v, f) { 14244 this.terminateMessageLoop = !0; 14245 const m = new e.ConversationTranslationCanceledEventArgs(d, f, v, void 0, u);
14246 try { 14247 this.privConversationServiceConnector.canceled && this.privConversationServiceConnector.canceled(this.privConversationServiceConnector, m); 14248 } catch { 14249 } 14250 } 14251 /** 14252 * Establishes a websocket connection to the end point. 14253 */ 14254 async conversationConnectImpl(u) { 14255 return this.privConnectionLoop = this.startMessageLoop(), u; 14256 } 14257 /** 14258 * Process incoming websocket messages 14259 */ 14260 async receiveConversationMessageOverride() { 14261 if (this.isDisposed() || this.terminateMessageLoop) 14262 return Promise.resolve(); 14263 const u = new t.Deferred(); 14264 try { 14265 const d = await (await this.fetchConnection()).read(); 14266 if (this.isDisposed() || this.terminateMessageLoop) 14267 return u.resolve(), Promise.resolve(); 14268 if (!d) 14269 return this.receiveConversationMessageOverride(); 14270 const v = this.privConversationRequestSession.sessionId, f = d.conversationMessageType.toLowerCase(); 14271 let m = !1; 14272 try { 14273 switch (f) { 14274 case "info": 14275 case "participant_command": 14276 case "command": 14277 const S = i.CommandResponsePayload.fromJSON(d.textBody); 14278 switch (S.command.toLowerCase()) { 14279 case "participantlist": 14280 const T = i.ParticipantsListPayloadResponse.fromJSON(d.textBody), _ = T.participants.map((Z) => ({ 14281 avatar: Z.avatar, 14282 displayName: Z.nickname, 14283 id: Z.participantId, 14284 isHost: Z.ishost, 14285 isMuted: Z.ismuted, 14286 isUsingTts: Z.usetts, 14287 preferredLanguage: Z.locale 14288 })); 14289 this.privConversationServiceConnector.participantsListReceived && this.privConversationServiceConnector.participantsListReceived(this.privConversationServiceConnector, new a.ParticipantsListEventArgs(T.roomid, T.token, T.translateTo, T.profanityFilter, T.roomProfanityFilter, T.roomLocked, T.muteAll, _, v)); 14290 break; 14291 case "settranslatetolanguages": 14292 this.privConversationServiceConnector.participantUpdateCommandReceived && this.privConversationServiceConnector.participantUpdateCommandReceived(this.privConversationServiceConnector, new a.ParticipantAttributeEventArgs(S.participantId, n.ConversationTranslatorCommandTypes.setTranslateToLanguages, S.value, v)); 14293 break; 14294 case "setprofanityfiltering": 14295 this.privConversationServiceConnector.participantUpdateCommandReceived && this.privConversationServiceConnector.participantUpdateCommandReceived(this.privConversationServiceConnector, new a.ParticipantAttributeEventArgs(S.participantId, n.ConversationTranslatorCommandTypes.setProfanityFiltering, S.value, v)); 14296 break; 14297 case "setmute": 14298 this.privConversationServiceConnector.participantUpdateCommandReceived && this.privConversationServiceConnector.participantUpdateCommandReceived(this.privConversationServiceConnector, new a.ParticipantAttributeEventArgs(S.participantId, n.ConversationTranslatorCommandTypes.setMute, S.value, v)); 14299 break; 14300 case "setmuteall": 14301 this.privConversationServiceConnector.muteAllCommandReceived && this.privConversationServiceConnector.muteAllCommandReceived(this.privConversationServiceConnector, new a.MuteAllEventArgs(S.value, v)); 14302 break; 14303 case "roomexpirationwarning": 14304 this.privConversationServiceConnector.conversationExpiration && this.privConversationServiceConnector.conversationExpiration(this.privConversationServiceConnector, new e.ConversationExpirationEventArgs(S.value, this.privConversationRequestSession.sessionId)); 14305 break; 14306 case "setusetts": 14307 this.privConversationServiceConnector.participantUpdateCommandReceived && this.privConversationServiceConnector.participantUpdateCommandReceived(this.privConversationServiceConnector, new a.ParticipantAttributeEventArgs(S.participantId, n.
14307ConversationTranslatorCommandTypes.setUseTTS, S.value, v)); 14308 break; 14309 case "setlockstate": 14310 this.privConversationServiceConnector.lockRoomCommandReceived && this.privConversationServiceConnector.lockRoomCommandReceived(this.privConversationServiceConnector, new a.LockRoomEventArgs(S.value, v)); 14311 break; 14312 case "changenickname": 14313 this.privConversationServiceConnector.participantUpdateCommandReceived && this.privConversationServiceConnector.participantUpdateCommandReceived(this.privConversationServiceConnector, new a.ParticipantAttributeEventArgs(S.participantId, n.ConversationTranslatorCommandTypes.changeNickname, S.value, v)); 14314 break; 14315 case "joinsession": 14316 const E = i.ParticipantPayloadResponse.fromJSON(d.textBody), z = { 14317 avatar: E.avatar, 14318 displayName: E.nickname, 14319 id: E.participantId, 14320 isHost: E.ishost, 14321 isMuted: E.ismuted, 14322 isUsingTts: E.usetts, 14323 preferredLanguage: E.locale 14324 }; 14325 this.privConversationServiceConnector.participantJoinCommandReceived && this.privConversationServiceConnector.participantJoinCommandReceived(this.privConversationServiceConnector, new a.ParticipantEventArgs(z, v)); 14326 break; 14327 case "leavesession": 14328 const L = { 14329 id: S.participantId 14330 }; 14331 this.privConversationServiceConnector.participantLeaveCommandReceived && this.privConversationServiceConnector.participantLeaveCommandReceived(this.privConversationServiceConnector, new a.ParticipantEventArgs(L, v)); 14332 break; 14333 case "disconnectsession": 14334 const ne = { 14335 id: S.participantId 14336 }; 14337 break; 14338 case "token": 14339 const We = new r.CognitiveTokenAuthentication(() => { 14340 const Z = S.token; 14341 return Promise.resolve(Z); 14342 }, () => { 14343 const Z = S.token; 14344 return Promise.resolve(Z); 14345 }); 14346 this.authentication = We, this.privConversationServiceConnector.onToken(We); 14347 break; 14348 default: 14349 break; 14350 } 14351 break; 14352 case "partial": 14353 case "final": 14354 const l = i.SpeechResponsePayload.fromJSON(d.textBody), g = f === "final" ? e.ResultReason.TranslatedParticipantSpeech : e.ResultReason.TranslatingParticipantSpeech, C = new e.ConversationTranslationResult(l.participantId, this.getTranslations(l.translations), l.language, l.id, g, l.recognition, void 0, void 0, d.textBody, void 0); 14355 l.isFinal ? ((C.text !== void 0 && C.text.length > 0 || l.id === this.privLastPartialUtteranceId) && (m = !0), m && this.privConversationServiceConnector.translationReceived && this.privConversationServiceConnector.translationReceived(this.privConversationServiceConnector, new a.ConversationReceivedTranslationEventArgs(n.ConversationTranslatorMessageTypes.final, C, v))) : C.text !== void 0 && (this.privLastPartialUtteranceId = l.id, this.privConversationServiceConnector.translationReceived && this.privConversationServiceConnector.translationReceived(this.privConversationServiceConnector, new a.ConversationReceivedTranslationEventArgs(n.ConversationTranslatorMessageTypes.partial, C, v))); 14356 break; 14357 case "translated_message": 14358 const y = i.TextResponsePayload.fromJSON(d.textBody), P = new e.ConversationTranslationResult(y.participantId, this.getTranslations(y.translations), y.language, void 0, void 0, y.originalText, void 0, void 0, void 0, d.textBody, void 0); 14359 this.privConversationServiceConnector.translationReceived && this.privConversationServiceConnector.translationReceived(this.privConversationServiceConnector, new a.ConversationReceivedTranslationEventArgs(n.ConversationTranslatorMessageTypes.instantMessage, P, v)); 14360 break; 14361 default: 14362 break; 14363 } 14364 } catch { 14365 } 14366 return this.receiveConversationMessageOverride(); 14367 } catch { 14368 this.terminateMessageLoop = !0; 14369 } 14370 return u.promise; 14371 } 14372 async startMessageLoop() { 14373 if (this.isDisposed()) 14374 return Promise.resolve(); 14375 this.terminateMessageLoop = !1; 14376 const u = this.receiveConversationMessageOverride();
14377 try { 14378 return await u; 14379 } catch (h) { 14380 return this.cancelRecognition(this.privRequestSession ? this.privRequestSession.sessionId : "", this.privRequestSession ? this.privRequestSession.requestId : "", e.CancellationReason.Error, e.CancellationErrorCode.RuntimeError, h), null; 14381 } 14382 } 14383 // Takes an established websocket connection to the endpoint 14384 configConnection() { 14385 return this.isDisposed() ? Promise.resolve(void 0) : this.privConnectionConfigPromise !== void 0 ? this.privConnectionConfigPromise.then((u) => u.state() === t.ConnectionState.Disconnected ? (this.privConnectionId = null, this.privConnectionConfigPromise = void 0, this.configConnection()) : this.privConnectionConfigPromise, () => (this.privConnectionId = null, this.privConnectionConfigPromise = void 0, this.configConnection())) : this.terminateMessageLoop ? Promise.resolve(void 0) : (this.privConnectionConfigPromise = this.connectImpl().then((u) => u), this.privConnectionConfigPromise); 14386 } 14387 getTranslations(u) { 14388 let h; 14389 if (u !== void 0) { 14390 h = new e.Translations(); 14391 for (const d of u) 14392 h.set(d.lang, d.translation); 14393 } 14394 return h; 14395 } 14396 }; 14397 return fr.ConversationServiceAdapter = o, fr; 14398} 14399var sa; 14400function Kl() { 14401 if (sa) return Le; 14402 sa = 1, Object.defineProperty(Le, "__esModule", { value: !0 }), Le.ConversationTranslatorRecognizer = Le.ConversationRecognizerFactory = void 0; 14403 const t = A(), e = I(), r = O, s = R(), p = jl(), a = Hl(); 14404 class n { 14405 static fromConfig(c, u, h) { 14406 return new i(c, u, h); 14407 } 14408 } 14409 Le.ConversationRecognizerFactory = n; 14410 let i = class extends s.Recognizer { 14411 constructor(c, u, h) { 14412 const d = u; 14413 r.Contracts.throwIfNull(d, "speechConfig"); 14414 const v = c; 14415 r.Contracts.throwIfNull(v, "conversationImpl"), super(h, d.properties, new p.ConversationConnectionFactory()), this.privConversation = v, this.privIsDisposed = !1, this.privProperties = d.properties.clone(), this.privConnection = s.Connection.fromRecognizer(this), this.privProperties.getProperty(s.PropertyId.WebWorkerLoadType, "on").toLowerCase() === "on" && typeof Blob < "u" && typeof Worker < "u" ? (this.privSetTimeout = e.Timeout.setTimeout, this.privClearTimeout = e.Timeout.clearTimeout) : typeof window < "u" ? (this.privSetTimeout = window.setTimeout.bind(window), this.privClearTimeout = window.clearTimeout.bind(window)) : (this.privSetTimeout = setTimeout, this.privClearTimeout = clearTimeout); 14416 } 14417 set connected(c) { 14418 this.privConnection.connected = c; 14419 } 14420 set disconnected(c) { 14421 this.privConnection.disconnected = c; 14422 } 14423 /** 14424 * Return the speech language used by the recognizer 14425 */ 14426 get speechRecognitionLanguage() { 14427 return this.privSpeechRecognitionLanguage; 14428 } 14429 /** 14430 * Return the properties for the recognizer 14431 */ 14432 get properties() { 14433 return this.privProperties; 14434 } 14435 isDisposed() { 14436 return this.privIsDisposed; 14437 } 14438 /** 14439 * Connect to the recognizer 14440 * @param token 14441 */ 14442 connect(c, u, h) { 14443 try { 14444 r.Contracts.throwIfDisposed(this.privIsDisposed), r.Contracts.throwIfNullOrWhitespace(c, "token"), this.privReco.conversationTranslatorToken = c, this.resetConversationTimeout(), this.privReco.connectAsync(u, h); 14445 } catch (d) { 14446 if (h) 14447 if (d instanceof Error) { 14448 const v = d; 14449 h(v.name + ": " + v.message); 14450 } else 14451 h(d); 14452 } 14453 } 14454 /** 14455 * Disconnect from the recognizer 14456 */ 14457 disconnect(c, u) { 14458 try { 14459 r.Contracts.throwIfDisposed(this.privIsDisposed), this.privTimeoutToken !== void 0 && this.privClearTimeout(this.privTimeoutToken), this.privReco.disconnect().then(() => { 14460 c && c(); 14461 }, (h) => { 14462 u && u(h); 14463 }); 14464 } catch (h) { 14465 if (u) 14466 if (h instanceof Error) { 14467 const d = h; 14468 u(d.name + ": " + d.message); 14469 } else 14470 u(h); 14471 this.dispose(!0).catch((d) => {
14472 e.Events.instance.onEvent(new e.BackgroundEvent(d)); 14473 }); 14474 } 14475 } 14476 /** 14477 * Send the mute all participants command to the websocket 14478 * @param conversationId 14479 * @param participantId 14480 * @param isMuted 14481 */ 14482 sendRequest(c, u, h) { 14483 try { 14484 r.Contracts.throwIfDisposed(this.privIsDisposed), this.sendMessage(c, u, h); 14485 } catch (d) { 14486 if (h) 14487 if (d instanceof Error) { 14488 const v = d; 14489 h(v.name + ": " + v.message); 14490 } else 14491 h(d); 14492 this.dispose(!0).catch((v) => { 14493 e.Events.instance.onEvent(new e.BackgroundEvent(v)); 14494 }); 14495 } 14496 } 14497 /** 14498 * Handle update of service auth token (#694) 14499 */ 14500 onToken(c) { 14501 this.privConversation.onToken(c); 14502 } 14503 /** 14504 * Close and dispose the recognizer 14505 */ 14506 async close() { 14507 this.privIsDisposed || (this.privConnection && (this.privConnection.closeConnection(), this.privConnection.close()), this.privConnection = void 0, await this.dispose(!0)); 14508 } 14509 /** 14510 * Dispose the recognizer 14511 * @param disposing 14512 */ 14513 async dispose(c) { 14514 this.privIsDisposed || c && (this.privTimeoutToken !== void 0 && this.privClearTimeout(this.privTimeoutToken), this.privIsDisposed = !0, this.privConnection && (this.privConnection.closeConnection(), this.privConnection.close(), this.privConnection = void 0), await super.dispose(c)); 14515 } 14516 /** 14517 * Create the config for the recognizer 14518 * @param speechConfig 14519 */ 14520 createRecognizerConfig(c) { 14521 return new t.RecognizerConfig(c, this.privProperties); 14522 } 14523 /** 14524 * Create the service recognizer. 14525 * The audio source is redundnant here but is required by the implementation. 14526 * @param authentication 14527 * @param connectionFactory 14528 * @param audioConfig 14529 * @param recognizerConfig 14530 */ 14531 createServiceRecognizer(c, u, h, d) { 14532 const v = h; 14533 return new a.ConversationServiceAdapter(c, u, v, d, this); 14534 } 14535 sendMessage(c, u, h) { 14536 const d = this.privReco; 14537 ((f, m, S) => { 14538 f !== void 0 ? f.then(() => { 14539 try { 14540 m && m(); 14541 } catch (l) { 14542 S && S(`'Unhandled error on promise callback: ${l}'`); 14543 } 14544 }, (l) => { 14545 try { 14546 S && S(l); 14547 } catch { 14548 } 14549 }) : S && S("Null promise"); 14550 })(d.sendMessageAsync(c), u, h), this.resetConversationTimeout(); 14551 } 14552 resetConversationTimeout() { 14553 this.privTimeoutToken !== void 0 && this.privClearTimeout(this.privTimeoutToken), this.privTimeoutToken = this.privSetTimeout(() => { 14554 this.sendRequest(this.privConversation.getKeepAlive()); 14555 }, 6e4); 14556 } 14557 }; 14558 return Le.ConversationTranslatorRecognizer = i, Le; 14559} 14560var gr = {}, oa; 14561function Jl() { 14562 if (oa) return gr; 14563 oa = 1, Object.defineProperty(gr, "__esModule", { value: !0 }), gr.TranscriberRecognizer = void 0; 14564 const t = I(), e = O, r = R(), s = A(), p = ae; 14565 let a = class extends r.Recognizer { 14566 /** 14567 * TranscriberRecognizer constructor. 14568 * @constructor 14569 * @param {SpeechTranslationConfig} speechTranslationConfig - Non-audio configuration associated with the recognizer 14570 * @param {AudioConfig} audioConfig - An audio configuration associated with the recognizer 14571 */ 14572 constructor(i, o) { 14573 const c = i; 14574 e.Contracts.throwIfNull(c, "speechTranslationConfig"); 14575 const u = o; 14576 e.Contracts.throwIfNull(u, "audioConfigImpl"), e.Contracts.throwIfNullOrWhitespace(c.speechRecognitionLanguage, r.PropertyId[r.PropertyId.SpeechServiceConnection_RecoLanguage]), super(o, c.properties, new s.TranscriberConnectionFactory()), this.privDisposedRecognizer = !1, this.isMeetingRecognizer = !1; 14577 } 14578 get speechRecognitionLanguage() { 14579 return e.Contracts.throwIfDisposed(this.privDisposedRecognizer), this.properties.getProperty(r.PropertyId.SpeechServiceConnection_RecoLanguage); 14580 } 14581 get properties() { 14582 return this.privProperties; 14583 } 14584 get authorizationToken() { 14585 return this.properties.getProperty(r.PropertyId.SpeechServiceAuthorization_Token); 14586 } 14587 set authorizationToken(i) { 14588 e.Contracts.throwIfNullOrWhitespace(i, "token"), this.properties.setProperty(r.PropertyId.SpeechServiceAuthorization_Token, i); 14589 } 14590 set conversation(i) { 14591 e.Contracts.throwIfNullOrUndefined(i, "Conversation"), this.isMeetingRecognizer = !1, this.privConversation = i; 14592 } 14593 getConversationInfo() { 14594 return e.Contracts.throwIfNullOrUndefined(this.privConversation, "Conversation"), this.privConversation.conversationInfo; 14595 } 14596 set meeting(i) { 14597 e.Contracts.throwIfNullOrUndefined(i, "Meeting"), this.isMeetingRecognizer = !0, this.privMeeting = i; 14598 } 14599 getMeetingInfo() { 14600 return e.Contracts.throwIfNullOrUndefined(this.privMeeting, "Meeting"), this.privMeeting.meetingInfo; 14601 } 14602 IsMeetingRecognizer() { 14603 return this.isMeetingRecognizer; 14604 } 14605 startContinuousRecognitionAsync(i, o) { 14606 (0, t.marshalPromiseToCallbacks)(this.startContinuousRecognitionAsyncImpl(p.RecognitionMode.Conversation), i, o); 14607 } 14608 stopContinuousRecognitionAsync(i, o) { 14609 (0, t.marshalPromiseToCallbacks)(this.stopContinuousRecognitionAsyncImpl(), i, o); 14610 } 14611 async close() { 14612 this.privDisposedRecognizer || await this.dispose(!0); 14613 }
14614 // Push async join/leave conversation message via serviceRecognizer 14615 async pushConversationEvent(i, o) { 14616 const c = this.privReco; 14617 e.Contracts.throwIfNullOrUndefined(c, "serviceRecognizer"), await c.sendSpeechEventAsync(i, o); 14618 } 14619 // Push async join/leave meeting message via serviceRecognizer 14620 async pushMeetingEvent(i, o) { 14621 const c = this.privReco; 14622 e.Contracts.throwIfNullOrUndefined(c, "serviceRecognizer"), await c.sendMeetingSpeechEventAsync(i, o); 14623 } 14624 async enforceAudioGating() { 14625 const c = (await this.audioConfig.format).channels; 14626 if (c === 1) { 14627 if (this.properties.getProperty("f0f5debc-f8c9-4892-ac4b-90a7ab359fd2", "false").toLowerCase() !== "true") 14628 throw new Error("Single channel audio configuration for MeetingTranscriber is currently under private preview, please contact [email protected] for more details"); 14629 } else if (c !== 8) 14630 throw new Error(`Unsupported audio configuration: Detected ${c}-channel audio`); 14631 } 14632 connectMeetingCallbacks(i) { 14633 this.isMeetingRecognizer = !0, this.canceled = (o, c) => { 14634 i.canceled && i.canceled(i, c); 14635 }, this.recognizing = (o, c) => { 14636 i.transcribing && i.transcribing(i, c); 14637 }, this.recognized = (o, c) => { 14638 i.transcribed && i.transcribed(i, c); 14639 }, this.sessionStarted = (o, c) => { 14640 i.sessionStarted && i.sessionStarted(i, c); 14641 }, this.sessionStopped = (o, c) => { 14642 i.sessionStopped && i.sessionStopped(i, c); 14643 }; 14644 } 14645 disconnectCallbacks() { 14646 this.canceled = void 0, this.recognizing = void 0, this.recognized = void 0, this.sessionStarted = void 0, this.sessionStopped = void 0; 14647 } 14648 /** 14649 * Disposes any resources held by the object. 14650 * @member ConversationTranscriber.prototype.dispose 14651 * @function 14652 * @public 14653 * @param {boolean} disposing - true if disposing the object. 14654 */ 14655 async dispose(i) { 14656 this.privDisposedRecognizer || (i && (this.privDisposedRecognizer = !0, await this.implRecognizerStop()), await super.dispose(i)); 14657 } 14658 createRecognizerConfig(i) { 14659 return new s.RecognizerConfig(i, this.properties); 14660 } 14661 createServiceRecognizer(i, o, c, u) { 14662 const h = c; 14663 return new s.TranscriptionServiceRecognizer(i, o, h, u, this); 14664 } 14665 }; 14666 return gr.TranscriberRecognizer = a, gr; 14667} 14668var aa; 14669function Vl() { 14670 return aa || (aa = 1, function(t) { 14671 Object.defineProperty(t, "__esModule", { value: !0 }), t.InternalParticipants = t.ConversationTranslatorMessageTypes = t.ConversationTranslatorCommandTypes = t.ParticipantsListEventArgs = t.ParticipantEventArgs = t.ParticipantAttributeEventArgs = t.MuteAllEventArgs = t.LockRoomEventArgs = t.ConversationReceivedTranslationEventArgs = t.TranscriberRecognizer = t.ConversationRecognizerFactory = t.ConversationConnectionConfig = t.ConversationManager = void 0; 14672 var e = Dl(); 14673 Object.defineProperty(t, "ConversationManager", { enumerable: !0, get: function() { 14674 return e.ConversationManager; 14675 } }); 14676 var r = Ye; 14677 Object.defineProperty(t, "ConversationConnectionConfig", { enumerable: !0, get: function() { 14678 return r.ConversationConnectionConfig; 14679 } }); 14680 var s = Kl();
14681 Object.defineProperty(t, "ConversationRecognizerFactory", { enumerable: !0, get: function() { 14682 return s.ConversationRecognizerFactory; 14683 } }); 14684 var p = Jl(); 14685 Object.defineProperty(t, "TranscriberRecognizer", { enumerable: !0, get: function() { 14686 return p.TranscriberRecognizer; 14687 } }); 14688 var a = Jc(); 14689 Object.defineProperty(t, "ConversationReceivedTranslationEventArgs", { enumerable: !0, get: function() { 14690 return a.ConversationReceivedTranslationEventArgs; 14691 } }), Object.defineProperty(t, "LockRoomEventArgs", { enumerable: !0, get: function() { 14692 return a.LockRoomEventArgs; 14693 } }), Object.defineProperty(t, "MuteAllEventArgs", { enumerable: !0, get: function() { 14694 return a.MuteAllEventArgs; 14695 } }), Object.defineProperty(t, "ParticipantAttributeEventArgs", { enumerable: !0, get: function() { 14696 return a.ParticipantAttributeEventArgs; 14697 } }), Object.defineProperty(t, "ParticipantEventArgs", { enumerable: !0, get: function() { 14698 return a.ParticipantEventArgs; 14699 } }), Object.defineProperty(t, "ParticipantsListEventArgs", { enumerable: !0, get: function() { 14700 return a.ParticipantsListEventArgs; 14701 } }); 14702 var n = ge; 14703 Object.defineProperty(t, "ConversationTranslatorCommandTypes", { enumerable: !0, get: function() { 14704 return n.ConversationTranslatorCommandTypes; 14705 } }), Object.defineProperty(t, "ConversationTranslatorMessageTypes", { enumerable: !0, get: function() { 14706 return n.ConversationTranslatorMessageTypes; 14707 } }), Object.defineProperty(t, "InternalParticipants", { enumerable: !0, get: function() { 14708 return n.InternalParticipants; 14709 } }); 14710 }(En)), En; 14711} 14712var is = {}; 14713(function(t) { 14714 Object.defineProperty(t, "__esModule", { value: !0 }), t.SynthesisAudioMetadata = t.MetadataType = void 0, function(r) { 14715 r.WordBoundary = "WordBoundary", r.Bookmark = "Bookmark", r.Viseme = "Viseme", r.SentenceBoundary = "SentenceBoundary", r.SessionEnd = "SessionEnd", r.AvatarSignal = "TalkingAvatarSignal"; 14716 }(t.MetadataType || (t.MetadataType = {})); 14717 class e { 14718 constructor(s) { 14719 this.privSynthesisAudioMetadata = JSON.parse(s); 14720 } 14721 static fromJSON(s) { 14722 return new e(s); 14723 } 14724 get Metadata() { 14725 return this.privSynthesisAudioMetadata.Metadata; 14726 } 14727 } 14728 t.SynthesisAudioMetadata = e; 14729})(is); 14730var mr = {}, ue = {}; 14731Object.defineProperty(ue, "__esModule", { value: !0 }); 14732ue.SynthesisStartedEvent = ue.ConnectingToSynthesisServiceEvent = ue.SynthesisTriggeredEvent = ue.SpeechSynthesisEvent = void 0; 14733const ca = I(); 14734class nn extends ca.PlatformEvent { 14735 constructor(e, r, s = ca.EventType.Info) { 14736 super(e, s), this.privRequestId = r; 14737 } 14738 get requestId() { 14739 return this.privRequestId; 14740 } 14741} 14742ue.SpeechSynthesisEvent = nn; 14743class Gl extends nn { 14744 constructor(e, r, s) { 14745 super("SynthesisTriggeredEvent", e), this.privSessionAudioDestinationId = r, this.privTurnAudioDestinationId = s; 14746 } 14747 get audioSessionDestinationId() { 14748 return this.privSessionAudioDestinationId; 14749 } 14750 get audioTurnDestinationId() { 14751 return this.privTurnAudioDestinationId; 14752 } 14753} 14754ue.SynthesisTriggeredEvent = Gl; 14755class Ql extends nn { 14756 constructor(e, r) { 14757 super("ConnectingToSynthesisServiceEvent", e), this.privAuthFetchEventId = r; 14758 } 14759 get authFetchEventId() { 14760 return this.privAuthFetchEventId; 14761 } 14762} 14763ue.ConnectingToSynthesisServiceEvent = Ql; 14764class Xl extends nn { 14765 constructor(e, r) { 14766 super("SynthesisStartedEvent", e), this.privAuthFetchEventId = r; 14767 } 14768 get authFetchEventId() { 14769 return this.privAuthFetchEventId; 14770 } 14771} 14772ue.SynthesisStartedEvent = Xl; 14773var pa; 14774function Yl() { 14775 if (pa) return mr; 14776 pa = 1, Object.defineProperty(mr, "__esModule", { value: !0 }), mr.SynthesisTurn = void 0; 14777 const t = I(), e = U, r = R(), s = is, p = ue; 14778 let a = class Mn { 14779 constructor() { 14780 this.privIsDisposed = !1, this.privIsSynthesizing = !1, this.privIsSynthesisEnded = !1, this.privBytesReceived = 0, this.privInTurn = !1, this.privTextOffset = 0, this.privNextSearchTextIndex = 0, this.privSentenceOffset = 0, this.privNextSearchSentenceIndex = 0, this.privRequestId = (0, t.createNoDashGuid)(), this.privTurnDeferral = new t.Deferred(), this.privTurnDeferral.resolve(); 14781 } 14782 get requestId() { 14783 return this.privRequestId; 14784 } 14785 get streamId() { 14786 return this.privStreamId; 14787 } 14788 set streamId(i) { 14789 this.privStreamId = i; 14790 } 14791 get audioOutputFormat() { 14792 return this.privAudioOutputFormat; 14793 } 14794 set audioOutputFormat(i) { 14795 this.privAudioOutputFormat = i; 14796 } 14797 get turnCompletionPromise() { 14798 return this.privTurnDeferral.promise; 14799 } 14800 get isSynthesisEnded() { 14801 return this.privIsSynthesisEnded; 14802 } 14803 get isSynthesizing() { 14804 return this.privIsSynthesizing; 14805 } 14806 get currentTextOffset() { 14807 return this.privTextOffset; 14808 } 14809 get currentSentenceOffset() { 14810 return this.privSentenceOffset; 14811 } 14812 // The number of bytes received for current turn 14813 get bytesReceived() { 14814 return this.privBytesReceived; 14815 } 14816 get audioDuration() { 14817 return this.privAudioDuration; 14818 } 14819 get extraProperties() { 14820 if (this.privWebRTCSDP) { 14821 const i = new r.PropertyCollection(); 14822 return i.setProperty(r.PropertyId.TalkingAvatarService_WebRTC_SDP, this.privWebRTCSDP), i; 14823 } 14824 } 14825 async getAllReceivedAudio() { 14826 return this.privReceivedAudio ? Promise.resolve(this.privReceivedAudio) : this.privIsSynthesisEnded ? (await this.readAllAudioFromStream(), Promise.resolve(this.privReceivedAudio)) : null; 14827 }
14828 async getAllReceivedAudioWithHeader() { 14829 if (this.privReceivedAudioWithHeader) 14830 return this.privReceivedAudioWithHeader; 14831 if (!this.privIsSynthesisEnded) 14832 return null; 14833 if (this.audioOutputFormat.hasHeader) { 14834 const i = await this.getAllReceivedAudio(); 14835 return this.privReceivedAudioWithHeader = this.audioOutputFormat.addHeader(i), this.privReceivedAudioWithHeader; 14836 } else 14837 return this.getAllReceivedAudio(); 14838 } 14839 startNewSynthesis(i, o, c, u) { 14840 this.privIsSynthesisEnded = !1, this.privIsSynthesizing = !0, this.privRequestId = i, this.privRawText = o, this.privIsSSML = c, this.privAudioOutputStream = new e.PullAudioOutputStreamImpl(), this.privAudioOutputStream.format = this.privAudioOutputFormat, this.privReceivedAudio = null, this.privReceivedAudioWithHeader = null, this.privBytesReceived = 0, this.privTextOffset = 0, this.privNextSearchTextIndex = 0, this.privSentenceOffset = 0, this.privNextSearchSentenceIndex = 0, this.privPartialVisemeAnimation = "", this.privWebRTCSDP = "", u !== void 0 && (this.privTurnAudioDestination = u, this.privTurnAudioDestination.format = this.privAudioOutputFormat), this.onEvent(new p.SynthesisTriggeredEvent(this.requestId, void 0, u === void 0 ? void 0 : u.id())); 14841 } 14842 onPreConnectionStart(i) { 14843 this.privAuthFetchEventId = i, this.onEvent(new p.ConnectingToSynthesisServiceEvent(this.privRequestId, this.privAuthFetchEventId)); 14844 } 14845 onAuthCompleted(i) { 14846 i && this.onComplete(); 14847 } 14848 onConnectionEstablishCompleted(i) { 14849 if (i === 200) { 14850 this.onEvent(new p.SynthesisStartedEvent(this.requestId, this.privAuthFetchEventId)), this.privBytesReceived = 0; 14851 return; 14852 } else i === 403 && this.onComplete(); 14853 } 14854 onServiceResponseMessage(i) { 14855 const o = JSON.parse(i); 14856 this.streamId = o.audio.streamId; 14857 } 14858 onServiceTurnEndResponse() { 14859 this.privInTurn = !1, this.privTurnDeferral.resolve(), this.onComplete(); 14860 } 14861 onServiceTurnStartResponse(i) { 14862 this.privTurnDeferral && this.privInTurn && (this.privTurnDeferral.reject("Another turn started before current completed."), this.privTurnDeferral.promise.then().catch(() => { 14863 })), this.privInTurn = !0, this.privTurnDeferral = new t.Deferred(); 14864 const o = JSON.parse(i); 14865 o.webrtc && (this.privWebRTCSDP = o.webrtc.connectionString); 14866 } 14867 onAudioChunkReceived(i) { 14868 this.isSynthesizing && (this.privAudioOutputStream.write(i), this.privBytesReceived += i.byteLength, this.privTurnAudioDestination !== void 0 && this.privTurnAudioDestination.write(i)); 14869 } 14870 onTextBoundaryEvent(i) { 14871 this.updateTextOffset(i.Data.text.Text, i.Type); 14872 } 14873 onVisemeMetadataReceived(i) { 14874 i.Data.AnimationChunk !== void 0 && (this.privPartialVisemeAnimation += i.Data.AnimationChunk); 14875 } 14876 onSessionEnd(i) { 14877 this.privAudioDuration = i.Data.Offset; 14878 } 14879 async constructSynthesisResult() { 14880 const i = await this.getAllReceivedAudioWithHeader(); 14881 return new r.SpeechSynthesisResult(this.requestId, r.ResultReason.SynthesizingAudioCompleted, i, void 0, this.extraProperties, this.audioDuration); 14882 } 14883 dispose() { 14884 this.privIsDisposed || (this.privIsDisposed = !0); 14885 } 14886 onStopSynthesizing() { 14887 this.onComplete(); 14888 } 14889 /** 14890 * Gets the viseme animation string (merged from animation chunk), and clears the internal 14891 * partial animation. 14892 */ 14893 getAndClearVisemeAnimation() { 14894 const i = this.privPartialVisemeAnimation; 14895 return this.privPartialVisemeAnimation = "", i; 14896 } 14897 onEvent(i) { 14898 t.Events.instance.onEvent(i); 14899 } 14900 /** 14901 * Check if the text is an XML(SSML) tag 14902 * @param text 14903 * @private 14904 */ 14905 static isXmlTag(i) { 14906 return i.length >= 2 && i[0] === "<" && i[i.length - 1] === ">"; 14907 } 14908 updateTextOffset(i, o) { 14909 o === s.MetadataType.WordBoundary ? (this.privTextOffset = this.privRawText.indexOf(i, this.privNextSearchTextIndex), this.privTextOffset >= 0 && (this.privNextSearchTextIndex = this.privTextOffset + i.length, this.privIsSSML && this.withinXmlTag(this.privTextOffset) && !Mn.isXmlTag(i) && this.updateTextOffset(i, o))) : (this.privSentenceOffset = this.privRawText.indexOf(i, this.privNextSearchSentenceIndex), this.privSentenceOffset >= 0 && (this.privNextSearchSentenceIndex = this.privSentenceOffset + i.length, this.privIsSSML && this.withinXmlTag(this.privSentenceOffset) && !Mn.isXmlTag(i) && this.updateTextOffset(i, o))); 14910 } 14911 onComplete() { 14912 this.privIsSynthesizing && (this.privIsSynthesizing = !1, this.privIsSynthesisEnded = !0, this.privAudioOutputStream.close(), this.privInTurn = !1, this.privTurnAudioDestination !== void 0 && (this.privTurnAudioDestination.close(), this.privTurnAudioDestination = void 0)); 14913 } 14914 async readAllAudioFromStream() { 14915 if (this.privIsSynthesisEnded) { 14916 this.privReceivedAudio = new ArrayBuffer(this.bytesReceived); 14917 try { 14918 await this.privAudioOutputStream.read(this.privReceivedAudio); 14919 } catch { 14920 this.privReceivedAudio = new ArrayBuffer(0); 14921 } 14922 } 14923 } 14924 /** 14925 * Check if current idx is in XML(SSML) tag 14926 * @param idx 14927 * @private 14928 */ 14929 withinXmlTag(i) { 14930 return this.privRawText.indexOf("<", i + 1) > this.privRawText.indexOf(">", i + 1); 14931 } 14932 }; 14933 return mr.SynthesisTurn = a, mr; 14934} 14935var Sr = {}, ua; 14936function Zl() { 14937 if (ua) return Sr; 14938 ua = 1, Object.defineProperty(Sr, "__esModule", { value: !0 }), Sr.SynthesisAdapterBase = void 0; 14939 const t = I(), e = R(), r = A(), s = xe; 14940 let p = class { 14941 constructor(n, i, o, c) { 14942 if (this.speakOverride = void 0, this.receiveMessageOverride = void 0, this.connectImplOverride = void 0, this.configConnectionOverride = void 0, this.privConnectionConfigurationPromise = void 0, !n) 14943 throw new t.ArgumentNullError("authentication"); 14944 if (!i) 14945 throw new t.ArgumentNullError("connectionFactory"); 14946 if (!o) 14947 throw new t.ArgumentNullError("synthesizerConfig"); 14948 this.privAuthentication = n, this.privConnectionFactory = i, this.privSynthesizerConfig = o, this.privIsDisposed = !1, this.privSessionAudioDestination = c, this.privSynthesisTurn = new r.SynthesisTurn(), this.privConnectionEvents = new t.EventSource(), this.privServiceEvents = new t.EventSource(), this.privSynthesisContext = new r.SynthesisContext(), this.privAgentConfig = new r.AgentConfig(), this.connectionEvents.attach((u) => { 14949 if (u.name === "ConnectionClosedEvent") { 14950 const h = u; 14951 h.statusCode !== 1e3 && this.cancelSynthesisLocal(e.CancellationReason.Error, h.statusCode === 1007 ? e.CancellationErrorCode.BadRequestParameters : e.CancellationErrorCode.ConnectionFailure, `${h.reason} websocket error code: ${h.statusCode}`); 14952 } 14953 }); 14954 } 14955 get synthesizerConfig() { 14956 return this.privSynthesizerConfig; 14957 } 14958 get synthesisContext() { 14959 return this.privSynthesisContext; 14960 } 14961 get agentConfig() { 14962 return this.privAgentConfig; 14963 } 14964 get connectionEvents() { 14965 return this.privConnectionEvents; 14966 } 14967 get serviceEvents() { 14968 return this.privServiceEvents; 14969 } 14970 set activityTemplate(n) { 14971 this.privActivityTemplate = n; 14972 } 14973 get activityTemplate() { 14974 return this.privActivityTemplate; 14975 } 14976 set audioOutputFormat(n) { 14977 this.privAudioOutputFormat = n, this.privSynthesisTurn.audioOutputFormat = n, this.privSessionAudioDestination !== void 0 && (this.privSessionAudioDestination.format = n), this.synthesisContext !== void 0 && (this.synthesisContext.audioOutputFormat = n); 14978 } 14979 isDisposed() { 14980 return this.privIsDisposed; 14981 } 14982 async dispose(n) { 14983 this.privIsDisposed = !0, this.privSessionAudioDestination !== void 0 && this.privSessionAudioDestination.close(), this.privConnectionConfigurationPromise !== void 0 && await (await this.privConnectionConfigurationPromise).dispose(n); 14984 } 14985 async connect() { 14986 await this.connectImpl(); 14987 } 14988 async sendNetworkMessage(n, i) { 14989 const o = typeof i == "string" ? t.MessageType.Text : t.MessageType.Binary, c = typeof i == "string" ? "application/json" : ""; 14990 return (await this.fetchConnection()).send(new s.SpeechConnectionMessage(o, n, this.privSynthesisTurn.requestId, c, i)); 14991 } 14992 async Speak(n, i, o, c, u, h) { 14993 let d; 14994 if (i ? d = n : d = this.privSynthesizer.buildSsml(n), this.speakOverride !== void 0) 14995 return this.speakOverride(d, o, c, u); 14996 this.privSuccessCallback = c, this.privErrorCallback = u, this.privSynthesisTurn.startNewSynthesis(o, n, i, h);
14997 try { 14998 await this.connectImpl(); 14999 const v = await this.fetchConnection(); 15000 await this.sendSynthesisContext(v), await this.sendSsmlMessage(v, d, o), this.onSynthesisStarted(o), this.receiveMessage(); 15001 } catch (v) { 15002 return this.cancelSynthesisLocal(e.CancellationReason.Error, e.CancellationErrorCode.ConnectionFailure, v), Promise.reject(v); 15003 } 15004 } 15005 async stopSpeaking() { 15006 return await this.connectImpl(), (await this.fetchConnection()).send(new s.SpeechConnectionMessage(t.MessageType.Text, "synthesis.control", this.privSynthesisTurn.requestId, "application/json", JSON.stringify({ 15007 action: "stop" 15008 }))); 15009 } 15010 // Cancels synthesis. 15011 cancelSynthesis(n, i, o, c) { 15012 const u = new e.PropertyCollection(); 15013 u.setProperty(r.CancellationErrorCodePropertyName, e.CancellationErrorCode[o]); 15014 const h = new e.SpeechSynthesisResult(n, e.ResultReason.Canceled, void 0, c, u); 15015 if (this.onSynthesisCancelled(h), this.privSuccessCallback) 15016 try { 15017 this.privSuccessCallback(h); 15018 } catch { 15019 } 15020 } 15021 // Cancels synthesis. 15022 cancelSynthesisLocal(n, i, o) { 15023 this.privSynthesisTurn.isSynthesizing && (this.privSynthesisTurn.onStopSynthesizing(), this.cancelSynthesis(this.privSynthesisTurn.requestId, n, i, o)); 15024 } 15025 // eslint-disable-next-line @typescript-eslint/no-unused-vars 15026 processTypeSpecificMessages(n) { 15027 return !0; 15028 } 15029 async receiveMessage() { 15030 try { 15031 const i = await (await this.fetchConnection()).read(); 15032 if (this.receiveMessageOverride !== void 0) 15033 return this.receiveMessageOverride(); 15034 if (this.privIsDisposed) 15035 return; 15036 if (!i) 15037 return this.privSynthesisTurn.isSynthesizing ? this.receiveMessage() : void 0; 15038 const o = s.SpeechConnectionMessage.fromConnectionMessage(i); 15039 if (o.requestId.toLowerCase() === this.privSynthesisTurn.requestId.toLowerCase()) 15040 switch (o.path.toLowerCase()) { 15041 case "turn.start": 15042 this.privSynthesisTurn.onServiceTurnStartResponse(o.textBody); 15043 break; 15044 case "response": 15045 this.privSynthesisTurn.onServiceResponseMessage(o.textBody); 15046 break; 15047 case "audio": 15048 this.privSynthesisTurn.streamId.toLowerCase() === o.streamId.toLowerCase() && o.binaryBody && (this.privSynthesisTurn.onAudioChunkReceived(o.binaryBody), this.onSynthesizing(o.binaryBody), this.privSessionAudioDestination !== void 0 && this.privSessionAudioDestination.write(o.binaryBody)); 15049 break; 15050 case "audio.metadata": 15051 const c = r.SynthesisAudioMetadata.fromJSON(o.textBody).Metadata; 15052 for (const h of c) 15053 switch (h.Type) { 15054 case r.MetadataType.WordBoundary: 15055 case r.MetadataType.SentenceBoundary: 15056 this.privSynthesisTurn.onTextBoundaryEvent(h); 15057 const d = new e.SpeechSynthesisWordBoundaryEventArgs(h.Data.Offset, h.Data.Duration, h.Data.text.Text, h.Data.text.Length, h.Type === r.MetadataType.WordBoundary ? this.privSynthesisTurn.currentTextOffset : this.privSynthesisTurn.currentSentenceOffset, h.Data.text.BoundaryType); 15058 this.onWordBoundary(d); 15059 break; 15060 case r.MetadataType.Bookmark: 15061 const v = new e.SpeechSynthesisBookmarkEventArgs(h.Data.Offset, h.Data.Bookmark); 15062 this.onBookmarkReached(v); 15063 break; 15064 case r.MetadataType.Viseme: 15065 if (this.privSynthesisTurn.onVisemeMetadataReceived(h), h.Data.IsLastAnimation) { 15066 const f = new e.SpeechSynthesisVisemeEventArgs(h.Data.Offset, h.Data.VisemeId, this.privSynthesisTurn.getAndClearVisemeAnimation()); 15067 this.onVisemeReceived(f); 15068 } 15069 break; 15070 case r.MetadataType.AvatarSignal: 15071 this.onAvatarEvent(h); 15072 break; 15073 case r.MetadataType.SessionEnd: 15074 this.privSynthesisTurn.onSessionEnd(h); 15075 break; 15076 } 15077 break; 15078 case "turn.end": 15079 this.privSynthesisTurn.onServiceTurnEndResponse(); 15080 let u; 15081 try { 15082 u = await this.privSynthesisTurn.constructSynthesisResult(), this.privSuccessCallback && this.privSuccessCallback(u); 15083 } catch (h) { 15084 this.privErrorCallback && this.privErrorCallback(h); 15085 } 15086 this.onSynthesisCompleted(u); 15087 break; 15088 default: 15089 this.processTypeSpecificMessages(o) || this.privServiceEvents && this.serviceEvents.onEvent(new t.ServiceEvent(o.path.toLowerCase(), o.textBody)); 15090 } 15091 return this.receiveMessage(); 15092 } catch { 15093 } 15094 } 15095 sendSynthesisContext(n) { 15096 this.setSynthesisContextSynthesisSection(); 15097 const i = this.synthesisContext.toJSON(); 15098 if (i) 15099 return n.send(new s.SpeechConnectionMessage(t.MessageType.Text, "synthesis.context", this.privSynthesisTurn.requestId, "application/json", i)); 15100 } 15101 setSpeechConfigSynthesisSection() { 15102 } 15103 connectImpl(n = !1) { 15104 if (this.privConnectionPromise != null) 15105 return this.privConnectionPromise.then((o) => o.state() === t.ConnectionState.Disconnected ? (this.privConnectionId = null, this.privConnectionPromise = null, this.connectImpl()) : this.privConnectionPromise, () => (this.privConnectionId = null, this.privConnectionPromise = null, this.connectImpl())); 15106 this.privAuthFetchEventId = (0, t.createNoDashGuid)(), this.privConnectionId = (0, t.createNoDashGuid)(), this.privSynthesisTurn.onPreConnectionStart(this.privAuthFetchEventId); 15107 const i = n ? this.privAuthentication.fetchOnExpiry(this.privAuthFetchEventId) : this.privAuthentication.fetch(this.privAuthFetchEventId); 15108 return this.privConnectionPromise = i.then(async (o) => { 15109 this.privSynthesisTurn.onAuthCompleted(!1); 15110 const c = await this.privConnectionFactory.create(this.privSynthesizerConfig, o, this.privConnectionId); 15111 c.events.attach((h) => { 15112 this.connectionEvents.onEvent(h); 15113 }); 15114 const u = await c.open(); 15115 return u.statusCode === 200 ? (this.privSynthesisTurn.onConnectionEstablishCompleted(u.statusCode), Promise.resolve(c)) : u.statusCode === 403 && !n ? this.connectImpl(!0) : (this.privSynthesisTurn.onConnectionEstablishCompleted(u.statusCode), Promise.reject(`Unable to contact server. StatusCode: ${u.statusCode}, 15116 ${this.privSynthesizerConfig.parameters.getProperty(e.PropertyId.SpeechServiceConnection_Url)} Reason: ${u.reason}`)); 15117 }, (o) => { 15118 throw this.privSynthesisTurn.onAuthCompleted(!0), new Error(o); 15119 }), this.privConnectionPromise.catch(() => { 15120 }), this.privConnectionPromise; 15121 } 15122 sendSpeechServiceConfig(n, i) { 15123 if (i) 15124 return n.send(new s.SpeechConnectionMessage(t.MessageType.Text, "speech.config", this.privSynthesisTurn.requestId, "application/json", i)); 15125 } 15126 sendSsmlMessage(n, i, o) { 15127 return n.send(new s.SpeechConnectionMessage(t.MessageType.Text, "ssml", o, "application/ssml+xml", i)); 15128 } 15129 async fetchConnection() { 15130 return this.privConnectionConfigurationPromise !== void 0 ? this.privConnectionConfigurationPromise.then((n) => n.state() === t.ConnectionState.Disconnected ? (this.privConnectionId = null, this.privConnectionConfigurationPromise = void 0, this.fetchConnection()) : this.privConnectionConfigurationPromise, () => (this.privConnectionId = null, this.privConnectionConfigurationPromise = void 0, this.fetchConnection())) : (this.privConnectionConfigurationPromise = this.configureConnection(), await this.privConnectionConfigurationPromise); 15131 } 15132 // Takes an established websocket connection to the endpoint and sends speech configuration information. 15133 async configureConnection() { 15134 const n = await this.connectImpl(); 15135 return this.configConnectionOverride !== void 0 ? this.configConnectionOverride(n) : (this.setSpeechConfigSynthesisSection(), await this.sendSpeechServiceConfig(n, this.privSynthesizerConfig.SpeechServiceConfig.serialize()), n); 15136 } 15137 onAvatarEvent(n) { 15138 } 15139 onSynthesisStarted(n) { 15140 } 15141 onSynthesizing(n) { 15142 } 15143 onSynthesisCancelled(n) { 15144 } 15145 onSynthesisCompleted(n) { 15146 } 15147 onWordBoundary(n) { 15148 } 15149 onVisemeReceived(n) { 15150 } 15151 onBookmarkReached(n) { 15152 } 15153 }; 15154 return Sr.SynthesisAdapterBase = p, p.telemetryDataEnabled = !0, Sr; 15155} 15156var Cr = {}, ha; 15157function $l() { 15158 if (ha) return Cr; 15159 ha = 1, Object.defineProperty(Cr, "__esModule", { value: !0 }), Cr.AvatarSynthesisAdapter = void 0; 15160 const t = R(), e = A(); 15161 let r = class extends e.SynthesisAdapterBase { 15162 constructor(p, a, n, i, o) { 15163 super(p, a, n, void 0), this.privAvatarSynthesizer = i, this.privSynthesizer = i, this.privAvatarConfig = o; 15164 } 15165 setSynthesisContextSynthesisSection() { 15166 this.privSynthesisContext.setSynthesisSection(void 0); 15167 } 15168 setSpeechConfigSynthesisSection() { 15169 var a, n, i, o, c, u, h, d, v, f, m, S, l, g, C, y, P; 15170 const p = { 15171 background: { 15172 color: this.privAvatarConfig.backgroundColor, 15173 image: { 15174 url: (a = this.privAvatarConfig.backgroundImage) == null ? void 0 : a.toString() 15175 } 15176 }, 15177 character: this.privAvatarConfig.character, 15178 customized: this.privAvatarConfig.customized, 15179 photoAvatarBaseModel: this.privAvatarConfig.photoAvatarBaseModel, 15180 style: this.privAvatarConfig.style, 15181 useBuiltInVoice: this.privAvatarConfig.useBuiltInVoice 15182 }; 15183 this.privAvatarConfig.scene && (p.scene = { 15184 amplitude: this.privAvatarConfig.scene.amplitude, 15185 positionX: this.privAvatarConfig.scene.positionX, 15186 positionY: this.privAvatarConfig.scene.positionY, 15187 rotationX: this.privAvatarConfig.scene.rotationX, 15188 rotationY: this.privAvatarConfig.scene.rotationY, 15189 rotationZ: this.privAvatarConfig.scene.rotationZ, 15190 zoom: this.privAvatarConfig.scene.zoom 15191 }), this.privSynthesizerConfig.synthesisVideoSection = { 15192 format: { 15193 bitrate: (n = this.privAvatarConfig.videoFormat) == null ? void 0 : n.bitrate, 15194 codec: (i = this.privAvatarConfig.videoFormat) == null ? void 0 : i.codec, 15195 crop: { 15196 bottomRight: { 15197 x: (u = (c = (o = this.privAvatarConfig.videoFormat) == null ? void 0 : o.cropRange) == null ? void 0 : c.bottomRight) == null ? void 0 : u.x, 15198 y: (v = (d = (h = this.privAvatarConfig.videoFormat) == null ? void 0 : h.cropRange) == null ? void 0 : d.bottomRight) == null ? void 0 : v.y 15199 }, 15200 topLeft: { 15201 x: (S = (m = (f = this.privAvatarConfig.videoFormat) == null ? void 0 : f.cropRange) == null ? void 0 : m.topLeft) == null ? void 0 : S.x, 15202 y: (C = (g = (l = this.privAvatarConfig.videoFormat) == null ? void 0 : l.cropRange) == null ? void 0 : g.topLeft) == null ? void 0 : C.y 15203 } 15204 }, 15205 resolution: { 15206 height: (y = this.privAvatarConfig.videoFormat) == null ? void 0 : y.height, 15207 width: (P = this.privAvatarConfig.videoFormat) == null ? void 0 : P.width 15208 } 15209 }, 15210 protocol: { 15211 name: "WebRTC", 15212 webrtcConfig: { 15213 clientDescription: btoa(this.privSynthesizerConfig.parameters.getProperty(t.PropertyId.TalkingAvatarService_WebRTC_SDP)), 15214 iceServers: this.privAvatarConfig.remoteIceServers ?? this.privAvatarSynthesizer.iceServers 15215 } 15216 }, 15217 talkingAvatar: p 15218 }; 15219 } 15220 onAvatarEvent(p) { 15221 if (this.privAvatarSynthesizer.avatarEventReceived) { 15222 const a = new t.AvatarEventArgs(p.Data.Offset, p.Data.Name); 15223 try { 15224 this.privAvatarSynthesizer.avatarEventReceived(this.privAvatarSynthesizer, a); 15225 } catch { 15226 } 15227 } 15228 } 15229 }; 15230 return Cr.AvatarSynthesisAdapter = r, Cr; 15231} 15232var yr = {}, da; 15233function ef() { 15234 if (da) return yr; 15235 da = 1, Object.defineProperty(yr, "__esModule", { value: !0 }), yr.SpeechSynthesisAdapter = void 0; 15236 const t = R(), e = A(); 15237 let r = class extends e.SynthesisAdapterBase { 15238 constructor(p, a, n, i, o) { 15239 super(p, a, n, o), this.privSpeechSynthesizer = i, this.privSynthesizer = i; 15240 } 15241 setSynthesisContextSynthesisSection() { 15242 this.privSynthesisContext.setSynthesisSection(this.privSpeechSynthesizer); 15243 } 15244 onSynthesisStarted(p) { 15245 const a = new t.SpeechSynthesisEventArgs(new t.SpeechSynthesisResult(p, t.ResultReason.SynthesizingAudioStarted)); 15246 this.privSpeechSynthesizer.synthesisStarted && this.privSpeechSynthesizer.synthesisStarted(this.privSpeechSynthesizer, a); 15247 } 15248 onSynthesizing(p) { 15249 if (this.privSpeechSynthesizer.synthesizing) 15250 try { 15251 const a = this.privSynthesisTurn.audioOutputFormat.addHeader(p), n = new t.SpeechSynthesisEventArgs(new t.SpeechSynthesisResult(this.privSynthesisTurn.requestId, t.ResultReason.SynthesizingAudio, a)); 15252 this.privSpeechSynthesizer.synthesizing(this.privSpeechSynthesizer, n); 15253 } catch { 15254 } 15255 } 15256 onSynthesisCancelled(p) { 15257 if (this.privSpeechSynthesizer.SynthesisCanceled) { 15258 const a = new t.SpeechSynthesisEventArgs(p); 15259 try { 15260 this.privSpeechSynthesizer.SynthesisCanceled(this.privSpeechSynthesizer, a); 15261 } catch { 15262 } 15263 } 15264 } 15265 onSynthesisCompleted(p) { 15266 if (this.privSpeechSynthesizer.synthesisCompleted) 15267 try { 15268 this.privSpeechSynthesizer.synthesisCompleted(this.privSpeechSynthesizer, new t.SpeechSynthesisEventArgs(p)); 15269 } catch { 15270 } 15271 } 15272 onWordBoundary(p) { 15273 if (this.privSpeechSynthesizer.wordBoundary) 15274 try { 15275 this.privSpeechSynthesizer.wordBoundary(this.privSpeechSynthesizer, p); 15276 } catch { 15277 } 15278 } 15279 onVisemeReceived(p) { 15280 if (this.privSpeechSynthesizer.visemeReceived) 15281 try { 15282 this.privSpeechSynthesizer.visemeReceived(this.privSpeechSynthesizer, p); 15283 } catch { 15284 } 15285 } 15286 onBookmarkReached(p) { 15287 if (this.privSpeechSynthesizer.bookmarkReached) 15288 try { 15289 this.privSpeechSynthesizer.bookmarkReached(this.privSpeechSynthesizer, p); 15290 } catch { 15291 } 15292 } 15293 }; 15294 return yr.SpeechSynthesisAdapter = r, yr; 15295} 15296var Pr = {}, va; 15297function tf() { 15298 if (va) return Pr; 15299 va = 1, Object.defineProperty(Pr, "__esModule", { value: !0 }), Pr.SynthesisRestAdapter = void 0; 15300 const t = re(), e = R(), r = Se(), s = Y; 15301 let p = class { 15302 constructor(n, i) { 15303 let o = n.parameters.getProperty(e.PropertyId.SpeechServiceConnection_Endpoint, void 0); 15304 if (!o) { 15305 const u = n.parameters.getProperty(e.PropertyId.SpeechServiceConnection_Region, "westus"), h = r.ConnectionFactoryBase.getHostSuffix(u); 15306 o = n.parameters.getProperty(e.PropertyId.SpeechServiceConnection_Host, `https://${u}.tts.speech${h}`); 15307 } 15308 this.privUri = `${o}/cognitiveservices/voices/list`; 15309 const c = t.RestConfigBase.requestOptions; 15310 this.privRestAdapter = new t.RestMessageAdapter(c), this.privAuthentication = i; 15311 } 15312 /** 15313 * Sends list voices request to endpoint. 15314 * @function 15315 * @public 15316 * @param connectionId - guid for connectionId 15317 * @returns {Promise<IRestResponse>} rest response to status request 15318 */ 15319 getVoicesList(n) { 15320 return this.privRestAdapter.setHeaders(s.HeaderNames.ConnectionId, n), this.privAuthentication.fetch(n).then((i) => (this.privRestAdapter.setHeaders(i.headerName, i.token), this.privRestAdapter.request(t.RestRequestType.Get, this.privUri))); 15321 } 15322 }; 15323 return Pr.SynthesisRestAdapter = p, Pr; 15324} 15325var An = {}, la; 15326function rf() { 15327 return la || (la = 1, function(t) { 15328 Object.defineProperty(t, "__esModule", { value: !0 }), t.SynthesizerConfig = t.SynthesisServiceType = void 0; 15329 const e = A(); 15330 var r; 15331 (function(p) { 15332 p[p.Standard = 0] = "Standard", p[p.Custom = 1] = "Custom"; 15333 })(r = t.SynthesisServiceType || (t.SynthesisServiceType = {})); 15334 class s {
15334 15335 constructor(a, n) { 15336 this.privSynthesisServiceType = r.Standard, this.avatarEnabled = !1, this.privSpeechServiceConfig = a || new e.SpeechServiceConfig(new e.Context(null)), this.privParameters = n; 15337 } 15338 get parameters() { 15339 return this.privParameters; 15340 } 15341 get synthesisServiceType() { 15342 return this.privSynthesisServiceType; 15343 } 15344 set synthesisServiceType(a) { 15345 this.privSynthesisServiceType = a; 15346 } 15347 set synthesisVideoSection(a) { 15348 this.privSpeechServiceConfig.Context.synthesis = { 15349 video: a 15350 }; 15351 } 15352 get SpeechServiceConfig() { 15353 return this.privSpeechServiceConfig; 15354 } 15355 setContextFromJson(a) { 15356 const n = JSON.parse(a); 15357 n.system && (this.privSpeechServiceConfig.Context.system = n.system), n.os && (this.privSpeechServiceConfig.Context.os = n.os), n.audio && (this.privSpeechServiceConfig.Context.audio = n.audio), n.synthesis && (this.privSpeechServiceConfig.Context.synthesis = n.synthesis); 15358 } 15359 } 15360 t.SynthesizerConfig = s; 15361 }(An)), An; 15362} 15363var Rr = {}, fa; 15364function nf() { 15365 if (fa) return Rr; 15366 fa = 1, Object.defineProperty(Rr, "__esModule", { value: !0 }), Rr.SynthesisContext = void 0; 15367 const t = R(); 15368 let e = class { 15369 constructor() { 15370 this.privContext = {}; 15371 } 15372 /** 15373 * Adds a section to the synthesis.context object. 15374 * @param sectionName Name of the section to add. 15375 * @param value JSON serializable object that represents the value. 15376 */ 15377 setSection(s, p) { 15378 this.privContext[s] = p; 15379 } 15380 /** 15381 * Sets the audio output format for synthesis context generation. 15382 * @param format {AudioOutputFormatImpl} the output format 15383 */ 15384 set audioOutputFormat(s) { 15385 this.privAudioOutputFormat = s; 15386 } 15387 toJSON() { 15388 return JSON.stringify(this.privContext); 15389 } 15390 setSynthesisSection(s) { 15391 const p = this.buildSynthesisContext(s); 15392 this.setSection("synthesis", p); 15393 } 15394 buildSynthesisContext(s) { 15395 return { 15396 audio: { 15397 metadataOptions: { 15398 bookmarkEnabled: !!(s != null && s.bookmarkReached), 15399 punctuationBoundaryEnabled: s == null ? void 0 : s.properties.getProperty(t.PropertyId.SpeechServiceResponse_RequestPunctuationBoundary, !!(s != null && s.wordBoundary)), 15400 sentenceBoundaryEnabled: s == null ? void 0 : s.properties.getProperty(t.PropertyId.SpeechServiceResponse_RequestSentenceBoundary, !1), 15401 sessionEndEnabled: !0, 15402 visemeEnabled: !!(s != null && s.visemeReceived), 15403 wordBoundaryEnabled: s == null ? void 0 : s.properties.getProperty(t.PropertyId.SpeechServiceResponse_RequestWordBoundary, !!(s != null && s.wordBoundary)) 15404 }, 15405 outputFormat: this.privAudioOutputFormat.requestAudioFormatString 15406 }, 15407 language: { 15408 autoDetection: s == null ? void 0 : s.autoDetectSourceLanguage 15409 } 15410 }; 15411 } 15412 }; 15413 return Rr.SynthesisContext = e, Rr; 15414} 15415var Gc = {}; 15416(function(t) { 15417 Object.defineProperty(t, "__esModule", { value: !0 }), t.type = t.connectivity = t.Device = t.OS = t.System = t.Context = t.SpeechServiceConfig = void 0; 15418 class e { 15419 constructor(i) { 15420 this.context = i; 15421 } 15422 serialize() { 15423 return JSON.stringify(this, (i, o) => { 15424 if (o && typeof o == "object" && !Array.isArray(o)) { 15425 const c = {}; 15426 for (const u in o) 15427 Object.hasOwnProperty.call(o, u) && (c[u && u.charAt(0).toLowerCase() + u.substring(1)] = o[u]); 15428 return c; 15429 } 15430 return o; 15431 }); 15432 } 15433 get Context() { 15434 return this.context; 15435 } 15436 get Recognition() { 15437 return this.recognition; 15438 } 15439 set Recognition(i) { 15440 this.recognition = i.toLowerCase(); 15441 } 15442 } 15443 t.SpeechServiceConfig = e; 15444 class r { 15445 constructor(i) { 15446 this.system = new s(), this.os = i; 15447 } 15448 } 15449 t.Context = r; 15450 class s { 15451 constructor() { 15452 const i = "1.48.0"; 15453 this.name = "SpeechSDK", this.version = i, this.build = "JavaScript", this.lang = "JavaScript"; 15454 } 15455 } 15456 t.System = s; 15457 class p { 15458 constructor(i, o, c) { 15459 this.platform = i, this.name = o, this.version = c; 15460 } 15461 } 15462 t.OS = p; 15463 class a { 15464 constructor(i, o, c) { 15465 this.manufacturer = i, this.model = o, this.version = c; 15466 } 15467 } 15468 t.Device = a, function(n) { 15469 n.Bluetooth = "Bluetooth", n.Wired = "Wired", n.WiFi = "WiFi", n.Cellular = "Cellular", n.InBuilt = "InBuilt", n.Unknown = "Unknown"; 15470 }(t.connectivity || (t.connectivity = {})), function(n) { 15471 n.Phone = "Phone", n.Speaker = "Speaker", n.Car = "Car", n.Headset = "Headset", n.Thermostat = "Thermostat", n.Microphones = "Microphones", n.Deskphone = "Deskphone", n.RemoteControl = "RemoteControl", n.Unknown = "Unknown", n.File = "File", n.Stream = "Stream"; 15472 }(t.type || (t.type = {})); 15473})(Gc); 15474var ga; 15475function A() { 15476 return ga || (ga = 1, function(t) { 15477 var e = k && k.__createBinding || (Object.create ? function(a, n, i, o) { 15478 o === void 0 && (o = i), Object.defineProperty(a, o, { enumerable: !0, get: function() { 15479 return n[i]; 15480 } }); 15481 } : function(a, n, i, o) { 15482 o === void 0 && (o = i), a[o] = n[i]; 15483 }), r = k && k.__exportStar || function(a, n) { 15484 for (var i in a) i !== "default" && !Object.prototype.hasOwnProperty.call(n, i) && e(n, a, i); 15485 };
15486 Object.defineProperty(t, "__esModule", { value: !0 }), t.AutoDetectSourceLanguagesOpenRangeOptionName = t.ForceDictationPropertyName = t.ServicePropertiesPropertyName = t.CancellationErrorCodePropertyName = t.OutputFormatPropertyName = t.SpeechSynthesisAdapter = t.AvatarSynthesisAdapter = void 0, r(Jr, t), r(vi, t), r(Xe, t), r(Ba, t), r(qa, t), r(li, t), r(Zv(), t), r($v(), t), r(el(), t), r(jc, t), r(xi, t), r(rl(), t), r(il(), t), r(nl(), t), r(sl(), t), r(Tc(), t), r(ol(), t), r(Lc, t), r(al(), t), r(Wi, t), r(pl(), t), r(ul(), t), r(Hi, t), r(Ki, t), r(Ji, t), r(hl(), t), r(dl(), t), r(vl(), t), r(ll(), t), r(fl(), t), r(Vi, t), r(Qi, t), r(Xi, t), r(bl(), t), r($i, t), r(Vl(), t), r(is, t), r(Yl(), t), r(Zl(), t); 15487 var s = $l(); 15488 Object.defineProperty(t, "AvatarSynthesisAdapter", { enumerable: !0, get: function() { 15489 return s.AvatarSynthesisAdapter; 15490 } }); 15491 var p = ef(); 15492 Object.defineProperty(t, "SpeechSynthesisAdapter", { enumerable: !0, get: function() { 15493 return p.SpeechSynthesisAdapter; 15494 } }), r(tf(), t), r(rf(), t), r(nf(), t), r(Gc, t), t.OutputFormatPropertyName = "OutputFormat", t.CancellationErrorCodePropertyName = "CancellationErrorCode", t.ServicePropertiesPropertyName = "ServiceProperties", t.ForceDictationPropertyName = "ForceDictation", t.AutoDetectSourceLanguagesOpenRangeOptionName = "UND"; 15495 }(on)), on; 15496} 15497(function(t) { 15498 var e = k && k.__createBinding || (Object.create ? function(p, a, n, i) { 15499 i === void 0 && (i = n), Object.defineProperty(p, i, { enumerable: !0, get: function() { 15500 return a[n]; 15501 } }); 15502 } : function(p, a, n, i) { 15503 i === void 0 && (i = n), p[i] = a[n]; 15504 }), r = k && k.__exportStar || function(p, a) { 15505 for (var n in p) n !== "default" && !Object.prototype.hasOwnProperty.call(a, n) && e(a, p, n); 15506 }; 15507 Object.defineProperty(t, "__esModule", { value: !0 }); 15508 const s = A(); 15509 new s.AgentConfig(), r(R(), t); 15510})(On); 15511const sf = /* @__PURE__ */ Hp(On), lg = /* @__PURE__ */ Kp({ 15512 __proto__: null, 15513 default: sf 15514}, [On]); 15515export { 15516 lg as m 15517};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.