Audio spells markup when ssml format passed in Ivona - text-to-speech

when i call Ivona API with input as ssml format, i get audio which pronounce ssml markup.
How to correctly call using ssml as input.

I was reqesting the audio with request type as 'text/plain'. The correct input type will be 'application/ssml+xml'.
I am using ivona-node library to get the audio.
The format will be something like this:
var audioText = '<?xml version="1.0"?><speak version="1.0" xmlns="http://www.w3.org/2001/10/synthesis" xml:lang="en-US"><p><s>This is the first sentence of the paragraph.</s><s>Here is another sentence.</s></p></speak>';
ivona.createVoice(audioText, {
body: {
input: {
data: null,
type: 'application/ssml+xml'
},
voice: {
name: 'Raveena',
language: 'en-IN',
gender: 'Female'
}
}
}).pipe(fs.createWriteStream('output.mp3'));

Related

i18next: Custom json format with comments for translation bureau

We are using a custom json format for our i18n resources that contain comments for the translation bureau, so they understand better the context of the strings to translate:
Example en.json:
{
"headerbar": {
"search": {
"placeholder": {
"value": "Enter your search here...",
"comment": "This string will be shown in the search input if empty. Truncated after 100 characters."
}
},
"welcome": {
"heading": {
"value": "Welcome, {{name}}!",
"comment": "This string should not be longer than 50 characters."
}
}
}
How can I configure i18next (or react-i18next) such that the translation is always retrieved from the value property? Without having to use {returnObjects} in every t().
t('headerbar.search.placeholder') // === 'Enter your search here...'
t('welcome.heading', {name: 'Bob'}) // === 'Welcome, Bob!'
I also have this requirement, but it appears i18next does not have the capability to define comments or descriptions, because 1) the API doesn't have a way to define those, and 2) the most popular extractor, i18next-parser, doesn't support generating files with comments included.
Alternatively, you could consider Format.JS which has this capability:
https://formatjs.io/docs/getting-started/message-declaration

Adobe PDF Embed API Save Content To Base64

Using Adobe PDF Embed API, you can register a callback:
this.adobeDCView = new window.AdobeDC.View(config);
this.adobeDCView.registerCallback(
window.AdobeDC.View.Enum.CallbackType.SAVE_API, (metaData, content, options) => {
})
Content is according to the docs here: https://www.adobe.io/apis/documentcloud/dcsdk/docs.html?view=view
content: The ArrayBuffer of file content
When I debug this content using chrome inspector, it shows me that content is a Int8Array.
Normally when we upload a pdf file, the user selects a file and we read as dataURI and get base64 and push that to AWS. So I need to convert this PDF's data (Int8Array) to Base64, so I can also push it to AWS.
Everything I have found online uses UInt8Array to base64, and I don't understand how to go from Int8Array to UInt8Array. I would think you can just add 128 to the signed int to get a ratio between 0-256, but this doesn't seem to work.
I have tried using this:
let decoder = new TextDecoder('utf8');
let b64 = btoa(decoder.decode(content));
console.log(b64);
But I get this error:
ERROR DOMException: Failed to execute 'btoa' on 'Window': The string to be encoded contains characters outside of the Latin1 range.
Please help me figure out how to go from Int8Array to Base64.
I use the function in this answer.
For Embed API, use the "content" parameter from the save callback as the input to the function.
You can see a working example at this CodePen. The functional part is below.
adobeDCView.registerCallback(
AdobeDC.View.Enum.CallbackType.SAVE_API,
function (metaData, content, options) {
/* Add your custom save implementation here...and based on that resolve or reject response in given format */
var base64PDF = arrayBufferToBase64(content);
var fileURL = "data:application/pdf;base64," + base64PDF;
$("#submitButton").attr("href", fileURL);
/* End save code */
return new Promise((resolve, reject) => {
resolve({
code: AdobeDC.View.Enum.ApiResponseCode.SUCCESS,
data: {
/* Updated file metadata after successful save operation */
metaData: { fileName: urlToPDF.split("/").slice(-1)[0] }
}
});
});
},
saveOptions
);

