Speech Synthesize API no longer working properly - php

The speech synthesizer API seems to be only working for English. Is it just me? Am I doing something wrong in the code? Or is it not working for anyone else? For some languages like Chinese, and Japanese, it doesn't output any sounds at all, and for languages like Spanish and others, it just reads them like how it reads the regular English language. This just started happening recently, maybe for the past 2 weeks or so? Before the same exact code worked fine.
<?php
header('Content-Type: text/html; charset=utf-8');
?>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script>
$(function() {
//te amo <--- spanish
// 我爱你 <--- chinese
var speech = "我爱你";
document.write(speech);
var u = new SpeechSynthesisUtterance(speech);
u.lang = "zh-CN";
u.volume = 1; //0-1 1=default
u.rate = 0.5; //0-10, 1=default
u.pitch = 1.9; //0-2 1=default
window.speechSynthesis.speak(u);
});
</script>
For Reference:
http://blog.teamtreehouse.com/getting-started-speech-synthesis-api
"arabic" => "ar-DZ",
"bulgarian" => "bg",
"catalan" => "ca",
"chinese-simplified" => "zh-CN",
"chinese-traditional" => "zh-CN",
"czech" => "cs",
"danish" => "da",
"dutch" => "nl-BE",
"english" => "en-US",
"estonian" => "et",
"finnish" => "fi",
"french" => "fr-BE",
"german" => "de-AT",
"greek" => "el",
"haitian-creole" => "en-US",
"hebrew" => "he",
"hindi" => "hi",
"hungarian" => "hu",
"indonesian" => "id",
"italian" => "it-IT",
"japanese" => "ja",
"klingon" => "en-US",
"korean" => "ko",
"latvian" => "lv",
"lithuanian" => "lt",
"malay" => "ms-BN",
"maltese" => "mt",
"norwegian" => "no-NO",
"persian" => "fa",
"polish" => "pl",
"portuguese" => "pt-BR",
"romanian" => "ro-MO",
"russian" => "ru",
"slovak" => "sk",
"slovenian" => "sl",
"spanish" => "es-AR",
"swedish" => "sv-FI",
"thai" => "th",
"turkish" => "tr",
"ukrainian" => "uk",
"urdu" => "ur",
"vietnamese" => "vi",
"welsh" => "cy",

Related

Cant get ipaddr with TheNetworg/oauth2-azure Resource Owner

I am using a PHP Library TheNetworg/oauth2-azure
Would like to seek help getting ipaddr from access_token;
I cant seem to get the ipaddr with $resourceOwner -> claim("ipaddr");
our company is using API Gateways which is why I cannot use the client IP for IP Address;
here's the print_r($resourceowner);
TheNetworg\OAuth2\Client\Provider\AzureResourceOwner Object (
[data:protected] => Array ( [aud] =>
73b99a0d-33db-4f60-9428-246ab79ad7a1 [iss] =>
https://login.microsoftonline.com/f3211d0e-125b-42c3-86db-322b19a65a22/v2.0
[iat] => 1654196670 [nbf] => 1654196670 [exp] => 1654200570
[auth_time] => 1653645878 [email] => adolf.rey.a.along#domain.com
[name] => Along, AR [oid] => a3d7f1ef-4b90-40bb-bb98-0b231fc3190c
[preferred_username] => adolf.rey.a.along#domain.com [rh] =>
0.ASYADh0h81sSw0KG2zIrGaZaIg2auXPbM2BPlCgkarea16EmAFA. [sub] => 7nrl5r4ZBgwsywvLVuRMiKCj40P_ABRbbh8Qg0WRJR4 [tid] =>
f3211d0e-125b-42c3-86db-322b19a65a22 [uti] => x-Nzcykiq0a1zqiW2sAAAA
[ver] => 2.0 ) )
here is what I get from jwt.io with the access token:
{
"aud": "https://graph.microsoft.com",
"iss": "https://sts.windows.net/f3211d0e-125b-42c3-86db-322b19a65a22/",
"iat": 1654192709,
"nbf": 1654192709,
"exp": 1654198372,
"acct": 0,
"acr": "1",
"acrs": [
"urn:user:registersecurityinfo",
"c1",
"c2"
],
"aio": "AVQAq/8TAAAAx1MCI+PyDFrMZwtwqaEKGKzGscUtn9R3OhpGGaZozsW7yPFJMfadAR4UgOc485j73E38OdNa3wu7FwLqxBeiZBnC7E3wXAX4Y1//zzZK6D4=",
"amr": [
"pwd",
"mfa"
],
"app_displayname": "7107_MYAPP_LEGACY_PHP_Staging_ESOPortal",
"appid": "73b99a0d-33db-4f60-9428-246ab79ad7a1",
"appidacr": "1",
"family_name": "Along",
"given_name": "Adolf Rey",
"idtyp": "user",
"ipaddr": "112.202.179.1",
"name": "Along, AR",
"oid": "a3d7f1ef-4b90-40bb-bb98-0b231fc3190c",
"onprem_sid": "S-1-5-21-861567501-413027322-1801674531-3036785",
"platf": "3",
"puid": "1003BFFD8DC81D0E",
"rh": "0.ASYADh0h81sSw0KG2zIrGaZaIgMAAAAAAAAAwAAAAAAAAAAmAFA.",
"scp": "email openid profile User.Read",
"signin_state": [
"kmsi"
],
"sub": "-ePe17Ssg1rFUWAE_u1Sn5_7Kr5IYaCnccVRtaU1euE",
"tenant_region_scope": "NA",
"tid": "f3211d0e-125b-42c3-86db-322b19a65a22",
"unique_name": "adolf.rey.a.along#domain.om",
"upn": "adolf.rey.a.along#domain.com",
"uti": "cycwWq1hrEK3gjBdx03IAA",
"ver": "1.0",
"wids": [
"b79fbf4d-3ef9-4689-8143-76b194e85509"
],
"xms_st": {
"sub": "7nrl5r4ZBgwsywvLVuRMiKCj40P_ABRbbh8Qg0WRJR4"
},
"xms_tcdt": 1403205942
}

