I'm using PHP shell_exec to call the Bluemix Text to Speech API and my code is working well except when I call the text with SSML tags like my second code.
How could I use text and SSML in the same data query?
$result = shell_exec("/usr/bin/curl -k -u 'XXX':'XXX' -X POST \
--header 'Content-Type: application/json' \
--header 'Accept: audio/wav' \
--max-time 90000 \
--output 'public/uploads/audios/padrao_bomdia.wav' \
--data '{\"text\":\"Hello! This is an test.\", \"voice\":\"pt-BR_IsabelaVoice\"}' \
'https://stream.watsonplatform.net/text-to-speech/api/v1/synthesize?voice=pt-BR_IsabelaVoice'");
$result = shell_exec("/usr/bin/curl -k -u 'XXX':'XXX' -X POST \
--header 'Content-Type: application/json' \
--header 'Accept: audio/wav' \
--max-time 90000 \
--output 'public/uploads/audios/padrao_bomdia.wav' \
--data '{\"text\":\"Hello! <say-as interpret-as="letters">Hello</say-as> This is an test.\", \"voice\":\"pt-BR_IsabelaVoice\"}' \
'https://stream.watsonplatform.net/text-to-speech/api/v1/synthesize?voice=pt-BR_IsabelaVoice'");
Does say-as interpret-as="letters" Hello fragment need the escape slashes around 'letters'?
Unfortunately, Only US-English Allison voice supports Expressive SSML. Isabela, the PT-BR voice, does not support SSML. That's why it's not working.
Reference:
Currently, the service supports expressiveness only for the US English
Allison voice (en-US_AllisonVoice). Using the element with any other
voice returns an error.
Related
I am trying to troubleshoot a symfony's HTTP client request. How can one display the anticipated request as a cURL request such as the following? Thank you
curl -X 'PUT' \
'https://example.com/projects/01GPX8HPBQ54SA11JKWPWFESM6/document_acl' \
-H 'accept: application/ld+json' \
-H 'Authorization: Bearer blaBlaBla' \
-H 'Content-Type: application/ld+json' \
-d '{}'
I am trying to use a payment gateway api using php and they said api request will post data using curl, my app is using php code and I don't know how to do that in php file... they provide a sample code, but when I tried to copy and paste the code in php file it shows syntax error. Please help me to do that in php. Link for the payment api that i am using is https://paycertify.com/docs/api/gateway/recurring-billing/create-a-subscription/
curl --request POST \
--url https://gateway-api.paycertify.com/api/subscriptions \
--header 'Authorization: Bearer YOUR_API_TOKEN' \
--form 'amount=1.00' \
--form 'description=Monthly tennis club signature' \
--form 'start_date=2018-09-07' \
--form 'end_date=2018-10-07' \
--form 'interval=day' \
--form 'card_number=4111111111111111' \
--form 'merchant_subscription_id=MY-ORDER' \
--form 'interval_count=1' \
--form 'card_expiry_month=01' \
--form 'card_expiry_year=2021' \
--form 'card_cvv=999' \
--form 'first_name=John' \
--form 'last_name=Doe' \
--form 'street_address_1=59 N Santa Cruz Avenue' \
--form 'street_address_2=Suite M' \
--form 'city=Los Gatos' \
--form 'state=CA' \
--form 'country=US' \
--form 'mobile_phone=+11231231234' \
--form 'email=support#paycertify.com' \
--form 'merchant_transaction_id=my-order-id-0001' \
--form 'zip=95030'
This exemple is a shell command. If you want to send data to the api, you will need to use the curl php method.
Try something like this
$curlHandler = curl_init();
curl_setopt_array($curlHandler, [
CURLOPT_URL => 'https://gateway-api.paycertify.com/api/subscriptions',//url you want to call
CURLOPT_RETURNTRANSFER => true,//receive server reponse
CURLOPT_POST => true,//Explain you are using the post method
CURLOPT_HTTPHEADER => array("Authorization: Bearer YOUR_API_TOKEN"),
/**
* An array of field you want to send
*/
CURLOPT_POSTFIELDS => [
'amount' => '1.00',
'description' => 'Monthly tennis club signature',
....
],
]);
$response = curl_exec($curlHandler);
curl_close($curlHandler);
echo($response);
I am trying to convert the following post request using postman with no luck
> curl "https://192.168.50.52/token" \
> --request POST \
> --include \
> --insecure \
> --header "Content-Type: application/json" \
> --data '["todo.all"]' \
> --user test:test
Set the "secure" => false setting in slim-api if you do not want to use https
I wondering if is good (or bad), to use exec() command in PHP ...
For example, with API Paypal REST, I use exec() (with curl) rather than the curl from PHP
$a = exec('curl -v '.$this->ENDPOINT.'/v1/oauth2/token \
-H "Accept: application/json" \
-H "Accept-Language: fr_FR" \
-u "'.$this->CLIENTID.':'.$this->SECRET.'" \
-d "grant_type=client_credentials"'
);
$a = json_decode($a);
What is the impact? Is it better not to do?
Thanks guys
If those parameters are not coming from an end-user then you are pretty-safe. If not, then you should definitely filter them through escapeshellarg()
The secure code..
$a = exec('curl -v '.escapeshellarg($this->ENDPOINT).'/v1/oauth2/token \
-H "Accept: application/json" \
-H "Accept-Language: fr_FR" \
-u "'.escapeshellarg($this->CLIENTID).':'.escapeshellarg($this->SECRET).'" \
-d "grant_type=client_credentials"'
);
$a = json_decode($a);
I am having a problem with my php script.
When i run this command in terminal :-
curl -X POST -H "X-Futuresimple-Token:mytoken" \
-H "Accept:application/xml" \
-H "Content-Type:application/json" \
--data "{\"lead\" : { \"company_name\" : \"Cody Test\", \
\"first_name\" : \"Cody\", \"last_name\" : \"Guest\", \"email\" : \"Cody.guest#boxview.com\" }}" \
https://leads.futuresimple.com/api/v1/leads.json
It works. But i want to convert it into PHP so that i can get the response using PHP
Thanks
Slap on the "--libcurl example.c" option to get your program in plain C, from there it is usually easy to make it into PHP...