title: How to play audio file in all browsers?
body: <p>I'm making a simple copy of Google's TTS. All the code is working and have 2 buttons, one downloads the audio-clip and the second should let you listen to the audio before downloading.</p>
  <p>The listen button does what it should and plays the audio on Mozilla Firefox. All other browsers just open a new tab and their built-in media player is displayed, but don't actually play the clip.</p>
  <p>Here is the PHP code for the Listen button:</p>
  <pre><code>&lt;?php
  require __DIR__ . '/vendor/autoload.php';
   
  use Google\Cloud\TextToSpeech\V1\AudioConfig;
  use Google\Cloud\TextToSpeech\V1\AudioEncoding;
  use Google\Cloud\TextToSpeech\V1\SsmlVoiceGender;
  use Google\Cloud\TextToSpeech\V1\SynthesisInput;
  use Google\Cloud\TextToSpeech\V1\TextToSpeechClient;
  use Google\Cloud\TextToSpeech\V1\VoiceSelectionParams;
  /** Retrieve values from html form **/
  $text = $_POST['textinput'];
  $language = $_POST['language'];
  $voicename = $_POST['voicename'];
  $pitch = $_POST['pitchInput'];
  $speed = $_POST['speedInput'];
  // create client object
  $client = new TextToSpeechClient();
  $input_text = (new SynthesisInput())
      -&gt;setText($text);
  // voice and audio configuration
  $voice = (new VoiceSelectionParams())
      -&gt;setLanguageCode($language)        
      -&gt;setName($voicename)
      -&gt;setSsmlGender(SsmlVoiceGender::FEMALE);
  $audioConfig = (new AudioConfig())
      -&gt;setPitch($pitch)
      -&gt;setSpeakingRate($speed)
      -&gt;setAudioEncoding(AudioEncoding::MP3);
  $response = $client-&gt;synthesizeSpeech($input_text, $voice, $audioConfig);
  $audioContent = $response-&gt;getAudioContent();
  file_put_contents('output.mp3', $audioContent);
  print('Audio content written to &quot;output.mp3&quot;' . PHP_EOL);
  header('Content-Type: audio/mpeg');
  header('Content-Disposition: inline; filename= &quot;output.mp3&quot; ');
  readfile('output.mp3',$audioContent);
  $client-&gt;close();
  ?&gt;
  </code></pre>