esri add graphic from json to graphicslayer is giving error

hi i am trying to add graphic to graphicslayer. here is the problem.
i get json result from sketchviewmodel create function which is graphic.
i store this in to new jsonobject.
then i try to add this graphic into graphicslayer manually. but its giving error.
here is the json
{
"geometry":{
"spatialReference":{
"latestWkid":3857,
"wkid":102100
},
"x":243208.09643883476,
"y":2940285.766420703,
"z":351.9580905416081
},
"symbol":{
"type":"point-3d",
"symbolLayers":[
{
"type":"Icon",
"material":{
},
"resource":{
"primitive":"kite"
},
"size":15,
"outline":{
"color":[
0,
0,
0
],
"size":2.25
}
}
]
},
"attributes":{
},
"popupTemplate":null
}
this code gives error
const [Graphic] = await loadModules(["esri/Graphic"]);
let g = new Graphic(data); // data which is json i gave.
any adivce ? Thank you.
Assuming you are using toJSON method of Graphic to generate the json object (in your example data). Then the correct way of creating a Graphic from the json object is to use the "reverse" method fromJSON. Something like this should work,
const [Graphic] = await loadModules(["esri/Graphic"]);
// here use fromJSON method to create the graphic
let g = Graphic.fromJSON(data); // data which is json i gave.
ArcGIS API - Graphic fromJSON

How to update HTML of Youtube video snippet description from the API exposed through Google Apps Script?

I want to update my Youtube video snippet.description from the API exposed through Google Apps Script. The snippet contains formatting so I am trying to use HTML. I expect to see the updated snippet on my Youtube video. But I get the following error instead.
API call to youtube.videos.update failed with error: The request metadata specifies an invalid video description. (line 88, file "Youtube")
How can I format my video description?
Youtube.gs
function updateVideo( data ) {
var videoId = 'foo';
var title = 'bar';
var description = '<p>baz</p><p>bat</p>';
var resource = {
id: videoId,
snippet: {
title: title,
description: description,
categoryId: '22'
}
};
YouTube.Videos.update(resource, 'id,snippet'); // this is line 88
}
You can't use HTML so you have to use string symbols for newline \n and tab \t, etc.
var description = 'baz\n\nbat';
I don't know how to add other HTML features like links, etc. Maybe someone else can improve upon this answer by adding that information if they know how to do it.

how to get pjscrape to print out current url in a file?

I am using pjscrape to scrape content from dynamic pages generated by a site. Please see code below.
I cant figure out what I need to do to get it to print out the url of the scraped page in the json variables dumped to a file. I have tried various ways of doing it - including document.url etc ( see lines 3-6 that are commented out in code below ). However I cant figure out how to get the urlFound variable to get the right value. Of course, the answer might be dead simple but its eluding me. Any other way of doing this? Help!
var scraper = function() {
return {
//urlFound:$(window.location.href),
//urlFound: $(this).window.location.href,
//urlFound: _pjs.toFullUrl($(this).attr('href')),
//urlFound: _pjs.toFullUrl($(this).URL),
// Heck - how to print out the url being scraped???
name: $('h1').text(),
marin: _pjs.getText($("script:contains('marin')"))
}
};
pjs.config({
// options: 'stdout', 'file' (set in config.logFile) or 'none'
log: 'stdout',
// options: 'json' or 'csv'
format: 'json',
// options: 'stdout' or 'file' (set in config.outFile)
writer: 'file',
outFile: 'scrape_output.json'
});
pjs.addSuite({
url: 'http://www.mophie.com/index.html',
moreUrls: function() {
return _pjs.getAnchorUrls('li a');
},
scraper: scraper
});
Don't need jquery for your selector on window.location.href. Not sure how to get access to the internal url of pjscraper, but changing your code to this works:
var scraper = function() {
return {
urlFound: window.location.href,
name: $('h1').text(),
marin: _pjs.getText($("script:contains('marin')"))
}
};
Or you can just use document.URL...save that as a variable and then write it to a file using How to read and write into file using JavaScript