How to get data from JSON file by parsing array name from the url

I am trying to print data in json format from my 'data.json' file. With my php file (alldata.php), I could get all data (arrays) pretty printed. But where I want you to help me is how to get a specific array name and it objects/content.
My alldata.php looks like this:
{
"players": [
{
"name": "Marcos Alonso",
"position": "Left-Back",
"nationality": "Spain",
"marketValue": "9,000,000 €",
"created": "2017-04-15 10:04:58"
}],
"articles": [
{
"author": "Stephen Walter",
"title": "Disruptive stag party revellers thrown off plane at Manchester Airport",
"url": "http://www.telegraph.co.uk/news/2017/04/15/disruptive-stag-party-revellers-thrown-plane-manchester-airport/",
"publishedAt": "2017-04-15T09:25:10Z"
}],
land": [
{
"state": "Somewhr",
"found": "1889",
"area": "6,812",
"empl": "1,325",
"ppl": "16,842"
}]
}
In php, how can I get an array e.g "players" with the content by using url such as 'alldata.php?search=players'
Here is a code sample....
//get content of the JSON API using file_get_contents()
$url = ('myJson.json');
$jsondata = file_get_contents($url);
//convert json object to php associative array
$data = json_decode($jsondata, true);
what do I do here to query the data.json file for a specific array?????
header('Content-Type: application/json; charset=UTF-8');
$json_string = json_encode($????????????, JSON_PRETTY_PRINT);
print $json_string;
Thanks
If I properly understood what you mean, and if your array has always the same tree, this wilp help you access the data :
<?php
error_reporting(E_ALL);
ini_set("display_errors", 1);
$array = array(
0 => array(
"players" => array(
"name" => "Marcos Alonso",
"position" => "Left-Back",
"nationality" => "Spain",
"marketValue" => "9,000,000 €",
"created" => "2017-04-15 10:04:58"
),
"articles" => array(
"author" => "Stephen Walter",
"title" => "Disruptive stag party revellers thrown off plane at Manchester Airport",
"url" => "http://www.telegraph.co.uk/news/2017/04/15/",
"publishedAt" => "2017-04-15T09:25:10Z"
),
"land" => array(
"state" => "Somewhr",
"found" => "1889",
"area" => "6,812",
"empl" => "1,325",
"ppl" => "16,842"
)
),
1 => array(
"players" => array(
"name" => "Sebastian Vettel",
"position" => "Driver",
"nationality" => "Germany",
"marketValue" => "9,000,000 €",
"created" => "2013-03-15 11:04:52"
),
"articles" => array(
"author" => "Stephen Walter",
"title" => "Disruptive stag party revellers thrown off plane at Manchester Airport",
"url" => "http://www.telegraph.co.uk/news/2017/04/15/",
"publishedAt" => "2017-04-15T09:25:10Z"
),
"land" => array(
"state" => "Somewhr",
"found" => "1889",
"area" => "6,812",
"empl" => "1,325",
"ppl" => "16,842"
)
)
);
/* end of array */
$data1 = json_encode($array); /* just checking - not needed after that */
$data = json_decode($data1, true); /* just checking - not needed after that */
$needle = "articles"; /* should be $needle = $_GET['search']; and checked before use */
//print_r($data); /* just checking */
foreach($data as $value){ /* we access 1st level */
echo '** Needle is: '.$needle.' **<br/>';
foreach($value[$needle] as $sub_key => $sub_data){ /* we access 2nd level */
echo $sub_key.'-->'.$sub_data.'<br/>'; }
}
?>
Once you access the data, you can easily do what you want with it...

