简体   繁体   English

VoiceRSS文本到语音API的特殊字符

[英]Special characters with the VoiceRSS text-to-speech API

I'm trying to make the VoiceRSS API working with french special characters and I don't manage to do it. 我正在尝试使VoiceRSS API使用法语特殊字符,但我没有做到这一点。

Here is my PHP code : 这是我的PHP代码:

<?php

    $text = htmlentities("fédéré"); // "fédéré" means "federated"
    $filename = "test.mp3";

    $querystring = (http_build_query(array(
    "src" => $text,
    "key" => "e913cc4ffc2148f18ddfdcda118b7391",
    "hl" => "fr-fr",
    "r" => "0",
    "c" => "mp3",
    "f" => "22khz_16bit_mono"
    )));

    $url = "http://api.voicerss.org?".$querystring;
    $soundfile = file_get_contents($url);
    file_put_contents($filename,$soundfile);

    echo 'API = <a href="http://api.voicerss.org?'.$querystring.'" target="_blank">http://api.voicerss.org?'.$querystring.'</a><br /><br />';
    echo 'MP3 file generated = <a href="./'.$filename.'" target="_blank">'.$filename.'</a>';

?>

As it is, the word "fédéré" becomes : 实际上,“fédéré”一词变为:

f%26Atilde%3B%26copy%3Bd%26Atilde%3B%26copy%3Br%26Atilde%3B%26copy%3B

How could I resolve this in the URL and also in the sound of the MP3 file generated ? 如何在URL和生成的MP3文件的声音中解决此问题?

删除$text上的htmlentities() -由于您在http_build_query使用它,它将自动为您编码字符串。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM