Text to speech

פרמיום
על ידי kelvin | מְעוּדכָּן 1ヶ月前 | Tools
פּוֹפּוּלָרִיוּת

9.5 / 10

חֶבִיוֹן

251ms

רמת שירות

100%

Health Check

N/A

חזרה לכל הדיונים

how to use audio sound

Rapid account: Rosly Dev
RoslyDev
1年前

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ヶ月前

Thank’s i solve the problem

Rapid account: Kelvin 2 Go
kelvin2go Commented 1年前

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

Rapid account: Rosly Dev
RoslyDev Commented 1年前

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 1年前

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>

הצטרף לדיון - הוסף תגובה למטה:

התחבר / הירשם כדי לפרסם תגובות חדשות