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