This commit is contained in:
Hk-Gosuto 2024-03-26 17:02:41 +08:00
parent 70690f64c5
commit bd1a8dcc3a
4 changed files with 28 additions and 19 deletions

View File

@ -68,6 +68,7 @@ import {
getMessageImages,
isVisionModel,
compressImage,
isFirefox,
} from "../utils";
import dynamic from "next/dynamic";
@ -92,6 +93,7 @@ import { useNavigate } from "react-router-dom";
import {
CHAT_PAGE_SIZE,
DEFAULT_STT_ENGINE,
FIREFOX_DEFAULT_STT_ENGINE,
LAST_INPUT_KEY,
ModelProvider,
Path,
@ -903,6 +905,7 @@ function _Chat() {
}
});
// eslint-disable-next-line react-hooks/exhaustive-deps
if (isFirefox()) config.sttConfig.engine = FIREFOX_DEFAULT_STT_ENGINE;
setSpeechApi(
config.sttConfig.engine === DEFAULT_STT_ENGINE
? new WebTranscriptionApi((transcription) =>

View File

@ -3,6 +3,7 @@ import { STTConfig, STTConfigValidator } from "../store";
import Locale from "../locales";
import { ListItem, Select } from "./ui-lib";
import { DEFAULT_STT_ENGINES } from "../constant";
import { isFirefox } from "../utils";
export function STTConfigList(props: {
sttConfig: STTConfig;
@ -24,6 +25,7 @@ export function STTConfigList(props: {
}
></input>
</ListItem>
{!isFirefox() && (
<ListItem title={Locale.Settings.STT.Engine.Title}>
<Select
value={props.sttConfig.engine}
@ -43,6 +45,7 @@ export function STTConfigList(props: {
))}
</Select>
</ListItem>
)}
</>
);
}

View File

@ -136,6 +136,7 @@ export const DEFAULT_TTS_VOICES = [
export const DEFAULT_STT_ENGINE = "WebAPI";
export const DEFAULT_STT_ENGINES = ["WebAPI", "OpenAI Whisper"];
export const FIREFOX_DEFAULT_STT_ENGINE = "OpenAI Whisper";
export const DEFAULT_MODELS = [
{

View File

@ -1,5 +1,6 @@
import { ChatGPTApi } from "../client/platforms/openai";
import { getSTTLang } from "../locales";
import { isFirefox } from "../utils";
export type TranscriptionCallback = (transcription: string) => void;
@ -94,6 +95,7 @@ export class WebTranscriptionApi extends SpeechApi {
constructor(transcriptionCallback?: TranscriptionCallback) {
super();
if (isFirefox()) return;
const SpeechRecognition =
(window as any).SpeechRecognition ||
(window as any).webkitSpeechRecognition;