Add audio input settings and effects in App.jsx
This commit is contained in:
35
src/App.jsx
35
src/App.jsx
@@ -1133,6 +1133,8 @@ async function regenerateFromIndex(index, overrideUserText = null) {
|
|||||||
setColorScheme(settings.colorScheme || 'Default');
|
setColorScheme(settings.colorScheme || 'Default');
|
||||||
setModel(settings.chatModel || ''); // Load the selected model, with a fallback
|
setModel(settings.chatModel || ''); // Load the selected model, with a fallback
|
||||||
setStreamOutput(settings.streamOutput || false);
|
setStreamOutput(settings.streamOutput || false);
|
||||||
|
setAudioInputEnabled(settings.audioInputEnabled === true);
|
||||||
|
setAudioInputDeviceId(typeof settings.audioInputDeviceId === 'string' ? settings.audioInputDeviceId : '');
|
||||||
setScrollPositions(settings.scrollPositions || {}); // Load scroll positions
|
setScrollPositions(settings.scrollPositions || {}); // Load scroll positions
|
||||||
applyColorScheme(settings.colorScheme || 'Default'); // Apply initial scheme
|
applyColorScheme(settings.colorScheme || 'Default'); // Apply initial scheme
|
||||||
}).finally(() => {
|
}).finally(() => {
|
||||||
@@ -1192,6 +1194,39 @@ async function regenerateFromIndex(index, overrideUserText = null) {
|
|||||||
setIsChatDragActive(false)
|
setIsChatDragActive(false)
|
||||||
}, [selectedModelSupportsVision, activeSidebarMode])
|
}, [selectedModelSupportsVision, activeSidebarMode])
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (audioInputEnabled || !isRecordingAudio) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
stopAudioRecording({ shouldTranscribe: false })
|
||||||
|
}, [audioInputEnabled, isRecordingAudio])
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (activeSidebarMode === 'chats' || !isRecordingAudio) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
stopAudioRecording()
|
||||||
|
}, [activeSidebarMode, isRecordingAudio])
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
return () => {
|
||||||
|
audioTranscriptionAbortRef.current?.abort()
|
||||||
|
clearAudioTimers()
|
||||||
|
const recorder = audioRecorderRef.current
|
||||||
|
if (recorder) {
|
||||||
|
recorder.ondataavailable = null
|
||||||
|
recorder.onstop = null
|
||||||
|
recorder.onerror = null
|
||||||
|
try {
|
||||||
|
if (recorder.state !== 'inactive') {
|
||||||
|
recorder.stop()
|
||||||
|
}
|
||||||
|
} catch {}
|
||||||
|
}
|
||||||
|
stopMediaStream(audioStreamRef.current)
|
||||||
|
}
|
||||||
|
}, [])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!settingsLoaded || loading || !backendApiUrl || startupOllamaCheckRanRef.current) return
|
if (!settingsLoaded || loading || !backendApiUrl || startupOllamaCheckRanRef.current) return
|
||||||
startupOllamaCheckRanRef.current = true
|
startupOllamaCheckRanRef.current = true
|
||||||
|
|||||||
Reference in New Issue
Block a user