AWS Transcription and Content Redaction - amazon-web-services

wondered if someone could help.
I am using the PHP AWS SDK, v3 (just updated to latest), it's working as it should, can send MP3, returns a json file with transcription.
However, I want to use Content Redaction, but no matter what I try I can't see to get it to work, I don't get any errors, my code looks like this:
$transcribe->startTranscriptionJob([
'ContentRedaction' => [
'RedactionType' => 'PII',
'RedactionOutput' => 'redacted'
],
'LanguageCode' => 'lang',
'Media' => [
'MediaFileUri' => 'someurl',
],
'MediaFormat' => 'file',
'OutputBucketName' => 'bucket_name',
'Settings' => [
'ChannelIdentification' => true,
'SplitChannelTranscription' => true,
],
'TranscriptionJobName' => 'output_filename'
]);
I don't get any errors, it just transcribes it without the Content Redaction.
From their docs:
"To enable content redaction using the API, complete the request parameters of the ContentRedaction object in the StartTranscriptionJob operation. See the request syntax for the StartTranscriptionJob action for more information. To see if content redaction has been enabled for a particular transcription job, use GetTranscriptionJob. To see which jobs have content redaction enabled, use ListTranscriptionJobs."

Related

Wordpress Rewrite Rule Anything

I'm trying to create a plugin that adds an "invite" post type that has an "rewrite" param to prepend "convite" before post slug... The code looks like this:
register_post_type("invite_company", [
'label' => __("Empresas", "modaladvisorsplugin"),
'public' => true,
'supports' => ['title'],
'exclude_from_search' => false,
'show_in_rest' => false,
'rewrite' => [
'slug' => "convite",
],
'menu_icon' => "dashicons-building",
]);
At this point, all works fine. Next step is to add an rewrite rule to append anything after the post slug, that will be used in template as a query var... So, for example, this url:
site.com/convite/company/abcdefg
Must recognize abcdefg as a advisor query parameter. For this, I've tried this way:
register_post_type("invite_company", [
'label' => __("Empresas", "modaladvisorsplugin"),
'public' => true,
'supports' => ['title'],
'exclude_from_search' => false,
'show_in_rest' => false,
'rewrite' => [
'slug' => "convite",
],
'menu_icon' => "dashicons-building",
]);
public function rewrite_rules()
{
add_rewrite_rule(
"convite/([a-z0-9-]+)[/]?$",
"index.php?post_type=invite_company&advisor=\$matches[1]",
"top"
);
}
And filtering query_vars as follow:
public function query_vars($vars)
{
$vars[] = "advisor";
return $vars;
}
Sometime (I don't remember what was in regex), when I tried to access /convite/some-post-slug/abcde, the URL was rewritten to /convite/some-post-slug (excluding the appended segment).
By the way, isn't working... I think is a regex problem (maybe convite/([a-z0-9-]+)[/]?$ isn't what I need), but really I don't know what I'm doing wrong, and I'm not an expert in regex...
Can anyone help me?
I'm not sure if I'm fully understanding the requirements, but this might work better. The regex is a bit easier this way, and it should check for both company by itself as well as company with advisor.
add_rewrite_rule('convite/([^/]+)/([^/]+)/?', 'index.php?invite_company=$matches[1]&advisor=$matches[2]', 'top');
add_rewrite_rule('convite/([^/]+)/?$', 'index.php?invite_company=$matches[1]', 'top');
Also, remember to flush rewrite rules before testing (resave permalinks, or run flush_rewrite_rules(); in your code while testing).

How to create a distribution on CloudFront using Paws

My goal is to create a basic CloudFront distribution using the Paws sdk, and as of yet I have been unable to get past an error 400 with the following configuration:
use Paws;
use Data::Printer;
my $cloudfront = Paws->service('CloudFront');
my $CreateDistributionResult = $cloudfront->CreateDistribution(
DistributionConfig => {
CallerReference => "1578211502",
Origins => {
Quantity => 1,
Items => [{
DomainName => "foo.s3-website-ap-southeast-2.amazonaws.com",
Id => 'S3-Website-foo.s3-website-ap-southeast-2.amazonaws.com'}]
},
DefaultCacheBehavior => {
ForwardedValues => {
Cookies => {Forward => 'none'},
QueryString => 0
},
TargetOriginId => 'S3-Website-foo.s3-website-ap-southeast-2.amazonaws.com',
TrustedSigners => {
Enabled => 0,
Quantity => 0
},
ViewerProtocolPolicy => 'redirect-to-https',
MinTTL => 0
},
Comment => "",
Enabled => 1
});
p $CreateDistributionResult;
The above is the complete set of only the required fields as defined in the api documentation here and here. However, when I run the above it crashes with the following:
[foo#bar~]# perl aws.pl
Paws::CloudFront is not stable / supported / entirely developed at /root/perl5/lib/perl5/Paws/CloudFront.pm line 2.
Bad Request
Trace begun at /root/perl5/lib/perl5/Paws/Net/RestXMLResponse.pm line 24
Paws::Net::RestXMLResponse::process('Paws::Net::RestXMLResponse=HASH(0x2f275b8)', 'Paws::CloudFront::CreateDistribution=HASH(0x2fbe6e0)', 'Paws::Net::APIResponse=HASH(0x30c0ec0)') called at /root/perl5/lib/perl5/Paws/Net/Caller.pm line 46
Paws::Net::Caller::caller_to_response('Paws::Net::Caller=HASH(0x16d7bb8)', 'Paws::CloudFront=HASH(0x2a615f8)', 'Paws::CloudFront::CreateDistribution=HASH(0x2fbe6e0)', 'Paws::Net::APIResponse=HASH(0x30c0ec0)') called at /root/perl5/lib/perl5/Paws/Net/RetryCallerRole.pm line 19
Paws::Net::RetryCallerRole::do_call('Paws::Net::Caller=HASH(0x16d7bb8)', 'Paws::CloudFront=HASH(0x2a615f8)', 'Paws::CloudFront::CreateDistribution=HASH(0x2fbe6e0)') called at /root/perl5/lib/perl5/Paws/CloudFront.pm line 49
Paws::CloudFront::CreateDistribution('Paws::CloudFront=HASH(0x2a615f8)', 'DistributionConfig', 'HASH(0x2f9c500)') called at aws.pl line 6
What is a correct minimal call that would work here?
you don't have anything in the comment argument. Please try passing value there.
AWS is a bit stingy with these kinds of things. Also please let me know if that fixes the issue or not.

Save AWS Polly mp3 file to S3

I am trying to send some text to AWS Polly to convert to speech and then save that mp3 file to S3. That part seems to work now.
// Send text to AWS Polly
$client_polly = new Aws\Polly\PollyClient([
'region' => 'us-west-2',
'version' => 'latest',
'credentials' => [
'key' => $aws_useKey,
'secret' => $aws_secret,
]
]);
$text = 'Test. Test. This is a sample text to be synthesized.';
$voice = 'Matthew';
$result_polly = $client_polly->startSpeechSynthesisTask([
'Text' => $text,
'TextType' => 'text',
'OutputFormat' => 'mp3',
'OutputS3BucketName' => $aws_bucket,
'OutputS3KeyPrefix' => 'files/audio/,
'VoiceId' => $voice,
'ACL' => 'public-read'
]);
echo $result_polly['ObjectURL'];
I'm also trying to accomplish couple other things:
Make mp3 file publicly accessible. Currently I have to go to AWS console to
click "Make Public" button. It seems that 'ACL' => 'public-read' doesn't work for me
I need to return full URL of the mp3 file. For some reason $result_polly['ObjectURL']; doesn't get any value.
What am I missing?
There is no ACL field in the StartSpeechSynthesisTask call:
$result = $client->startSpeechSynthesisTask([
'LanguageCode' => 'arb|cmn-CN|cy-GB|da-DK|de-DE|en-AU|en-GB|en-GB-WLS|en-IN|en-US|es-ES|es-MX|es-US|fr-CA|fr-FR|is-IS|it-IT|ja-JP|hi-IN|ko-KR|nb-NO|nl-NL|pl-PL|pt-BR|pt-PT|ro-RO|ru-RU|sv-SE|tr-TR',
'LexiconNames' => ['<string>', ...],
'OutputFormat' => 'json|mp3|ogg_vorbis|pcm', // REQUIRED
'OutputS3BucketName' => '<string>', // REQUIRED
'OutputS3KeyPrefix' => '<string>',
'SampleRate' => '<string>',
'SnsTopicArn' => '<string>',
'SpeechMarkTypes' => ['<string>', ...],
'Text' => '<string>', // REQUIRED
'TextType' => 'ssml|text',
'VoiceId' => 'Aditi|Amy|Astrid|Bianca|Brian|Carla|Carmen|Celine|Chantal|Conchita|Cristiano|Dora|Emma|Enrique|Ewa|Filiz|Geraint|Giorgio|Gwyneth|Hans|Ines|Ivy|Jacek|Jan|Joanna|Joey|Justin|Karl|Kendra|Kimberly|Lea|Liv|Lotte|Lucia|Mads|Maja|Marlene|Mathieu|Matthew|Maxim|Mia|Miguel|Mizuki|Naja|Nicole|Penelope|Raveena|Ricardo|Ruben|Russell|Salli|Seoyeon|Takumi|Tatyana|Vicki|Vitoria|Zeina|Zhiyu', // REQUIRED
]);
Therefore, you will either need to make another call to Amazon S3 to change the ACL of the object, or use an Amazon S3 Bucket Policy to make the bucket (or a path within the bucket) public.
The output location is given in the OutputUri field (NOT OutputUrl -- URI vs URL).

Yii2 Web Service not returning a single row from database

I've made a web service using yii2 basic template I got a table called 'ely_usuario' when I call it with:
http://localhost/basic/web/index.php/ely-usuario/
it works fine and returns me all the rows in ely_usuario table
but when I try to get just one record, for example:
http://localhost/basic/web/index.php/ely-usuario/29
it doesn't work, show me a not found page, I've made the model class using gii
here's my Controller:
<?php
namespace app\controllers;
use yii\rest\ActiveController;
class ElyUsuarioController extends ActiveController
{
public $modelClass = 'app\models\ElyUsuario';
}
My configs:
'urlManager' => [
'enablePrettyUrl' => true,
'enableStrictParsing' => false,
'showScriptName' => false,
'rules' => [
['class' => 'yii\rest\UrlRule', 'controller' => 'ely-usuario'],
],
],
Another weird thing that you might noticed is that 'enableStrictParsing' is false, in the yii2 guide it says to be true but for me it only works with false
Thanks
You need to change the code in your configs.I hope you will get an idea from the following code.It works fine for me!
'urlManager' => [
'enablePrettyUrl' => true,
'showScriptName' => false,
'rules' => [
'<controller:(ely-usuario)>/<action>/<id:\d+>' => '<controller>/<action>',
],
],
And in your controller please check your specific action.It must be coded like as:
public function actionTransactions($id=null){
if($id!=null){
//retrieve single row
}else{
//retrieve multiple rows
}
Also please check this link for reference:
Why RESTfull API request to view return 404 in Yii2?
I hope it helps!

How to resolve Recoverable fatal error: Object of class Drupal\Core\Link could not be converted to string in Drupal\Component\Utility\Xss::filter?

I'm following the How to Configure SimpleSAMLphp for Drupal 8 on Acquia instruction. I'm at the bottom where it says, "SimpleSAMLphp_auth module settings. I personally recommend to store configuration for SimpleSAMLphp_auth module settings in settings.php." Once I copied the code he has in that code snippet to my settings.php file (pasted it at the bottom) and push it to Acquia, I got this error when I tried to login via the dev.mysite.com/user url.
The website encountered an unexpected error. Please try again later. Recoverable fatal error: Object of class Drupal\Core\Link could not be converted to string in Drupal\Component\Utility\Xss::filter() (line 67 of core/lib/Drupal/Component/Utility/Xss.php).
The code shown below is what I have in my settings.php file.
$config['simplesamlphp_auth.settings'] = [
// Basic settings.
'activate' => TRUE, // Enable or Disable SAML login.
'auth_source' => 'default-sp',
'login_link_display_name' => 'Login with your SSO account',
'register_users' => TRUE,
'debug' => FALSE,
// Local authentication.
'allow' => [
'default_login' => TRUE,
'set_drupal_pwd' => TRUE,
'default_login_users' => '',
'default_login_roles' => [
'authenticated' => FALSE,
'administrator' => 'administrator',
],
],
'logout_goto_url' => '',
// User info and syncing.
// `unique_id` is specified in Transient format, otherwise this should be `UPN`
// Please talk to your SSO adminsitrators about which format you should be using.
'unique_id' => 'http://schemas.xmlsoap.org/ws/2005/05/identity/claims/upn',
'user_name' => 'uid',
'mail_attr' => 'mail',
'sync' => [
'mail' => FALSE,
'user_name' => FALSE,
],
];
If I commented out this whole block of code in my setings.php file then I can login to my dev.mysite.com/user drupal site. One other thing I'm not clear is, do I "Check Activate authentication via SimpleSAMLphp option" first then copied the code snippet to my settings.php file and push to Acquia or the other way around?
Any help is much appreciated.
It seems that update to version 8.x-3.0-rc2 resolves the error above. However, looks like it introduces another issues, "This site can't be reached" and redirected the site to port 80 instead.