Google TTS API: Encoding GET request with PHP -
--- solved ---
problem solved. solution simple:
file_get_contents("http://translate.google.com/translate_tts?tl=de&q=".urlencode($str)."&ie=utf-8")
to coming here search engine: make sure set file charset utf-8, include ie=utf-8 parameter url, urlencode string. should fine then.
original post was:
i have problem making php send correctly encoded request google tts api.
$str='this german string contains crazy umlaute ä (like in häuser) or ü (like in Übermensch). sehr deutsch halt.'; file_get_contents("http://translate.google.com/translate_tts?tl=de&q=".$str."&ie=utf-8");
all included php files encoded in utf-8 (no byte order marks). google tts returns me mp3 file spells "umlaute" not Übermensch, a~1/4bermensch. problem has nothing client side.
i think google expecting ascii string, might problem? when type line browser manually however, spells correctly. see also:
stackoverflow - google tts api arabic, chinese , greek
thanks help!!
you have set encoding url parameter &ie=utf-8 , encoding of python file to: #coding: utf-8 , sure safe .py file utf-8 encoding (not iso-8859-1).
Comments
Post a Comment