简体   繁体   English

在twilio php api上拨打电话时使用文字语音

[英]use text to speech in making call on twilio php api

Good day, 美好的一天,

Im creating reminder app that calls a number in certain time, currently I was using an uploaded mp3 file on my server: 我正在创建在特定时间拨打电话的提醒应用,目前我正在服务器上使用上载的mp3文件:

here the code: 这里的代码:

$sid = "ACxxxxxxxxxx";
$token = "2xxxxxxxxx";
$client = new Client($sid, $token);
$call = $client->calls->create(
         "$phone_number_to","$phone_number_from", 
          array("url" => 
          "https://xxxxx.com/asset/mp3/reminder.mp3")
            );
$csid = $call->sid;

the above code works, but now I wanted to use the text to speech feature on twilio to have a more customized voicemail per reminder.. 上面的代码可以正常工作,但是现在我想在twilio上使用文本语音转换功能,以便为每个提醒设置更个性化的语音邮件。

how do I do this using $client-> api? 如何使用$client-> api执行此操作? Im not really familiar on how TwiML works though, maybe thats why im confused. 我对TwiML的工作原理并不十分熟悉,也许这就是为什么我感到困惑。

thanks! 谢谢!

You change this line of your current code "url" => "https://xxxxx.com/asset/mp3/reminder.mp3" so that the URL points at the url hosting the script you want to use to generate your dynamic TwiML. 您更改当前代码的这一行"url" => "https://xxxxx.com/asset/mp3/reminder.mp3"以便该URL指向托管您要用来生成动态TwiML的脚本的URL。 。

Then use the php TwiML library to generate the TwiML, it's pretty straightforward. 然后使用php TwiML库生成TwiML,这非常简单。 We have a database with all out customers details in, I use code something along these lines to get their details based on caller ID and have Twilio greet them by first name: 我们有一个包含所有客户详细信息的数据库,我在这些行中使用一些代码来根据呼叫者ID获取其详细信息,并让Twilio用名字问候他们:

$booked = SELECT * FROM table WHERE phone = $caller;
$name = explode(" ", $booked->name);
$firstname = $name[0];
$response->say("Hello $firstname. Thanks for calling......");

It's ok but it's a bit robotic. 可以,但是有点机器人。 We ended up extracting the 50 most common first names from the database and having a voiceover artist record greetings for each one. 最后,我们从数据库中提取了50个最常见的名字,然后由配音艺术家录制了每个名字的问候。 For callers with one of those 50 names we serve a specific mp3 file, everyone else gets the robot. 对于使用这50个名字之一的来电者,我们会提供一个特定的mp3文件,其他所有人都会获得漫游器。

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

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