Text-To-Speech

FREEMIUM
Par kynesys | Mise à jour 2달 전 | Text Analysis
Health Check

N/A

Retour à tous les tutoriels (1)

How to Consume API in Web App

This example shows how to set the use the generated Text-to-speech response as the source for an HTML video element

HTML:

When the OutputType is set to stream, the response is a buffer array which can be converted into a URL as below

JS:
var dataArr = new Uint8Array(bstream) // bstream is API response where OutputType is stream
var blob = new Blob([dataArr.buffer]);
var url = URL.createObjectURL(blob);
var audio = document.getElementById(‘myplayer’);
audio.src = url

When the Output type is file, a url is returned so we can simply set it
JS:
var audio = document.getElementById(‘myplayer’);
audio.src = url //url is API response where OutputType is file