mirror of
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
synced 2025-10-01 23:56:39 +08:00
修复语音识别小bug
This commit is contained in:
parent
24eb62f5e9
commit
868cf96cc8
@ -47,8 +47,7 @@ export default function VoiceInput({
|
||||
|
||||
function onRecognizedResult(result: SpeechRecognitionResult) {
|
||||
// setVoiceInputText("");
|
||||
setVoiceInputText(`${result.text}`);
|
||||
|
||||
setVoiceInputText(`${result.text ?? ""}`);
|
||||
let intentJson = result.properties.getProperty(
|
||||
ms_audio_sdk.PropertyId.LanguageUnderstandingServiceResponse_JsonResult,
|
||||
);
|
||||
@ -57,8 +56,6 @@ export default function VoiceInput({
|
||||
}
|
||||
|
||||
// setTempUserInput("");
|
||||
console.log("3333", tempUserInput, "2", voiceInputText);
|
||||
|
||||
// if (result?.translations) {
|
||||
// let resultJson = JSON.parse(result.json);
|
||||
// resultJson['privTranslationPhrase']['Translation']['Translations'].forEach(
|
||||
@ -89,12 +86,11 @@ export default function VoiceInput({
|
||||
setUserInput(
|
||||
tempUserInput +
|
||||
voiceInputText.replace(/(.*)(^|[\r\n]+).*\[\.\.\.][\r\n]+/, "$1$2") +
|
||||
`${result.text} [...]`,
|
||||
`${result.text ?? ""} [...]`,
|
||||
);
|
||||
|
||||
setVoiceInputText(
|
||||
voiceInputText.replace(/(.*)(^|[\r\n]+).*\[\.\.\.][\r\n]+/, "$1$2") +
|
||||
`${result.text} [...]`,
|
||||
`${result.text ?? ""} [...]`,
|
||||
);
|
||||
}
|
||||
|
||||
@ -130,12 +126,10 @@ export default function VoiceInput({
|
||||
recognizer.current.recognizeOnceAsync(
|
||||
(result) => {
|
||||
onRecognizedResult(result);
|
||||
|
||||
setUserInput(tempUserInput + voiceInputText ?? "" + `${result.text}`);
|
||||
// setVoiceInputText(result.text);
|
||||
console.log("result", result.text);
|
||||
setUserInput(
|
||||
tempUserInput + (voiceInputText ?? "") + `${result.text ?? ""}`,
|
||||
);
|
||||
setVoiceInputLoading(false);
|
||||
// recognizer.close();
|
||||
},
|
||||
(err) => {
|
||||
console.error("Recognition error: ", err); // 错误处理
|
||||
|
Loading…
Reference in New Issue
Block a user