Skip to content
Snippets Groups Projects
Commit 61723ede authored by Martin Klampfer's avatar Martin Klampfer
Browse files

Merge branch 'feature/translation-threshold-setting-in-ui' into 'feature/translation-2.3.x'

speech detection threshold setting

See merge request chat/fairblue!34
parents c801e93e 232ea05b
No related branches found
No related tags found
1 merge request!34speech detection threshold setting
......@@ -34,3 +34,4 @@ clients/flash/**/.gradle
**/.idea/*
*.iml
*~
**/node_modules/
......@@ -330,7 +330,7 @@ class ActionsBar extends PureComponent {
aria-label={intl.formatMessage(intlMessages.translatorMicrophoneLabel)}
color={!amIAsTranslatorMuted ? 'primary' : 'default'}
ghost={amIAsTranslatorMuted}
icon={amIAsTranslatorMuted ? 'mute' : 'unmute'}
icon={amIAsTranslatorMuted ? 'mute' : AudioManager.$translatorSpeakingChanged.value ? "mute_filled": 'unmute'}
size="lg"
circle
/>
......
......@@ -39,6 +39,11 @@ const intlMessages = defineMessages({
description: 'Label for end translation button',
defaultMessage: 'End Translation',
},
speechDetectionThreshold: {
id: 'app.translation.speechDetectionThreshold',
description: 'Translator speech detection threshold',
defaultMessage: 'Translator speech detection threshold',
},
});
class Translations extends Component{
......@@ -106,12 +111,25 @@ class Translations extends Component{
languages: [],
active: false,
warning: null,
speechDetectionThreshold: AudioManager.$translatorSpeechDetectionThresholdChanged.value
}
componentWillUnmount() {
window.dispatchEvent(new Event('panelChanged'));
}
updateThreshold() {
AudioManager.$translatorSpeechDetectionThresholdChanged.next(this.state.speechDetectionThreshold);
}
setThreshold(pEvent) {
this.setState({speechDetectionThreshold: pEvent.target.value});
}
handleSubmit(pEvent) {
pEvent.preventDefault();
}
render() {
const {
intl,
......@@ -167,6 +185,11 @@ class Translations extends Component{
: null
}
</p>
<div>{intl.formatMessage(intlMessages.speechDetectionThreshold)}:</div>
<form onSubmit={this.handleSubmit}>
<input id="speechDetectionThreshold" type="number" value={this.state.speechDetectionThreshold} onChange={this.setThreshold.bind(this)} />
<input type="submit" onClick={ this.updateThreshold.bind(this) } value="Set" />
</form>
</div>
);
}
......
......@@ -15,6 +15,7 @@ import { monitorAudioConnection } from '/imports/utils/stats';
import AudioErrors from './error-codes';
import {Meteor} from "meteor/meteor";
import {makeCall} from "../api";
import { BehaviorSubject } from "rxjs";
const STATS = Meteor.settings.public.stats;
const MEDIA = Meteor.settings.public.media;
......@@ -24,7 +25,7 @@ const MAX_LISTEN_ONLY_RETRIES = 1;
const LISTEN_ONLY_CALL_TIMEOUT_MS = MEDIA.listenOnlyCallTimeout || 25000;
const DEFAULT_INPUT_DEVICE_ID = 'default';
const DEFAULT_OUTPUT_DEVICE_ID = 'default';
const TRANSLATOR_SPEAK_DETECTION_THRESHOLD = MEDIA.translation.translator.speakDetection.threshold || -70;
const TRANSLATOR_SPEECH_DETECTION_THRESHOLD = MEDIA.translation.translator.speakDetection.threshold || -70;
const CALL_STATES = {
STARTED: 'started',
......@@ -53,7 +54,12 @@ class AudioManager {
status: BREAKOUT_AUDIO_TRANSFER_STATES.DISCONNECTED,
breakoutMeetingId: null,
};
this.translatorStream = null
this.translatorStream = null;
this.translatorSpeechEvents = null;
this.$translatorSpeechDetectionThresholdChanged = new BehaviorSubject(TRANSLATOR_SPEECH_DETECTION_THRESHOLD)
this.$translatorSpeakingChanged = new BehaviorSubject(false)
this.defineProperties({
isMuted: false,
isConnected: false,
......@@ -69,7 +75,7 @@ class AudioManager {
isReconnecting: false,
listeningTranslation: ORIGINAL_TRANSLATION,
translatorChannelOpen:false,
translationChannelOpen:false
translationChannelOpen:false,
});
this.useKurento = Meteor.settings.public.kurento.enableListenOnly;
......@@ -86,6 +92,12 @@ class AudioManager {
this.muteStateCallbacks = new Set();
this.translationStateCallbacks = new Set();
this.translationState = null;
this.$translatorSpeechDetectionThresholdChanged.subscribe((val) => {
if(this.translatorSpeechEvents && this.translatorSpeechEvents.hasOwnProperty("setThreshold")) {
this.translatorSpeechEvents.setThreshold(val);
}
});
}
init(userData, audioEventHandler) {
......@@ -828,29 +840,28 @@ class AudioManager {
let success = function (inputStream) {
let speechEventsOptions = {
interval: 200,
threshold: TRANSLATOR_SPEAK_DETECTION_THRESHOLD,
threshold: this.$translatorSpeechDetectionThresholdChanged.value,
play: false,
};
let hark = window.hark;
this.translatorStream = inputStream
this.translatorSpeechEvents = hark(inputStream, speechEventsOptions);
this.translatorSpeechEvents.on('speaking', () => {
console.log("Speaking")
this.$translatorSpeakingChanged.next(true);
Meeting.changeTranslatorSpeackState(languageExtension, true);
});
this.translatorSpeechEvents.on('volume_change', () => {
const translatorIsSpeaking = this.translatorSpeechEvents.speaking;
if (translatorIsSpeaking && (!this.translatorSpeechEvents.lastTimestamp || Date.now() - this.translatorSpeechEvents.lastTimestamp > 2000)) {
console.log("Check is translator speaking");
this.translatorSpeechEvents.lastTimestamp = Date.now();
Meeting.changeTranslatorSpeackState(languageExtension, translatorIsSpeaking);
}
});
this.translatorSpeechEvents.on('stopped_speaking', () => {
this.$translatorSpeakingChanged.next(false);
Meeting.changeTranslatorSpeackState(languageExtension, false);
console.log("stopped speaking")
});
const callOptions = {
......
......@@ -819,6 +819,7 @@
"app.translation.language.connection.established": "✓",
"app.translation.language.connection.settingUp": "...",
"app.translation.filterMarker.languageListening": "hören",
"app.translation.filterMarker.languageTranslating": "sprechen"
"app.translation.filterMarker.languageTranslating": "sprechen",
"app.translation.speechDetectionThreshold": "Sprachschwellenwert f. Übersetzer"
}
......@@ -830,6 +830,7 @@
"app.translation.language.connection.established": "✓",
"app.translation.language.connection.settingUp": "...",
"app.translation.filterMarker.languageListening": "listening",
"app.translation.filterMarker.languageTranslating": "speaking"
"app.translation.filterMarker.languageTranslating": "speaking",
"app.translation.speechDetectionThreshold": "Translator speech detection threshold"
}
{
"requires": true,
"lockfileVersion": 1,
"dependencies": {
"rxjs": {
"version": "7.1.0",
"resolved": "https://registry.npmjs.org/rxjs/-/rxjs-7.1.0.tgz",
"integrity": "sha512-gCFO5iHIbRPwznl6hAYuwNFld8W4S2shtSJIqG27ReWXo9IWrCyEICxUA+6vJHwSR/OakoenC4QsDxq50tzYmw==",
"requires": {
"tslib": "~2.1.0"
}
},
"tslib": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.1.0.tgz",
"integrity": "sha512-hcVC3wYEziELGGmEEXue7D75zbwIIVUMWAVbHItGPx0ziyXxrOMQx4rQEVEV45Ut/1IotuEvwqPopzIOkDMf0A=="
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment