PHP code example of mathsgod / microsoft-tts

1. Go to this page and download the library: Download mathsgod/microsoft-tts library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

mathsgod / microsoft-tts example snippets


use Microsoft\CognitiveServices\Speech\TTS;

 new TTS($key, $region);
$tts->save('Hello World', 'hello-world.mp3');

$format=TTS::AUDIO_24KHZ_160KBITRATE_MONO_MP3;
$voice="zh-HK-HiuGaaiNeural";
$tts->save('Hello World', 'hello-world.mp3', $format, $voice);

$voices=$tts->getVoicesList();