@speechly/browser-client
Advanced tools
Comparing version 0.5.0 to 0.5.1
@@ -16,2 +16,4 @@ import { AudioFilter } from './sampler'; | ||
private readonly sampler; | ||
private readonly nativeResamplingSupported; | ||
private readonly sampleRate; | ||
private audioTrack?; | ||
@@ -18,0 +20,0 @@ private mediaStream?; |
@@ -26,5 +26,15 @@ "use strict"; | ||
}; | ||
try { | ||
const constraints = window.navigator.mediaDevices.getSupportedConstraints(); | ||
this.nativeResamplingSupported = constraints.sampleRate === true; | ||
} | ||
catch (_a) { | ||
this.nativeResamplingSupported = false; | ||
} | ||
if (window.AudioContext !== undefined) { | ||
// Chrome / FF support passing sampleRate to audio context. | ||
this.audioContext = new window.AudioContext({ sampleRate }); | ||
const opts = {}; | ||
if (this.nativeResamplingSupported) { | ||
opts.sampleRate = sampleRate; | ||
} | ||
this.audioContext = new window.AudioContext(opts); | ||
this.isWebkit = false; | ||
@@ -41,2 +51,3 @@ } | ||
this.sampler = sampler !== null && sampler !== void 0 ? sampler : sampler_1.newSampler(this.audioContext.sampleRate, sampleRate); | ||
this.sampleRate = sampleRate; | ||
this.onAudio = onAudio; | ||
@@ -61,6 +72,14 @@ } | ||
try { | ||
this.mediaStream = yield window.navigator.mediaDevices.getUserMedia({ | ||
audio: true, | ||
const opts = { | ||
video: false | ||
}); | ||
}; | ||
if (this.nativeResamplingSupported) { | ||
opts.audio = { | ||
sampleRate: this.sampleRate | ||
}; | ||
} | ||
else { | ||
opts.audio = true; | ||
} | ||
this.mediaStream = yield window.navigator.mediaDevices.getUserMedia(opts); | ||
} | ||
@@ -67,0 +86,0 @@ catch (_b) { |
{ | ||
"name": "@speechly/browser-client", | ||
"version": "0.5.0", | ||
"version": "0.5.1", | ||
"description": "Browser client for Speechly API", | ||
@@ -5,0 +5,0 @@ "private": false, |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
129582
2518