我正在做一个twilio应用程序,它的声音被转录,然后转换成文本。在检索转录文本之前,一切都是有用的。我知道,如果我知道"sid“,我可以检索转录代码,但是如果我想要动态的转录代码,而不知道"sid”,该怎么办?换句话说,我想从电话号码"555-555-1212“中找到最新的抄本,我能找到的只有下面的代码。
<?php
// Get the PHP helper library from twilio.com/docs/php/install
require_once('/path/to/twilio-php/Services/Twilio.php'); // Loads the library
// Your Account Sid and Auth Token from twilio.com/user/account
$sid = "AC1240edf87a1d3b6717472af6deda4ce7";
$token = "{{ auth_token }}";
$client = new Services_Twilio($sid, $token);
$client->account->transcriptions->delete("TR8c61027b709ffb038236612dc5af8723");
?>提前感谢!迭戈
发布于 2013-11-16 17:32:55
修正我原来的问题=)
<?php
//RETRIEVE NUMBERS LAST TRANSCRIPTION
$client = new Services_Twilio($sid, $token);
$i=0;
foreach($client->account->transcriptions->getIterator(0, 50, array('Status' => 'completed', 'To' => ''.$_GET['number'].'')) as $call) {
//now use the sid to get the transcription text using a seperate rest call.
if($i==1) break;
$transcription = $client->account->transcriptions->get($call->sid);
$sms_text = $transcription->transcription_text;
$i++;
}
?>发布于 2013-10-26 11:17:04
您需要获得呼叫的SID,但是如果您知道电话号码,并且可以选择要查找的日期范围(我的PHP已经生疏了,所以您可能需要将其连接起来),这就很容易做到了:
// Your Account Sid and Auth Token from twilio.com/user/account
$sid = "{{ sid }}";
$token = "{{ auth_token }}";
$client = new Services_Twilio($sid, $token);
// Get calls to a number on or after a certain date.
foreach ($client->account->calls->getIterator(0, 50, array("Status" => "completed", "To" => "555-555-1212","StartTime" => "2013-10-26")) as $call) {
echo $call->sid
//now use the sid to get the transcription text using a seperate rest call.
$transcription = $client->account->transcriptions->get($call->sid);
echo $transcription->transcription_text;
}发布于 2013-11-17 05:56:10
这里的福音传道者。
另一个选项是,如果使用<Record>谓词,则可以设置transcribeCallback参数:
https://www.twilio.com/docs/api/twiml/record#attributes-transcribe-callback
这允许您给Twilio一个URL,我们将在完成转录时请求该URL。
希望这能有所帮助。
https://stackoverflow.com/questions/19598195
复制相似问题