gpt4 book ai didi

PHP http_build_query 错误 "0="

转载 作者:行者123 更新时间:2023-12-03 23:06:57 25 4
gpt4 key购买 nike

您好,我正在使用此代码发布 url 并获取结果,但它在每个结果之前添加 =0

我的代码是

    <!DOCTYPE HTML>
<html>
<body>
<h1>In this demonstration:<br />
>tts is done on server side (i.e by using Google-translate server)<br/>
>then the audio received from Google-translate server is saved on your server (local/production)<br />
>and then that saved audio is played through that saved file on this webpage.</h1>
<h3>
Tested with:
Chrome v21 [Working],
Firefox v14 [Not Working, firefox does not support mp3 audio format playback],
IE v9[Working]
</h3>
<hr />
<form method="POST">
Text to convert : <input name="txt" type="text" /><br />
Filename to save (without the extension) : <input name="filename" type="text" /><br />
Convert text to speech : <input name="submit" type="submit" value="Convert" />
</form>

<?php
if (isset($_POST['txt']) && isset($_POST['filename']))
{
$text=htmlentities($_POST['txt']);
$filename=$_POST['filename'].'.mp3';

$querystring = http_build_query(array($text));

if ($soundfile = file_get_contents("http://api.voicerss.org?key=c68635f1104b452e8dbe740c0c0330f3&src=$querystring&hl=en-in j"))
{
file_put_contents($filename,$soundfile);
echo ('
<audio autoplay="autoplay" controls="controls">
<source src="'.$filename.'" type="audio/mp3" />
</audio>
<br />
Saved mp3 location : '.dirname(__FILE__).'\\'.$filename.'
<br />
Saved mp3 uri : <a href="'.$filename.'">'.$_SERVER['SERVER_NAME'].'/webtts/'.$filename.'</a>'
);
}
else echo("<br />Audio could not be saved");
}
?>

其结果是 http://api.voicerss.org?key=c68635f1104b452e8dbe740c0c0330f3&src=0=Good+evening.+Please+sit+down.+Now+tell+me+about+your+problem&hl=en-in

不应该显示src=0=Good,应该显示src=Good+evening,如何去掉0=

最佳答案

您需要为 http_build_query 提供一个关联数组

所以改变

 http_build_query(array($text))

 http_build_query(array("src"=>$text))

 file_get_contents("http://api.voicerss.org?key=c68635f1104b452e8dbe740c0c0330f3&src=$querystring&hl=en-in j

file_get_contents("http://api.voicerss.org?key=c68635f1104b452e8dbe740c0c0330f3&$querystring&hl=en-in j

或者你可以使用

http_build_query(array(
"src"=>$text,
"key"=>"c68635f1104b452e8dbe740c0c0330f3",
"hl"=>"en-in j"))

file_get_contents("http://api.voicerss.org?".$querystring);

关于PHP http_build_query 错误 "0=",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17889358/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com