I have been researching into using PHP and Javascript to communicate with each other on the same page.
Firstly I have a php script at the top with a function to retrieve a audio from an AWS Ivona media stream.
<?php
function createAndPlay($text){
// request service get response save to `$data`
// I want this to then play the sound
}
?>
<script>
// when button clicked createAndPlay("Text to Speak")
<script>
I would like this to be done on the same page WITHOUT starting when the body of the document is first loaded.
Based on your last sentence:
It sounds like your situation is that all of this is working, but that the audio auto-plays when you load the page. That makes sense considering you have your call in a
<script>tag. Javascript will process it as soon as it sees it and play the audio. It is hard to say since you have not included that actual code.You would need to move the
scriptblock to a link or button or something: