php - Compress base64 encoded binary data -


i'm making api request audio files language learning app. request seems take 2-3 seconds return, far long needs.

i need pass them php script in smallest way possible.

how can send binary data, such requested audio file, in fastest way possible?

code if needed:

js request:

$.get('testphp.php/translate_tts?ie=utf-8&tl=zh-cn&q=你好',     function (returned_data) {         document.getelementbyid("audio").innerhtml=             '<embed src="data:audio/mpeg;base64,'+returned_data+'" hidden="true" autostart="true" loop="false"/>'; 

php:

$params = http_build_query(array("ie" => $_get['ie'],"tl" => $_get["tl"], "q" => $_get["q"])); $ctx = stream_context_create(array("http"=>array("method"=>"get","header"=>"referer: \r\n")));  $soundfile = file_get_contents("https://translate.google.com/translate_tts?".$params, false, $ctx);   header("content-type: text/plain; charset=utf-8"); header("content-transfer-encoding: binary"); header('pragma: no-cache'); header('expires: 0');  echo base64_encode($soundfile); 


Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -