Add metadata to output .wav file using AWS MediaConvert - node.js

I am creating a Node api to convert .mp4 file to .wav file using AWS MediaConvert.
I need to add some metadata to the output .wav file but I am not able to figure out how to do so.
Is there any specific MediaConvert setting that I need to configure while creating a MediaConvert Job for the transcoding which will allow me to add the metadata to the .wav file?
I am currently having the following setting for my MediaConvert Job:
const mediaConvertSetting = {
Queue: queue-arn,
Role: role-arn,
Settings: {
Inputs: [
{
AudioSelectors: {
"Audio Selector 1": {
DefaultSelection: "DEFAULT",
},
},
VideoSelector: {},
TimecodeSource: "ZEROBASED",
FileInput: `s3://source-bucket/input_file.mp4`,
},
],
TimecodeConfig: {
Source: "ZEROBASED",
},
OutputGroups: [
{
Name: "File Group",
Outputs: [
{
ContainerSettings: {
Container: "RAW",
},
AudioDescriptions: [
{
AudioTypeControl: "FOLLOW_INPUT",
AudioSourceName: "Audio Selector 1",
CodecSettings: {
Codec: "WAV",
WavSettings: {
BitDepth: '16',
Channels: '1',
Format: 'RIFF',
SampleRate: '8000'
}
},
LanguageCodeControl: "FOLLOW_INPUT",
AudioType: 0,
},
],
Extension: "wav",
NameModifier: "_wav",
},
],
OutputGroupSettings: {
Type: "FILE_GROUP_SETTINGS",
FileGroupSettings: {
Destination: `s3://destination-bucket/`,
S3Settings: {
AccessControl: {
CannedAcl: "PUBLIC_READ"
}
}
},
},
},
],
TimedMetadataInsertion: {
Id3Insertions: [
{
Id3: base64EncodedTestMetadata,
Timecode: '00:00:00:01'
},
]
}
},
UserMetadata: {
"Some Metadata": "TEST",
},

At present MediaConvert cannot set metadata on the RAW container type.
A possible workflow alternative is to embed the desired metadata into the newly created WAV files in an automated fashion using an AWS Lambda function and ffmpeg.
If you would like to see this feature added to MediaConvert, please use the 'Feedback' button in the lower left of the AWS Console, and select 'Feature Request' in the resulting dialog box.

Related

How to tell googlespeech recognition to use a specific phraseset node.js

We have an evolving Node.js app where we had experimented with:
config: {
encoding: "MULAW",
sampleRateHertz: 8000,
languageCode: "en-US",
useEnhanced: true,
model: 'phone_call',
"speechContexts": [{
"phrases": [
{ "value": "battalion", "boost": 10 },
{ "value": "italian", "boost": -10 },
]
}
]
},
singleUtterance: false,
interimResults: true
};
And after some iterative prototypes we also learned how to load phraseset into the google cloud .. so for example our phraseset that can be set and inspected is similar to:
.createPhraseSet({
phraseSet: {
name: "second",
phrases: newPhrases
},
phraseSetId: "PUSDA01",
parent: "projects/project-id/locations/global",
})
.then((res) => {
console.log("speech api res +++", res);
console.log("speech api res 218 +++", JSON.stringify(res));
});
So instead of "speechContexts" being an array pushed on every recognition request we want to our config to tell google to use phraset id "PUSDA01" ... please advise on syntax.
I do not readily see how in: https://googleapis.dev/java/google-api-grpc/0.62.0/com/google/cloud/speech/v1p1beta1/SpeechContext.html
Assuming that the phraseset is already created and you know its name, phraseset could be defined in the config. See code below on how to define it in the config. See RecognitionConfig for the reference.
NOTE: Though I don't have the actual audio to test, but this syntax should work. Use the updated config for recognition. I used your created phraseset with phraseid PUSDA01 as the example:
const phraseSets = {
phraseSets: [
{
name: "projects/your-project-number/locations/global/phraseSets/PUSDA01"
}
]
};
config: {
encoding: "MULAW",
sampleRateHertz: 8000,
languageCode: "en-US",
useEnhanced: true,
model: 'phone_call',
adaptation: phraseSets
},
singleUtterance: false,
interimResults: true
};
If ever you have multiple phraseSets or don't know the name of your phraseSets, you can use listPhraseSet() to get all your available phrases.

Creating AWS S3 object life cycle using NodeJS

Creating AWS S3 object life cycle using NodeJS.
I want to create S3 object life cycle via API using NodeJS. When I see the documentation, AWS provided only multiple object life cycle, with Java.
https://docs.aws.amazon.com/AmazonS3/latest/userguide/how-to-set-lifecycle-configuration-intro.html
I also checked this url -
https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html#getBucketLifecycle-property
Genral Concern
How to set multiple Transition with NodeJS like the way Java has ?
BucketLifecycleConfiguration.Rule rule2 = new BucketLifecycleConfiguration.Rule()
.withId("Archive and then delete rule")
.withFilter(new LifecycleFilter(new LifecycleTagPredicate(new Tag("archive", "true"))))
.addTransition(new Transition().withDays(30).withStorageClass(StorageClass.StandardInfrequentAccess))
.addTransition(new Transition().withDays(365).withStorageClass(StorageClass.Glacier))
.withExpirationInDays(3650)
.withStatus(BucketLifecycleConfiguration.ENABLED);
Followed by -
https://docs.aws.amazon.com/AmazonS3/latest/userguide/how-to-set-lifecycle-configuration-intro.html
Any help would be great.
we need to call putBucketLifecycle and pass Rules Array to LifecycleConfiguration. Similar to CLI Example
s3.putBucketLifecycle(
{
Bucket: "sample-temp-bucket",
LifecycleConfiguration: {
Rules: [
{
Filter: {
And: {
Prefix: "myprefix",
Tags: [
{
Value: "mytagvalue1",
Key: "mytagkey1",
},
{
Value: "mytagvalue2",
Key: "mytagkey2",
},
],
},
},
Status: "Enabled",
Expiration: {
Days: 1,
},
},
{
Filter: {
Prefix: "documents/",
},
Status: "Enabled",
Transitions: [
{
Days: 365,
StorageClass: "GLACIER",
},
],
Expiration: {
Days: 3650,
},
ID: "ExampleRule",
},
],
},
},
(error, result) => {
if (error) console.log("error", error);
if (result) console.log("result", result);
}
);

TagSpecifications with requestSpotInstances UnexpectedParameter with aws-sdk

I'm trying to add a tag to my AWS Spot Request. But it has returned me { UnexpectedParameter: Unexpected key 'TagSpecifications' found in params.LaunchSpecification.
I have followed this documentation, and I have already tried to move this code out of LaunchSpecification, but the error persists.
const params = {
InstanceCount: 1,
LaunchSpecification: {
ImageId: config.aws.instanceAMI,
KeyName: 'backoffice',
InstanceType: config.aws.instanceType,
SecurityGroupIds: [config.aws.instanceSecurityGroupId],
TagSpecifications: [{
ResourceType: 'instance',
Tags: [{
Key: 'Type',
Value: 'Mongo-Dump',
}],
}],
BlockDeviceMappings: [{
DeviceName: '/dev/xvda',
Ebs: {
DeleteOnTermination: true,
SnapshotId: 'snap-06e838ce2a80337a4',
VolumeSize: 50,
VolumeType: 'gp2',
Encrypted: false,
},
}],
IamInstanceProfile: {
Name: config.aws.instanceProfileIAMName,
},
Placement: {
AvailabilityZone: `${config.aws.region}a`,
},
},
SpotPrice: config.aws.instancePrice,
Type: 'one-time',
};
return ec2.requestSpotInstances(params).promise();
Something makes me think that the problem is in the documentation or in the aws-sdk for Javascript itself. My options are exhausted.
The error message is correct. According to the documentation, the RequestSpotLaunchSpecification object doesn't have an attribute called TagSpecifications.
However, you can tag your Spot Instance request after you create it.
ec2.requestSpotInstances(params) returns an array of SpotInstanceRequest objects, each containing a spotInstanceRequestId (e.g. sir-012345678). Use the CreateTags API with these Spot Instance request ids to add the tags.
const createTagParams = {
Resources: [ 'sir-12345678' ],
Tags: [
{
Key: 'Type',
Value: 'Mongo-Dump'
}
]
};
ec2.createTags(createTagParams, function(err, data) {
// ...
});

Dialogflow API V2 largeImage for MediaObject not working

I recently switched from the V1 to V2 for dialogflow and I'm updating my webhook.
I use mediaObjects with large Images in my agent as a personal taste.
Unfortunately I can't seem to make it work for the V2.
My current code for the media object is this:
conv.ask(new MediaObject({
name: 'Name',
largeImage: new Image({
url: 'https://[...].jpg',
alt: 'alternative'
}),
url: 'https://[...].mp3',
description: 'description'
}));
As you can see, I used the largeImage field, as I found it in the JSON section of Google's example . As the documentation is inexistant, I'm checking the node.js library for information and I verified that the largeImage field extends the Image interface so it should be correct.
It works when I switch largeImage for Icon but I don't like it.
My JSON response is like this:
"payload": {
"google": {
"expectUserResponse": true,
"richResponse": {
"items": [
{
"simpleResponse": {
"textToSpeech": "text"
}
},
{
"mediaResponse": {
"mediaType": "AUDIO",
"mediaObjects": [
{
"contentUrl": "https://[...].mp3",
"description": "description",
"name": "name"
}
]
}
}
],
"suggestions": [
{
"title": "Not yet implemented"
}
]
},
"userStorage": "{\"data\":{}}"
}
}
For some reason the largeImage field doesn't appear in my JSON but there isn't any error appearing anywhere.
Some of the APIs in JSON do not match the Node.js parameters. For example, largeImage in JSON is actually image in the MediaObjectOptions definition.

Creating azure VM from image with Node SDK

I'm trying to use the azure sdk (azure-sdk-for-node) to create a virtual machine based on an image i've already saved. I've also already created the service.
Here is what I've got:
// Create a virtual machine in the cloud service.
computeManagementClient.virtualMachines.createDeployment('prerender-pro', {
name: "prerender-pro",
deploymentSlot: "Production",
label: "for heavy duty caching",
roles: [{
roleName: "prerender-pro",
roleType: "PersistentVMRole",
label: "for heavy duty caching",
oSVirtualHardDisk: {
sourceImageName: "prerender-os-2014-07-16",
mediaLink: "https://XXXXXXX.blob.core.windows.net/vhds/prerender-os-2014-07-16.vhd"
},
dataVirtualHardDisks: [],
configurationSets: [{
configurationSetType: "LinuxProvisioningConfiguration",
adminUserName: "Blah",
adminPassword: "Blahblah2014!",
computerName: 'prerender-pro',
enableAutomaticUpdates: true,
resetPasswordOnFirstLogon: false,
storedCertificateSettings: [],
inputEndpoints: []
}, {
configurationSetType: "NetworkConfiguration",
subnetNames: [],
storedCertificateSettings: [],
inputEndpoints: [{
localPort: 3389,
protocol: "tcp",
name: "RemoteDesktop"
}]
}]
}]
}, function (err, result) {
if (err) {
console.error(err);
} else {
console.info(result);
}
});
And the error I'm getting is this. I follow the example in the github readme almost exactly. Not sure why this is an issue.
{ [Error: A computer name must be specified.]
code: 'BadRequest',
statusCode: 400,
requestId: '9206ea1e591eb4dd8ea21a9196da5d74' }
Thanks!
It turns out that the error message is inaccurate. When deploying a Linux instance, only the "HostName" is required when defining the Configuration Set. "ComputerName" applies only to Windows instances. Here's an example of C# code:
ConfigurationSet configSet = new ConfigurationSet
{
HostName = "VMTest",
UserName="xxxxx",
UserPassword="xxxx",
ConfigurationSetType = ConfigurationSetTypes.LinuxProvisioningConfiguration
}

Resources