feat: productionize learning engine and classroom
This commit is contained in:
@@ -46,5 +46,6 @@ export function useASRAvailable(): boolean {
|
||||
const modelOk = !!builtIn || (providerConfig?.customModels?.length ?? 0) > 0;
|
||||
const browserOk = asrProviderId !== 'browser-native' || browserSpeechSupported;
|
||||
|
||||
if (typeof window !== 'undefined' && window.__MAKELORE_COURSE_CONTEXT__) return true;
|
||||
return asrEnabled && keyOk && modelOk && browserOk;
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ import { useState, useRef, useCallback } from 'react';
|
||||
import { ASR_PROVIDERS } from '@/lib/audio/constants';
|
||||
import { normalizeASRUploadAudio } from '@/lib/audio/wav-utils';
|
||||
import { createLogger } from '@/lib/logger';
|
||||
import { transcribeMakeloreLearningAudio } from '@/lib/makelore-runtime/browser-bridge';
|
||||
|
||||
const log = createLogger('AudioRecorder');
|
||||
|
||||
@@ -45,6 +46,14 @@ export function useAudioRecorder(options: UseAudioRecorderOptions = {}) {
|
||||
const { useSettingsStore } = await import('@/lib/store/settings');
|
||||
const { asrProviderId, asrLanguage, asrProvidersConfig } = useSettingsStore.getState();
|
||||
const uploadAudio = await normalizeASRUploadAudio(asrProviderId, audioBlob);
|
||||
if (window.__MAKELORE_COURSE_CONTEXT__) {
|
||||
const text = await transcribeMakeloreLearningAudio(uploadAudio.blob, {
|
||||
fileName: uploadAudio.fileName,
|
||||
language: asrLanguage,
|
||||
});
|
||||
onTranscription?.(text);
|
||||
return;
|
||||
}
|
||||
formData.append('audio', uploadAudio.blob, uploadAudio.fileName);
|
||||
|
||||
formData.append('providerId', asrProviderId);
|
||||
@@ -105,7 +114,7 @@ export function useAudioRecorder(options: UseAudioRecorderOptions = {}) {
|
||||
const { asrProviderId, asrLanguage } = useSettingsStore.getState();
|
||||
|
||||
// Use browser native ASR if configured
|
||||
if (asrProviderId === 'browser-native') {
|
||||
if (asrProviderId === 'browser-native' && !window.__MAKELORE_COURSE_CONTEXT__) {
|
||||
// Check if Speech Recognition is supported
|
||||
if (!window.SpeechRecognition && !window.webkitSpeechRecognition) {
|
||||
onError?.('您的浏览器不支持语音识别功能');
|
||||
|
||||
@@ -31,7 +31,7 @@ import {
|
||||
isAbortError,
|
||||
withGenerationRetry,
|
||||
type GenerationRetryOptions,
|
||||
} from '@openmaic/generation';
|
||||
} from '@openmaic/generation/generation-retry';
|
||||
|
||||
const log = createLogger('SceneGenerator');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user