🎙️ Real-Time AI Voice & Response Generation

Use this API to interact with our AI voice assistant in real time. Simply provide your userId and speech_url to receive an AI-generated voice response as a streamed audio file.


Core Parameters

🛈 The parameters below define the request body for this API.

ParameterTypeRequired?Description
speech_urlstring✅ RequiredURL pointing to the input audio file

Request Body

Request body: 
{
  "speech_url": "https://example.com/your_audio.mp3"
}

Code Samples


      <input type="text" id="userId" value="user-123">
      <input type="text" id="speechUrl" value="https://example.com/speech.mp3">
      <button id="playButton">Play Voice</button>
      <audio id="audioPlayer" controls></audio>

      <script>
      async function getVoiceAudio() {
          const userId = document.getElementById("userId").value;
          const speechUrl = document.getElementById("speechUrl").value;

          const response = await fetch("https://api.soundverse.ai/v1/assistant/voice", {
          method: "POST",
          headers: {
              "Content-Type": "application/json",
              "Authorization": "Bearer your_api_key_here"
          },
          body: JSON.stringify({ speech_url: speechUrl }),
          });

          if (!response.ok || !response.body) {
          throw new Error("Failed to fetch audio");
          }

          const reader = response.body.getReader();
          const chunks = [];

          while (true) {
          const { done, value } = await reader.read();
          if (done) break;
          chunks.push(value);
          }

          const blob = new Blob(chunks, { type: "audio/mpeg" });
          const url = URL.createObjectURL(blob);

          const audio = document.getElementById("audioPlayer");
          audio.src = url;
          audio.play();
      }

      document.getElementById("playButton").addEventListener("click", getVoiceAudio);
      </script>

Response

If the request is valid, you’ll receive an audio data in chunks.

Response

HTTP/1.1 200 OK
Content-Type: audio/mpeg

Possible Errors :

  • Internal Server Error - 500 status code