mirror of
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
synced 2025-10-01 07:36:39 +08:00
chore: wip
This commit is contained in:
parent
5999604df4
commit
80a7a1d9d0
@ -370,6 +370,7 @@ export function ChatAction(props: {
|
||||
text: string;
|
||||
icon: JSX.Element;
|
||||
onClick: () => void;
|
||||
recording?: boolean;
|
||||
}) {
|
||||
const iconRef = useRef<HTMLDivElement>(null);
|
||||
const textRef = useRef<HTMLDivElement>(null);
|
||||
@ -378,7 +379,7 @@ export function ChatAction(props: {
|
||||
icon: 16,
|
||||
});
|
||||
|
||||
function updateWidth() {
|
||||
function updateWidth(recording?: boolean) {
|
||||
if (!iconRef.current || !textRef.current) return;
|
||||
const getWidth = (dom: HTMLDivElement) => dom.getBoundingClientRect().width;
|
||||
const textWidth = getWidth(textRef.current);
|
||||
@ -559,7 +560,7 @@ export function ChatActions(props: {
|
||||
useEffect(() => {
|
||||
if (isFirefox()) config.sttConfig.engine = FIREFOX_DEFAULT_STT_ENGINE;
|
||||
setSpeechApi(
|
||||
config.sttConfig.engine === DEFAULT_STT_ENGINE
|
||||
config.sttConfig.engine !== DEFAULT_STT_ENGINE
|
||||
? new WebTranscriptionApi((transcription) =>
|
||||
onRecognitionEnd(transcription),
|
||||
)
|
||||
@ -570,6 +571,7 @@ export function ChatActions(props: {
|
||||
}, []);
|
||||
|
||||
const startListening = async () => {
|
||||
showToast(Locale.Chat.StartSpeak);
|
||||
if (speechApi) {
|
||||
await speechApi.start();
|
||||
setIsListening(true);
|
||||
@ -582,6 +584,7 @@ export function ChatActions(props: {
|
||||
await speechApi.stop();
|
||||
setIsListening(false);
|
||||
}
|
||||
showToast(Locale.Chat.CloseSpeak);
|
||||
};
|
||||
const onRecognitionEnd = (finalTranscript: string) => {
|
||||
console.log(finalTranscript);
|
||||
@ -832,6 +835,7 @@ export function ChatActions(props: {
|
||||
}
|
||||
text={isListening ? Locale.Chat.StopSpeak : Locale.Chat.StartSpeak}
|
||||
icon={isListening ? <VoiceOpenIcon /> : <VoiceCloseIcon />}
|
||||
recording={isListening}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
|
@ -271,8 +271,8 @@ export const DEFAULT_TTS_VOICES = [
|
||||
"shimmer",
|
||||
];
|
||||
|
||||
export const DEFAULT_STT_ENGINE = "Web Speech API";
|
||||
export const DEFAULT_STT_ENGINES = ["Web Speech API", "OpenAI Whisper"];
|
||||
export const DEFAULT_STT_ENGINE = "OpenAI Whisper";
|
||||
export const DEFAULT_STT_ENGINES = ["OpenAI Whisper", "Web Speech API"];
|
||||
export const DEFAULT_STT_LANGUAGE = "zh-CN";
|
||||
export const DEFAULT_STT_LANGUAGES = [
|
||||
"zh-CN", // 中文(简体)
|
||||
|
@ -92,8 +92,9 @@ const cn = {
|
||||
return inputHints + ",/ 触发补全,: 触发命令";
|
||||
},
|
||||
Send: "发送",
|
||||
StartSpeak: "说话",
|
||||
StopSpeak: "停止",
|
||||
StartSpeak: "启用语音输入",
|
||||
CloseSpeak: "关闭语音输入",
|
||||
StopSpeak: "录音中....点击结束",
|
||||
Config: {
|
||||
Reset: "清除记忆",
|
||||
SaveAs: "存为面具",
|
||||
|
@ -94,7 +94,8 @@ const en: LocaleType = {
|
||||
},
|
||||
Send: "Send",
|
||||
StartSpeak: "Start Speak",
|
||||
StopSpeak: "Stop Speak",
|
||||
CloseSpeak: "Stop Speak",
|
||||
StopSpeak: "Recording...",
|
||||
Config: {
|
||||
Reset: "Reset to Default",
|
||||
SaveAs: "Save as Mask",
|
||||
|
Loading…
Reference in New Issue
Block a user