Fusioncharts couple angulargouge to a database and Double arrow message showing up

I'm trying to find a way to get information out of a database and use this information in a graph. Im using a libery (FusionCharts), this has some examples but not with data out of a database. So far i came up this this but im getting an error
Parse error: syntax error, unexpected '=>' (T_DOUBLE_ARROW)
The example im using is this one Example angulargauge
if ($result) {
$arrData6 = array(
"chart" => array
(
"caption" => "Sended mail",
"lowerlimit" => "0",
"upperlimit" => "100",
"lowerlimitdisplay" =>"0%",
"upperlimitdisplay" => "100%",
"palette" => "1",
"numbersuffix" => "%",
"tickvaluedistance" => "10",
"showvalue" => "0",
"gaugeinnerradius" => "0",
"bgcolor" => "FFFFFF",
"pivotfillcolor" => "333333",
"pivotradius" => "8",
"pivotfillmix" => "333333, 333333",
"pivotfilltype" => "radial",
"pivotfillratio"=> "0,100",
"showtickvalues"=> "1",
"showborder" => "0",
),
"colorRange" => array (
"color" => array
(
"minValue" => "0",
"maxValue" => "50",
"code" => "#e44a00"
),
(
"minValue" => "50",
"maxValue" => "75",
"code" => "#f8bd19"
),
(
"minValue" => "75",
"maxValue" => "100",
"code" => "#6baa01"
)
),
"dials" => array (
"dial" => array (
"value" => "$precentage"
)
)
);
$arrData6["data"] = array();
$jsonEncodedData6 = json_encode($arrData6);
$angularChart = new FusionCharts("AngularGauge", "chart4" , "100%", "200", "chart-5", "json", $jsonEncodedData6);
// Render the chart
$angularChart->render();
}
I can up with this by using the information on the page but since this one got more informatiesets (chart,dials and colors) I haven't been able to figure out how to do it yet.Database how to explaination i used
The $percentage is the result of the total - the not sended mail

Looping through an Multidimentinal/Associative Array

Looking for some help with looping through a multidimensional/associative array in PHP. Essentially, I need to loop through and output the certain key values in a table. Not having much luck.
Here is a sample of my array.
$myarray = array(
"body" => array(
"0" => array(
"machine" => array(
"id" => "1",
"name" => "macbookpro",
"description" => "laptop machine",
"state" => "reserved",
"state_since" => "2013-08-28 12:05:00",
"queue_snapshot" => array(
"time" => "2013-08-01 12:00:00",
"jobs" => "450",
"jobs_available" => "90",
"cputime_running" => "00:01:00",
"cputime_eligible" => "00:90:00",
"cputime_block" => " 90:00:00",
)
)
),
"1" => array(
"machine" => array(
"id" => "2",
"name" => "ipad",
"description" => "tablet machine",
"state" => "available",
"state_since" => "2013-08-28 12:05:00",
"queue_snapshot" => array(
"time" => "2013-08-01 12:00:00",
"jobs" => "50",
"jobs_available" => "20",
"cputime_running" => "00:05:00",
"cputime_eligible" => "00:12:00",
"cputime_block" => " 00:10:00",
)
)
)
));
I have some values in this array that will need to be accessed later so I only need to be able to access particular values in order to create this table. Needs to output like this....
Machine Name | Description | State | Jobs | Jobs Available |
macbookpro laptop machine reserved 450 90
ipad tablet machine available 50 20
Untestet on the fly
<?php
if(isset($myarray['body']) && is_array($myarray['body']))
foreach($myarray['body'] as $id=>$arr) {
$name = $arr['name'];
$description = $arr['description'];
$jobs = $arr['queue_snapshot']['jobs'];
$jobs_available = $arr['queue_snapshot']['jobs_available'];
echo "<br>$name $description $jobs $jobs_available";
}
?>

Adding Docusign Template array into REST Header

