I cannot retrieve the transcript value with javascript using XMLHttpRequest, what's wrong with my code? everything works fine but i need the return value of transcript variable which is a long text
@app.route("/transcribe", methods=['POST'])
def transcribe():
transcript = ""
videos = glob.glob("static/uploads/video/*")
ToEmptyDir()
for video in videos:
prs = parse_seconde(video)
transcript = cut_video(prs, video).lstrip()
insertToFile(video.split("\\")[1].split(".")[0], transcript)
txtFile = glob.glob(os.getcwd() + "/*.txt")
return transcript
index.html :
<button type="button" id="transcribe" onclick="loadTranscribeFile()"> Transcribe </button>
<script>
function loadTranscribeFile(callback) {
var req = new XMLHttpRequest();
req.open('POST', '/transcribe', true);
req.responseType = 'json';
req.send("textTranscribed=" + document.getElementById('textTranscribed').value);
}
</script>
try this
req.onreadystatechange = function(res){
if (req.readyState == 4 && req.status == 200){
var t = JSON.parse(req.responseText)
console.log(t);
}
}