'How to use resemble ai api
I have tried to create a project in which I can use my voice in text to speech in Javascript but I recieved an error saying this.
https://i.stack.imgur.com/fnIpg.png
Here's my code:-
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<title>Document</title>
</head>
<body>
<input class="form-control" id="text">
<br>
<button type="button" class="btn btn-primary btn-lg" id="speak">Speak</button>
<script>
var HttpClient = function() {
this.get = function(aUrl, aCallback) {
var anHttpRequest = new XMLHttpRequest();
anHttpRequest.onreadystatechange = function() {
if (anHttpRequest.readyState == 4 && anHttpRequest.status == 200)
aCallback(anHttpRequest.responseText);
}
anHttpRequest.open("GET", aUrl, true);
anHttpRequest.send(null);
}
}
var theurl = 'https://app.resemble.ai/api/v2/voices/14ebc696';
var client = new HttpClient();
client.get(theurl, function(response) {
response1 = resemble.voices.get('14ebc696');
});
const Resemble = require('@resemble/node')
const resemble = new Resemble('v2', 'zDoirHoJUI3xhHHnrPBH7wtt')
var text = document.querySelector('#text');
var speak = document.querySelector('#speak');
let voices = [];
function speakNow(){
var speech = new SpeechSynthesisUtterance();
speech.rate = .7;
speech.pitch = 1;
speech.volume = 1;
speech.voice = response1;
speech.text = text.value;
speechSynthesis.speak(speech);
}
speak.onclick = function (e) {
e.preventDefault();
speakNow();
}
</script>
</body>
</html>
And you can also view my project here:- https://github.com/Rohit4021/Resemble-AI---Javascript
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