So I'm back again. My problem is this:
I have an array of Docusign Templates from checkboxes in a Codeigniter view:
<?php
echo form_open('create_envelope');
foreach ($response["envelopeTemplates"] as $envelopeTemplate) { ?>
<li><?php echo form_checkbox('templatearray[]', $envelopeTemplate["templateId"], FALSE), $envelopeTemplate["name"]; ?></li>
<?php } ?>
What I'm trying to do is add the templates to our REST Header request:
$data = array(
"accountId" => $accountId,
"emailSubject" => "Hello World!",
"emailBlurb" => "This comes from PHP",
"templateId" => "ID from template array here",
"templateRoles" => array(
array(
"tabs" => array(
"textTabs" => array (
array (
"tabLabel" => "lic_num",
"value" => "$license_number"
),
array (
"tabLabel" => "ubi_num",
"value" => "$ubi_number"
),
array (
"tabLabel" => "tra_nam",
"value" => "$trade_name"
)
)
),
"email" => "$applicant_email",
"name" => "$applicant_name",
"roleName" => "Applicant"
)
),
"status" => "sent"
);
Is this possible?
EDIT: So I got it to work using loops to get my data in the request, but I'm running into an interesting problem. If I put one or two templates in the envelope, it sends fine. If I put more than two in, it duplicates the templates. Here is my code for the complicated loops:
$compTempArray = array();
$applicant_name = $this->input->post("applicant_name");
$applicant_email = $this->input->post("applicant_email");
$license_number = $this->input->post("license_number");
$ubi_number = $this->input->post("ubi_number");
$trade_name = $this->input->post("trade_name");
foreach($hello as $key => $value) {
if(sizeof($hello) > 1) {
for($i = 1; $i < sizeof($hello); $i++) {
$compTempArray[] = array("serverTemplates" => array(
array(
"sequence" => $i,
"templateId" => $value
)
),
"inlineTemplates" => array(
array(
"sequence" => $i,
"recipients" => array(
"signers" => array(
array(
"tabs" => array(
"textTabs" => array (
array ("tabLabel" => "lic_num", "value" => $license_number),
array ("tabLabel" => "ubi_num", "value" => $ubi_number),
array ("tabLabel" => "tra_nam", "value" => $trade_name)
)
),
"email" => "*********#*****.com",
"name" => $applicant_name,
"recipientId" => "1",
"roleName" => "Applicant"
),
)
)
)
));
}
$data = array("accountId" => $accountId,
"emailSubject" => "Hello World!",
"emailBlurb" => "This comes from PHP",
"compositeTemplates" => $compTempArray,
"status" => "sent");
} else {
$data = array("accountId" => $accountId,
"emailSubject" => "Hello World!",
"emailBlurb" => "This comes from PHP",
"templateId" => "$value",
"templateRoles" => array(
array(
"tabs" => array(
"textTabs" => array (
array ("tabLabel" => "lic_num", "value" => $license_number),
array ("tabLabel" => "ubi_num", "value" => $ubi_number),
array ("tabLabel" => "tra_nam", "value" => $trade_name)
)
),
"email" => "*********#*****.com",
"name" => $applicant_name,
"roleName" => "Applicant"
)
),
"status" => "sent");
}
}
Any idea why it would do this?
NEW EDIT: Update on this weirdness: one to two - one copy of each template, three - it doubles the amount of each template, four - it triples the amount, five - it quadruples the amount.
NEWEST EDIT: So as it turns out, it was the for loop that I was using to try and increment the sequence. I got rid of the loop and hardcoded the sequence to 1. That fixed it.
To apply multiple templates to a single envelope you'll need to use the compositeTemplates structure.
compositeTemplates can get complex very quickly but they do allow for great flexibility and functionality for your envelopes. The API documentation is the best place to read about compositeTemplates but as previously mentioned the April 2012 Templates Webinar is also a good resource. The third example provides a basic use of compositeTemplates in that it shows you how to combine two server templates into one single envelope. You can use that as a base for your JSON.
To apply 2 server templates to a single envelope it uses the following JSON:
{
"emailSubject": "DocuSign Templates Webinar - Example 3",
"emailBlurb": "Example #3 - Composite Templates",
"status": "sent",
"compositeTemplates": [
{
"serverTemplates": [
{
"sequence": "1",
"templateId": "55A80182-2E9F-435D-9B16-FD1E1C0F9D74"
}
],
"inlineTemplates": [
{
"sequence": "1",
"recipients": {
"signers": [
{
"email": "firstrecipient#gmail.com",
"name": "John Doe",
"recipientId": "1",
"roleName": "RoleOne"
}
]
}
}
]
},
{
"serverTemplates": [
{
"sequence": "2",
"templateId": "44D9E888-3D86-4186-8EE9-7071BC87A0DA"
}
],
"inlineTemplates": [
{
"sequence": "2",
"recipients": {
"signers": [
{
"email": "secondrecipient#gmail.com",
"name": "Jane Doe",
"recipientId": "1",
"roleName": "RoleOne"
}
]
}
}
]
}
]
}
Note that the sequence value for each template determines the order of template application to the envelope. So in other words, the sequence value determines the document order, but since the templates might have matching/conflicting info (in terms of template roles for instance) the sequence value might also affect the end result of the envelope.

Categories