Skip to content

Commit

Permalink
fix: default audio value for mute speaker
Browse files Browse the repository at this point in the history
  • Loading branch information
nzambello committed Sep 16, 2024
1 parent 34225bd commit 09022bc
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
13 changes: 13 additions & 0 deletions src/components/MemoriWidget/MemoriWidget.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,19 @@ WithoutAudio.args = {
AZURE_COGNITIVE_SERVICES_TTS_KEY: 'provide your key here',
};

export const WithoutAudioFromIntegrationConfig = Template.bind({});
WithoutAudioFromIntegrationConfig.args = {
memori,
tenant,
integration: {
...integration,
customData: JSON.stringify({
enableAudio: false,
}),
},
AZURE_COGNITIVE_SERVICES_TTS_KEY: 'provide your key here',
};

export const DefautSpeakerDisabled = Template.bind({});
DefautSpeakerDisabled.args = {
memori,
Expand Down
18 changes: 14 additions & 4 deletions src/components/MemoriWidget/MemoriWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,9 @@ const MemoriWidget = ({

const selectedLayout = layout || integrationConfig?.layout || 'DEFAULT';

const defaultEnableAudio =
enableAudio ?? integrationConfig?.enableAudio ?? false;

const [hasUserActivatedSpeak, setHasUserActivatedSpeak] = useState(false);
const [hasUserActivatedListening, setHasUserActivatedListening] =
useState(false);
Expand All @@ -504,8 +507,7 @@ const MemoriWidget = ({
const [showKnownFactsDrawer, setShowKnownFactsDrawer] = useState(false);
const [showExpertsDrawer, setShowExpertsDrawer] = useState(false);
const [muteSpeaker, setMuteSpeaker] = useState(
!(enableAudio ?? integrationConfig?.enableAudio ?? true) ||
!defaultSpeakerActive
!defaultEnableAudio || !defaultSpeakerActive
);
const [continuousSpeech, setContinuousSpeech] = useState(false);
const [continuousSpeechTimeout, setContinuousSpeechTimeout] = useState(2);
Expand Down Expand Up @@ -543,8 +545,16 @@ const MemoriWidget = ({
defaultControlsPosition = 'bottom';
}

setMuteSpeaker(getLocalConfig('muteSpeaker', !defaultSpeakerActive));
speakerMuted = getLocalConfig('muteSpeaker', !defaultSpeakerActive);
setMuteSpeaker(
getLocalConfig(
'muteSpeaker',
!defaultEnableAudio || !defaultSpeakerActive
)
);
speakerMuted = getLocalConfig(
'muteSpeaker',
!defaultEnableAudio || !defaultSpeakerActive
);
setContinuousSpeech(microphoneMode === 'CONTINUOUS');
setContinuousSpeechTimeout(getLocalConfig('continuousSpeechTimeout', 2));
setControlsPosition(
Expand Down

0 comments on commit 09022bc

Please sign in to comment.