AT&T Dev Prog: Speech to Text Custom Post - speech-to-text

When I check the documentation on Developer.ATT.com I see this example of the format (Code)I should use:
POST https://api.att.com/speech/v3/speechToTextCustom HTTP/1.1
Host: api.att.com
Authorization: Bearer 38C2399A23999
X-SpeechContext: GrammarList
Accept: application/json
Content-length: 7012
Content-Language: en-us
Content-type: multipart/x-srgs-audio; boundary=----------------------------46ef33c653e2
------------------------------46ef33c653e2
Content-Disposition: form-data; name="x-dictionary"; filename="speech_alpha.pls"
Content-Type: application/pls+xml
<?xml version="1.0" encoding="UTF-8"?>
<lexicon version="1.0" alphabet="sampa" xml:lang="en-US">
<lexeme>
<grapheme>Qiang</grapheme>
<phoneme>tS { n</phoneme>
</lexeme>
</lexicon>
------------------------------46ef33c653e2
Content-Disposition: form-data; name="x-grammar"
Content-Type: application/srgs+xml
<grammar root="top" xml:lang="en-US">
<rule id="CONTACT">
<one-of>
<item>Qiang</item>
<item>David</item>
</one-of>
</rule>
<rule id="top" scope="public">
<item>
<one-of>
<item>text</item>
<item>send message to</item>
</one-of>
</item>
<ruleref uri="#CONTACT"/>
</rule>
</grammar>
------------------------------46ef33c653e2
Content-Disposition: form-data; name="x-voice"; filename="speech_ex.amr"
Content-Type: audio/amr
{{...audio data...}}
------------------------------45ef33c653e2--
Since I am having trouble getting this to work I am wondering if I should include the dictionary and grammar parts of the post as well? Why?

To use the customspeech engine (for non-standard languages) the grammar file is required as you need to supply the vocabulary for transcription whenever using the customspeech engine.
You are able use the regular speech API for transcription with no grammar file but it may not cover what you are trying to do.
It looks like you are trying to take advantage of the large number of non-English languages available with the AT&T customspeech engine. All of those languages do require that you supply a grammar file in order to work.
Supported non custom languages are American English and American Spanish.

Related

How to output xml file as text in u-sql?

I've a XML file that I need to output as text, how can I do that? What is the best and efficient way to get text output via u-sql?
INPUT XML:
<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
<channel>
<title>abstract.xml</title>
<link>download.wikimedia.org/enwiki/20171103</link>
<description>Wikimedia dump updates for enwiki</description>
<item>
<title>download.wikimedia.org/enwiki/20171103</title>
<link>download.wikimedia.org/enwiki/20171103</link>
<description>
<a href="download.wikimedia.org/enwiki/20171103/…" />
</description>
<pubDate>Sun, 05 Nov 2017 21:11:20 GMT</pubDate>
</item>
</channel>
</rss>
This is my xml and I'm trying with below code to retrieve its data.
REFERENCE ASSEMBLY [Microsoft.Analytics.Samples.Formats];
#wiki = EXTRACT title string,
link string //abst string
FROM #input
USING new Microsoft.Analytics.Samples.Formats.Xml.XmlExtractor(
"doc",
new SQL.MAP<string,string> {
{"title","title" },
{"link","link" }
}
);
There is a great example from Microsoft showed here:
https://github.com/Azure/usql/tree/master/Examples/DataFormats/Microsoft.Analytics.Samples.Formats
You can just bind the .DLL file and refer to it in your u-sql project.
I've used it a lot in the past for extracting and outputting both json and xml.

Shell script embed multiple image with sendmail

I'm using following script to embed multiple image on a mail using sendmail function.
sendmail -t <<EOT
TO: example_to#xyz.com
FROM: example_from#xyz.com
Cc: example_cc#xyz.com
SUBJECT: Phobos Report
MIME-Version: 1.0
Content-Type: multipart/related;boundary="XYZ"
--XYZ
Content-Type: text/html; charset=ISO-8859-15
Content-Transfer-Encoding: 7bit
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-15">
</head>
<body bgcolor="#ffffff" text="#000000">
<img src="cid:part1.06090408.01060107" alt=""><br/>
<img src="cid:part2.06090408.01060107" alt=""><br/>
<img src="cid:part3.06090408.01060107" alt="">
</body>
</html>
--XYZ
Content-Type: image/jpeg;name="rag1.jpg"
Content-Transfer-Encoding: base64
Content-ID: <part1.06090408.01060107>
Content-Disposition: inline; filename="rag1.jpg"
$(base64 rag1.jpg)
--XYZ
Content-Type: image/jpeg;name="rag2.jpg"
Content-Transfer-Encoding: base64
Content-ID: <part2.06090408.01060107>
Content-Disposition: inline; filename="rag2.jpg"
$(base64 rag2.jpg)
--XYZ
Content-Type: image/jpeg;name="rag3.jpg"
Content-Transfer-Encoding: base64
Content-ID: <part3.06090408.01060107>
Content-Disposition: inline; filename="rag3.jpg"
$(base64 rag3.jpg)
--XYZ--
EOT
Here only the first image getting embedded. And all the others are failed to get added. Those two images are added as text based attachment. How can I add multiple images on this script?
It is an old question, but I think it deserves an answer anyway.
The problem with your code is that you are putting empty lines between the MIME boundary and the MIME headers of the last two images, as here:
--XYZ
Content-Type: image/jpeg;name="rag2.jpg"
Content-Transfer-Encoding: base64
Content-ID: <part2.06090408.01060107>
Content-Disposition: inline; filename="rag2.jpg"
This is not allowed. You should correct your code and delete those empty lines in two places, as follows, here:
--XYZ
Content-Type: image/jpeg;name="rag2.jpg"
Content-Transfer-Encoding: base64
Content-ID: <part2.06090408.01060107>
Content-Disposition: inline; filename="rag2.jpg"
and here:
--XYZ
Content-Type: image/jpeg;name="rag3.jpg"
Content-Transfer-Encoding: base64
Content-ID: <part3.06090408.01060107>
Content-Disposition: inline; filename="rag3.jpg"
Empty lines are allowed before the boundary line, which means that they will be part of the preceding body, where they are usually harmless (but I can make up contexts where they wouldn’t be. It’s not your case, however.)
It’s best never to put extra empty lines on either side of MIME boundaries. Of course, this is not about the empty line needed before the first MIME boundary, where it separates the MIME header.
try to do it without line break tag
<img src="cid:part1.06090408.01060107" alt="">
<img src="cid:part2.06090408.01060107" alt="">
<img src="cid:part3.06090408.01060107" alt="">
tested it myself and it is working fine

TaxonomyClientService.GetTermSets 400 bad request

What is wrong with this SOAP request? I keep on getting 400 bad request error.
<S:Body>
<GetTermSets xmlns="http://schemas.microsoft.com/sharepoint/taxonomy/soap/">
<sharedServiceIds>
<termStoreIds>
<termStoreId>27a0a321-083f-4688-8b6e-d86b7ab42de9</termStoreId>
</termStoreIds>
</sharedServiceIds>
<termSetIds>
<termSetIds><termSetId>cb1b9444-159d-48c3-b9a7-19ebd612e796</termSetId></termSetIds>
</termSetIds>
<lcid>1033</lcid>
<clientTimeStamps>
<timeStamps><timeStamp>2304823424</timeStamp></timeStamps>
</clientTimeStamps>
<clientVersions><versions><version>1</version></versions></clientVersions>
</GetTermSets>
</S:Body>
I was struggling with this for a long time as well, and had extrapolated the same request from all the examples that I could find online.
But I managed to get it working by looking up "MS-EMMWS" (my working example below)
MS-EMMWS - Protocol Examples
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<GetTermSets xmlns="http://schemas.microsoft.com/sharepoint/taxonomy/soap/">
<sharedServiceIds><sspIds><sspId>0d18c636-63d4-452b-b094-6de97ee5159d</sspId></sspIds>
</sharedServiceIds><termSetIds><termSetIds><termSetId>48508451-17d5-4bdb-b1c9-7f096f680352</termSetId></termSetIds></termSetIds><lcid>1033</lcid>
<clientTimeStamps><dateTimes><dateTime>1900-01-01T00:00:00</dateTime></dateTimes></clientTimeStamps>
<clientVersions><versions><version>0</version></versions></clientVersions></GetTermSets>
</soap:Body>
</soap:Envelope>

How can I output the soap fragment with perl SOAP::Lite?

I am a new comer to soap protocol, so I want to find a perl module to produce soap fragments so that I can learn how to construct a soap fragment with it, SOAP::Lite is an excellent module for soap, but I can not find tutorials on how to output the soap fragment to files or stdout, so any tips?
regards.
use strictures;
use SOAP::Lite qw();
my $soap_body = SOAP::Data->name('foo' => \SOAP::Data->value(SOAP::Data->name('bar' => '123')));
print SOAP::Serializer->envelope(freeform => $soap_body);
$ perl -C /tmp/soap.pl | xmllint -format -
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<soap:Body>
<foo>
<bar xsi:type="xsd:int">123</bar>
</foo>
</soap:Body>
</soap:Envelope>
For experimentation tasks like this, it is usually better to use a REPL. It gives you quicker turn-around because you see the results immediately after entering an expression.

Can EXSLT date-and-time functions be used in XSLT 1.0 and processed using browser engine?

My goal: I need to transform a "date of birth" element in XML document to "age" value using XSL stylesheet and generate XHTML page. I am using the web browser (e.g. IE/FF) directly to open the XML document.
I know XSLT 2.0 has built-in date and time functions, but I think no browser currently support this. So, I've been trying to use EXSLT functions instead without success.
Here are my sample test files:
test.xml
<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="test.xsl"?>
<test>
</test>
test.xsl
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:date="http://exslt.org/dates-and-times">
<xsl:output method="text"/>
<xsl:template match="/">
<xsl:value-of select="date:date-time()"/>
</xsl:template>
</xsl:stylesheet>
Error on IE8:
Namespace 'http://exslt.org/dates-and-times' does not contain any functions.
Error on FF4:
Error during XSLT transformation: An unknown XPath extension function was called.
Does that mean EXSLT is not supported by major web browsers? Do I have to use XSLT proccessor like SAXON/Xalan? Am I doing something wrong? Is there an alternative way?
Use the EXSLT support matrix as a reference:
The following XSLT processors support date:date-time:
SAXON from Michael Kay (version 6.4.2)
Xalan-J from Apache (version 2.4.D1)
4XSLT, from 4Suite. (version 0.12.0a3)
libxslt from Daniel Veillard et al. (version 1.0.19)
libxslt is used by Chrome, Opera and Safari, but date-time() does not work since EXSLT is disabled:
I don't think it makes sense to add functions piecemeal; after nearly 5 years is there still anything preventing libexslt being included in the build and exsltRegisterAll() being called from registerXSLTExtensions() in XSLTExtensions.cpp?
IE uses MSXML, which has the following support:
MSXML4 provided two great extension functions, ms:format-date() and ms:format-time() to aim at the latter problem, but they are not supported in .NET or MSXML3.
There is no ms:date-time() function, but there is an MSXSL extension.
<?xml version='1.0'?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
xmlns:ecma ="about:ecma">
<msxsl:script implements-prefix="ecma">
<![CDATA[
function GetCurrentDateTime()
{
var currentTime = new Date();
var month = currentTime.getMonth() + 1;
var day = currentTime.getDate();
var year = currentTime.getFullYear();
return(month + "/" + day + "/" + year);
}
]]>
</msxsl:script>
<xsl:template match="/">
<xsl:value-of select="ecma:GetCurrentDateTime()"/>
</xsl:template>
</xsl:stylesheet>
Firefox uses Transformiix, which has support for EXSLT date-time() since FF6.
References
MDN: EXSLT
EXSLT - date:date-time
XSL Transformations (XSLT) in Mozilla
Test Cases for XSLT support in browsers
Mozilla Bug 603159 - implement exslt-date:date-time()
Webkit Bug 4079 Support EXSLT with libexslt
Mozilla Bug 265254 - support exlst:date
Transformiix: Elements and Functions Available
Building Practical Solutions with EXSLT.NET
Microsoft XPath Extension Functions

Resources