Fix: ElevenLabs API Key Not Persisting (#6557)
Signed-off-by: Abhijay007 <Abhijay007j@gmail.com>
This commit is contained in:
@@ -2,6 +2,7 @@ import { DictationSettings, DictationProvider } from './useDictationSettings';
|
||||
|
||||
export const DICTATION_SETTINGS_KEY = 'dictation_settings';
|
||||
export const ELEVENLABS_API_KEY = 'ELEVENLABS_API_KEY';
|
||||
export const DICTATION_PROVIDER_OPENAI = 'openai' as const;
|
||||
export const DICTATION_PROVIDER_ELEVENLABS = 'elevenlabs' as const;
|
||||
|
||||
export const isSecretKeyConfigured = (response: unknown): boolean =>
|
||||
@@ -14,14 +15,12 @@ export const getDefaultDictationSettings = async (
|
||||
getProviders: (refresh: boolean) => Promise<Array<{ name: string; is_configured: boolean }>>
|
||||
): Promise<DictationSettings> => {
|
||||
const providers = await getProviders(false);
|
||||
|
||||
// Check if we have an OpenAI API key as primary default
|
||||
const openAIProvider = providers.find((p) => p.name === 'openai');
|
||||
|
||||
if (openAIProvider && openAIProvider.is_configured) {
|
||||
return {
|
||||
enabled: true,
|
||||
provider: 'openai' as DictationProvider,
|
||||
provider: DICTATION_PROVIDER_OPENAI,
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
|
||||
@@ -3,12 +3,16 @@ import { useConfig } from '../components/ConfigContext';
|
||||
import {
|
||||
DICTATION_SETTINGS_KEY,
|
||||
ELEVENLABS_API_KEY,
|
||||
DICTATION_PROVIDER_OPENAI,
|
||||
DICTATION_PROVIDER_ELEVENLABS,
|
||||
getDefaultDictationSettings,
|
||||
isSecretKeyConfigured,
|
||||
} from './dictationConstants';
|
||||
|
||||
export type DictationProvider = 'openai' | typeof DICTATION_PROVIDER_ELEVENLABS | null;
|
||||
export type DictationProvider =
|
||||
| typeof DICTATION_PROVIDER_OPENAI
|
||||
| typeof DICTATION_PROVIDER_ELEVENLABS
|
||||
| null;
|
||||
|
||||
export interface DictationSettings {
|
||||
enabled: boolean;
|
||||
@@ -28,7 +32,6 @@ export const useDictationSettings = () => {
|
||||
|
||||
useEffect(() => {
|
||||
const loadSettings = async () => {
|
||||
// Load settings from localStorage
|
||||
const saved = localStorage.getItem(DICTATION_SETTINGS_KEY);
|
||||
|
||||
let currentSettings: DictationSettings;
|
||||
|
||||
@@ -2,7 +2,7 @@ import { useState, useRef, useCallback, useEffect } from 'react';
|
||||
import { useConfig } from '../components/ConfigContext';
|
||||
import { getApiUrl } from '../config';
|
||||
import { useDictationSettings } from './useDictationSettings';
|
||||
import { DICTATION_PROVIDER_ELEVENLABS } from './dictationConstants';
|
||||
import { DICTATION_PROVIDER_OPENAI, DICTATION_PROVIDER_ELEVENLABS } from './dictationConstants';
|
||||
import { safeJsonParse } from '../utils/conversionUtils';
|
||||
|
||||
interface UseWhisperOptions {
|
||||
@@ -75,7 +75,7 @@ export const useWhisper = ({ onTranscription, onError, onSizeWarning }: UseWhisp
|
||||
|
||||
// Check provider availability
|
||||
switch (dictationSettings.provider) {
|
||||
case 'openai':
|
||||
case DICTATION_PROVIDER_OPENAI:
|
||||
setCanUseDictation(hasOpenAIKey);
|
||||
break;
|
||||
case DICTATION_PROVIDER_ELEVENLABS:
|
||||
@@ -178,7 +178,7 @@ export const useWhisper = ({ onTranscription, onError, onSizeWarning }: UseWhisp
|
||||
|
||||
// Choose endpoint based on provider
|
||||
switch (dictationSettings.provider) {
|
||||
case 'openai':
|
||||
case DICTATION_PROVIDER_OPENAI:
|
||||
endpoint = '/audio/transcribe';
|
||||
break;
|
||||
case DICTATION_PROVIDER_ELEVENLABS:
|
||||
|
||||
Reference in New Issue
Block a user