首页 > 解决方案 > 使用反应文本到语音

问题描述

我正在使用来自此链接https://www.readspeaker.com/text-to-speech-demo/的名为 read speaker 的服务使用以下代码进行文本到语音:

 fetch('https://tts.readspeaker.com/a/speak?key=xxx&lang=sv_fi&voice=Samuel&text=veta', {
            method: 'get',
            // headers: {
            //     'Content-Type': 'application/json'
            // },
            mode: 'no-cors'

        })
            .then(response => {
                 console.log("RESPONSE: ", response);
            })
            .catch(error => {
                console.log("ERROR: ", error);
            })

出于某种原因,响应显示如下: 错误:未指定密钥或指定无效密钥,但我提供了正确的 api 密钥。

删除方法时:'POST' 我得到以下响应:

body: (...)
bodyUsed: false
headers: Headers {}
ok: false
redirected: false
status: 0
statusText: ""
type: "opaque"
url: ""

我不知道该怎么做或有什么问题!

标签: javascriptreactjsreadspeaker

解决方案


推荐阅读