mirror of
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
synced 2025-10-01 23:56:39 +08:00
feat: 语音选择
This commit is contained in:
parent
5e514c5655
commit
b91c224d75
@ -558,10 +558,12 @@ export function ChatActions(props: {
|
||||
|
||||
useEffect(() => {
|
||||
if (isFirefox()) config.sttConfig.engine = FIREFOX_DEFAULT_STT_ENGINE;
|
||||
const lang = config.sttConfig.lang;
|
||||
setSpeechApi(
|
||||
config.sttConfig.engine !== DEFAULT_STT_ENGINE
|
||||
? new WebTranscriptionApi((transcription) =>
|
||||
onRecognitionEnd(transcription),
|
||||
? new WebTranscriptionApi(
|
||||
(transcription) => onRecognitionEnd(transcription),
|
||||
lang,
|
||||
)
|
||||
: new OpenAITranscriptionApi((transcription) =>
|
||||
onRecognitionEnd(transcription),
|
||||
|
@ -55,10 +55,10 @@ export function STTConfigList(props: {
|
||||
{props.sttConfig.engine === "Web Speech API" && !isFirefox() && (
|
||||
<ListItem title="语言选择">
|
||||
<Select
|
||||
value={props.sttConfig.language}
|
||||
value={props.sttConfig.lang}
|
||||
onChange={(e) => {
|
||||
props.updateConfig(
|
||||
(config) => (config.language = e.currentTarget.value),
|
||||
(config) => (config.lang = e.currentTarget.value),
|
||||
);
|
||||
}}
|
||||
>
|
||||
|
@ -95,7 +95,7 @@ export const DEFAULT_CONFIG = {
|
||||
sttConfig: {
|
||||
enable: true,
|
||||
engine: DEFAULT_STT_ENGINE,
|
||||
language: DEFAULT_STT_LANGUAGE,
|
||||
lang: DEFAULT_STT_LANGUAGE,
|
||||
},
|
||||
};
|
||||
|
||||
|
@ -93,7 +93,7 @@ export class WebTranscriptionApi extends SpeechApi {
|
||||
|
||||
isListening = () => this.listeningStatus;
|
||||
|
||||
constructor(transcriptionCallback?: TranscriptionCallback) {
|
||||
constructor(transcriptionCallback?: TranscriptionCallback, lang?: string) {
|
||||
super();
|
||||
if (isFirefox()) return;
|
||||
const SpeechRecognition =
|
||||
@ -102,7 +102,7 @@ export class WebTranscriptionApi extends SpeechApi {
|
||||
this.recognitionInstance = new SpeechRecognition();
|
||||
this.recognitionInstance.continuous = true;
|
||||
this.recognitionInstance.interimResults = true;
|
||||
this.recognitionInstance.lang = getSTTLang();
|
||||
this.recognitionInstance.lang = lang ?? getSTTLang();
|
||||
if (transcriptionCallback) {
|
||||
this.onTranscriptionReceived(transcriptionCallback);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user