Text to speech

免费增值
通过 kelvin | 已更新 24日前 | Tools
人气

9.6 / 10

延迟

254ms

服务等级

100%

Health Check

N/A

返回所有讨论

how to use audio sound

Rapid account: Rosly Dev
RoslyDev
10 mesi fa

hello I have all the problems in the world with your api, I obviously can’t use the answer
and in addition there is no documentation on how to do this, can you help me?

Rapid account: Rosly Dev
RoslyDev Commented 10 mesi fa

Thank’s i solve the problem

Rapid account: Kelvin 2 Go
kelvin2go Commented 10 mesi fa

whats language of BE do you use? i can give a example for that

Rapid account: Rosly Dev
RoslyDev Commented 10 mesi fa

I see, already thank you very much for your quick response but unfortunately I still have some concerns (PS js is not my cup of tea yet because I do more backend)

Basically I converted the blob to mpeg audio in my code but I couldn’t play the sound.

now i am more enlightened but i don’t know where to place the fast api option array?

const options = {
method: ‘GET’,
url: ‘https://text-to-speech27.p.rapidapi.com/speech’,
params: {
text: text,
lang: ‘fr’
},
headers: {
‘X-RapidAPI-Key’: ‘’,
‘X-RapidAPI-Host’: '
}
};

I have to put them in the StreamUrl? or https://text-to-speech27.p.rapidpi.com/speech?

Rapid account: Kelvin 2 Go
kelvin2go Commented 10 mesi fa

hi there,
like a html you can play the audio with call api like below

<audio id="audioPlayer" controls></audio>

<script>
  const audioPlayer = document.getElementById('audioPlayer');
  const streamUrl = 'your-api-endpoint-url';

  fetch(streamUrl)
    .then(response => response.blob())
    .then(blob => {
      const mediaSource = new MediaSource();
      audioPlayer.src = URL.createObjectURL(mediaSource);

      mediaSource.addEventListener('sourceopen', () => {
        const sourceBuffer = mediaSource.addSourceBuffer('audio/mpeg');
        sourceBuffer.addEventListener('updateend', () => {
          mediaSource.endOfStream();
          audioPlayer.play();
        });
        sourceBuffer.appendBuffer(blob);
      });
    });
</script>

加入讨论 - 在下面添加评论:

登录/注册以发布新的评论