语音转文字识别不准确

问题描述 投票:0回答:2

我正在尝试在我的 React 网站中实现语音到文本识别,并且我正在使用 npm 中的

react-speech-recognition
包。我正在使用他们在此处的包描述中指定的确切代码:npm
现在它适用于日常言语,我所说的任何内容,但当我引入技术术语时,它就大错特错了!

这就是我想对它说的话,这是航空术语:

Cleared to enter the CTR, not above 1500 feet, join and report on a right downwind runway 19, QNH 1018, squak 2732

这是我得到的回复:

please to enter the city are not above 15 feet heart penetrate join and report on a ride on the wind blown away 9 theme

我还需要做什么来修复识别的准确性?
javascript reactjs text-to-speech
2个回答
2
投票

该软件包利用浏览器的 Web 语音 API语音识别接口。 React 库的 API 允许您通过调用

SpeechRecognition
 方法来获取底层 
getRecognition()
对象。

底层 SpeechRecognition 对象的 API 允许使用 JSpeech Grammar Format 添加语法。 这是一个例子。因此从理论上讲,您可以提供有关您希望在应用程序中听到的单词的更多信息,从而提高性能。

但也有一些注意事项,包括:

  • 一般来说,对于语音识别,特别是对于语法的添加,浏览器支持非常有限。显然,如果您无法控制用户将使用什么浏览器,这意味着识别质量会有所不同,并且如果您不使用 Polyfills,则可能根本无法工作。 根据语音识别的实现方式,硬件配置和操作系统等因素可能会影响语音识别结果。
  • 语音识别是一门极其不精确的科学。即使是普通语音,最好的自动语音识别软件/服务的准确率也只有 85% 左右。您的浏览器中内置的可能不会那么好。
  • 您也许能够通过基于云的语音服务获得更高的准确性。例如,
Azure 认知服务

允许您创建自定义语音模型、自定义语法等。当然,它们还会根据使用情况向您收费,如果您使用自定义,它们会收取更多费用。


0
投票

为了获得准确且连续的结果:

const { transcript, finalTranscript, listening, resetTranscript, browserSupportsSpeechRecognition } = useSpeechRecognition({ lang: "en-IN", // Set the language to Indian English interimResults: true, // Get partial results continuous: true, // Enable continuous recognition maxAlternatives: 5, // Set the number of alternative transcriptions });


    SpeechRecognition.startListening({ continuous: true, language: 'en-IN' }); // Set the language to Indian English
  • react-speech-recognition 库允许您指定语音识别引擎的语言和方言。选择与用户的语音模式相匹配的适当语言和方言至关重要。例如,如果您的应用程序面向具有印度英语口音的用户,则应将语言设置为“en-IN”(英语 - 印度)以优化识别准确性。

对于冗长的对话:

const { transcript, finalTranscript, listening, resetTranscript, browserSupportsSpeechRecognition } = useSpeechRecognition({ lang: "en-IN", // Set the language to Indian English interimResults: true, // Get partial results continuous: true, // Enable continuous recognition maxAlternatives: 5, // Set the number of alternative transcriptions abortController: new AbortController(), // Create a new AbortController instance}); const [abortController, setAbortController] = useState(new AbortController());

const handleStopRecording = () => {
    stopRecording();
    setAbortController(new AbortController()); // Create a new AbortController instance};

const stopRecording = () => {
    setRecordingStatus("inactive");
    abortController.abort(); // Abort the speech recognition
    SpeechRecognition.stopListening();
// rest of the logic
}


冗长而快速的对话

    使用 useCallback 钩子记忆 startRecording 和 stopRecording 函数 将 abortController 实例的创建移至handleStartRecording 和handleStopRecording 函数。这确保每次都会创建一个新的 abortController。
  • const stopRecording = useCallback(() => {...,[abortController]} const startRecording = useCallback(() => {...,[abortController]}

    
    
const handleStartRecording = () => { startRecording(); setAbortController(new AbortController()); // Create a new AbortController instance }; const handleStopRecording = () => { stopRecording(); setAbortController(new AbortController()); // Create a new AbortController instance };
© www.soinside.com 2019 - 2024. All rights reserved.