有没有办法使用Annyang语音识别API在React框架上实现文本到语音?

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

我正在尝试实现类似于Google ok搜索引擎的Web应用程序。

我在我的React Web应用程序中使用语音识别API。

我已经成功地实现了语音到文本。现在我想使用语音识别API在我的React Web应用程序中实现文本到语音,但我在他们的文档中找不到任何内容。

这是我的代码:

import React, { Component } from 'react';
reactjs
2个回答
0
投票

试试这个包react-speech-recognition

   import React, { PropTypes, Component } from 'react'
   import SpeechRecognition from 'react-speech-recognition'

    const propTypes = {
      // Props injected by SpeechRecognition
      transcript: PropTypes.string,
      resetTranscript: PropTypes.func,
      browserSupportsSpeechRecognition: PropTypes.bool
    }

    class Dictaphone extends Component {
      render() {
        const { transcript, resetTranscript, browserSupportsSpeechRecognition } = this.props

        if (!browserSupportsSpeechRecognition) {
          return null
        }

        return (
          <div>
            <button onClick={resetTranscript}>Reset</button>
            <span>{transcript}</span>
          </div>
        )
      }
    }

    Dictaphone.propTypes = propTypes

    export default SpeechRecognition(Dictaphone)

0
投票

您可以将react-speech npm用于文本到语音和语音到文本。

这是GitHub存储库:https://github.com/andrewkeig/react-speech

© www.soinside.com 2019 - 2024. All rights reserved.