Azure Cognitive Services - Batch Transcription API responds with error message "The recording URI is invalid." - azure

Steps Followed:
I created a speech services instance in West US.
I have the right headers(Content-Type and Ocp-Apim-Subscription-Key)
I make a POST request to https://westus.cris.ai/api/speechtotext/v2.0/transcriptions/ with below request payload
{
"recordingsUrl": "https://transcribehm97c1.blob.core.windows.net/audio-files/2019-04-04_Blockchain%20explained%20with%20TruStory%27s%20Preethi%20Kasireddy.mp3?st=2019-05-27T12%3A19%3A27Z&se=2019-12-31T12%3A19%3A00Z&sp=rl&sv=2018-03-28&sr=b&sig=HFBvGl1pmCM95MNU9U3yniMNXrUMT6RmPb36F32cxrY%3D",
"models": [],
"locale": "en-US",
"name": "I dont know why this is not working",
"description": "Someone please send help",
"properties": {
"ProfanityFilterMode": "Masked",
"PunctuationMode": "DictatedAndAutomatic"
}
}
I get a “202 Accepted” response with below headers. This confirms that the request body is valid.
location: https://westus.cris.ai/api/speechtotext/v2.0/transcriptions/69b7abf4-6383-4490-88a9-9fd42a77e470
When I make a GET Request to the above location, I see this
{
"recordingsUrl": "https://transcribehm97c1.blob.core.windows.net/audio-files/2019-04-04_Blockchain explained with TruStory's Preethi Kasireddy.mp3?st=2019-05-27T12:19:27Z&se=2019-12-31T12:19:00Z&sp=rl&sv=2018-03-28&sr=b&sig=HFBvGl1pmCM95MNU9U3yniMNXrUMT6RmPb36F32cxrY%3D",
"resultsUrls": {},
"models": [“I have removed this for brevity”],
"statusMessage": "The recordings URI is invalid.",
"id": "69b7abf4-6383-4490-88a9-9fd42a77e470",
"createdDateTime": "2019-05-27T12:43:39Z",
"lastActionDateTime": "2019-05-27T12:43:50Z",
"status": "Failed",
"locale": "en-US",
"name": "I dont know why this is not working",
"description": "Someone please send help",
"properties": {
"ProfanityFilterMode": "Masked",
"PunctuationMode": "DictatedAndAutomatic"
}
}
The transcriptions fails for some URL's while passing for others for blobs in the same storage although they are all valid URL’s. The SAS URI in the request is valid till end of the
year.
I have re-tried the same request multiple times via code and Postman and it fails.
Link to Swagger Page : https://westus.cris.ai/swagger/ui/index

The issue may be due to the audio file size. Please refer the core features for REST API as the REST support only short Audio.

Related

obtain item-id for microsoft graph api

I am trying to figure out how to obtain an "item-id" for a file in a sharepoint site for microsoft graph API.
Microsoft documentation: https://learn.microsoft.com/en-us/graph/api/driveitem-get?view=graph-rest-1.0&tabs=http
Here is what I tried for far:
Tried using https://developer.microsoft.com/en-us/graph/graph-explorer to guess the api link that will let me download the file I want.
I first tried to get the sharepointsite like so:
https://graph.microsoft.com/v1.0/sites/omidtechnfr.sharepoint.com:/sites/delploy
That worked:
{
"#odata.context": "https://graph.microsoft.com/v1.0/$metadata#sites/$entity",
"createdDateTime": "2021-07-15T21:02:02.78Z",
"description": "delploy",
"id": "omidtechnfr.sharepoint.com,5e03397e-03b0-4d92-9658-f9163f0131b3,1d9f21da-4d74-45db-b5d4-e4a7f7f278a1",
"lastModifiedDateTime": "2021-07-17T02:16:39Z",
"name": "delploy",
"webUrl": "https://omidtechnfr.sharepoint.com/sites/delploy",
"displayName": "delploy",
"root": {},
"siteCollection": {
"hostname": "omidtechnfr.sharepoint.com"
}
}
So then I tried using what I ASSUME is the item-id for the SharePoint site delploy to try and get more information out of the site so I can try to find the item-id for the file I want to download:
https://graph.microsoft.com/v1.0/sites/5e03397e-03b0-4d92-9658-f9163f0131b3/drive/
And I got back some result but it doesn't so the item-id for me to do anything with it:
{
"#odata.context": "https://graph.microsoft.com/v1.0/$metadata#drives/$entity",
"createdDateTime": "2021-07-11T05:16:50Z",
"description": "",
"id": "b!fjkDXrADkk2WWPkWPwExs9ohnx10TdtFtdTkp_fyeKF_K1_Z49FFSbzXVFRA5GKa",
"lastModifiedDateTime": "2021-07-16T18:32:35Z",
"name": "Documents",
"webUrl": "https://omidtechnfr.sharepoint.com/sites/delploy/Shared%20Documents",
"driveType": "documentLibrary",
"createdBy": {
"user": {
"displayName": "System Account"
}
}
At this point I started to get desperate and a little angry. So I tried to just download the file from sharepoint and assume that the characters at the end of the download link was the item-id but that didn't work either:
download link:
https://omidtechnfr.sharepoint.com/sites/delploy/_layouts/15/download.aspx?UniqueId=25e2fd4f%2Deb32%2D43ac%2D9141%2Dfa47a610a27c
Used https://www.urldecoder.org/ to decode what I am assuming is the item-id for the file I want to download
25e2fd4f-eb32-43ac-9141-fa47a610a27c
Then tried to desperately tack this on to the Microsoft graph api to see what happens:
https://graph.microsoft.com/v1.0/sites/5e03397e-03b0-4d92-9658-f9163f0131b3/drive/items/25e2fd4f-eb32-43ac-9141-fa47a610a27c
and it failed:
{
"error": {
"code": "itemNotFound",
"message": "The resource could not be found.",
"innerError": {
"date": "2021-07-17T14:13:51",
"request-id": "985e2893-5343-47ac-a93c-6629a00c4eb3",
"client-request-id": "73a3b6d0-f1ce-bb51-b126-43f0957d15e3"
}
}
}
You could get the file by the path: https://graph.microsoft.com/v1.0/sites/{site-id}/drive/root:/{item-path}
For example: https://graph.microsoft.com/v1.0/sites/{site-id}/drive/root:/test.docx
If the file is in a folder, it would be like this: https://graph.microsoft.com/v1.0/sites/{site-id}/drive/root:/folder1/test.docx
I used the search site id endpoint GET /sites/{site-id}/drive/root/search(q='{search-text}')
Documentation here.

How do determine Azure WAF rule that affect to my specific url

My request got 403 when access to url like this format
https://example.com/Test.aspx?param=https%3A%2F%2Fwww.test.com%2Fen-us%3F
I have read the document but I not sure which rule prevented my request.
Anyone can show me:
How do find exactly rule prevent my request
Report prevented requests (I have looked at the log but nothing in there)
If you have enabled WAF monitoring for application gateway or for Azure front door, you should see the ruleId in the Firewall log. Please note that the logs are only saved hourly. You could get more details from this blog.
{
"resourceId": "/SUBSCRIPTIONS/{subscriptionId}/RESOURCEGROUPS/{resourceGroupName}/PROVIDERS/MICROSOFT.NETWORK/APPLICATIONGATEWAYS/{applicationGatewayName}",
"operationName": "ApplicationGatewayFirewall",
"time": "2017-03-20T15:52:09.1494499Z",
"category": "ApplicationGatewayFirewallLog",
"properties": {
"instanceId": "ApplicationGatewayRole_IN_0",
"clientIp": "104.210.252.3",
"clientPort": "4835",
"requestUri": "/?a=%3Cscript%3Ealert(%22Hello%22);%3C/script%3E",
"ruleSetType": "OWASP",
"ruleSetVersion": "3.0",
"ruleId": "941320",
"message": "Possible XSS Attack Detected - HTML Tag Handler",
"action": "Blocked",
"site": "Global",
"details": {
"message": "Warning. Pattern match \"<(a|abbr|acronym|address|applet|area|audioscope|b|base|basefront|bdo|bgsound|big|blackface|blink|blockquote|body|bq|br|button|caption|center|cite|code|col|colgroup|comment|dd|del|dfn|dir|div|dl|dt|em|embed|fieldset|fn|font|form|frame|frameset|h1|head|h ...\" at ARGS:a.",
"data": "Matched Data: <script> found within ARGS:a: <script>alert(\\x22hello\\x22);</script>",
"file": "rules/REQUEST-941-APPLICATION-ATTACK-XSS.conf",
"line": "865"
}
"hostname": "40.90.218.100",
"transactionId": "AYAcUqAcAcAcAcAcASAcAcAc"
}
}

Dialogflow Fulfillment URLnot sending any data

I am building a bot for google assistant. I have enabled fulfillment section for some intents. Dialog flow sends the request to the fulfillment url. The url is executed and a hard coded response is returned. I can see the response in the assistant simulator. Everything works fine except one thing. The request is empty.I can't access fields that are supposed to be present in the request.
I have accessed the same url using post request from a python code and it displays the parameters. So, there are no issues in the code. I think I am missing some configuration option.
I was expecting the post body in the following format:
POST body:
{
"responseId": "ea3d77e8-ae27-41a4-9e1d-174bd461b68c",
"session": "projects/your-agents-project-id/agent/sessions/88d13aa8-2999-4f71-b233-39cbf3a824a0",
"queryResult": {
"queryText": "user's original query to your agent",
"parameters": {
"param": "param value"
},
"allRequiredParamsPresent": true,
"fulfillmentText": "Text defined in Dialogflow's console for the intent that was matched",
"fulfillmentMessages": [
{
"text": {
"text": [
"Text defined in Dialogflow's console for the intent that was matched"
]
}
}
],
"outputContexts": [
{
"name": "projects/your-agents-project-id/agent/sessions/88d13aa8-2999-4f71-b233-39cbf3a824a0/contexts/generic",
"lifespanCount": 5,
"parameters": {
"param": "param value"
}
}
],
"intent": {
"name": "projects/your-agents-project-id/agent/intents/29bcd7f8-f717-4261-a8fd-2d3e451b8af8",
"displayName": "Matched Intent Name"
},
"intentDetectionConfidence": 1,
"diagnosticInfo": {},
"languageCode": "en"
},
"originalDetectIntentRequest": {}
}
But when I print the post data using print(request.POST), the actual post request shown is
One more thing: Does dialog flow append the action at the end of the fulfillment url? If so, I will have to handle the logic separately. I have done it without considering the action name. But a lot of my stuff is hacked, so I just want to be sure.
On another note, is dialogflow good enough? It has worked fine on a few examples similar to what it was trained on. How many training samples does it need to work properly? What is the underlying algorithm used in dialogflow? Or should I use the fulfillment url and handle everything on my own? I am inclined towards the later. I do not have too much faith in the existing chatbots.
Any help is appreciated.
If the Fallback Intent is the one being triggered, then you wouldn't get any parameters since this means that nothing else matched.
Got it. Used request.body. This solves the problem. Then parsed it using json.loads and accessed the parameters.

Request timeout in API.AI

I have an API.ai agent that sends a request (comes from the user) to a webhook which needs a lot of processing (more than 5 sec) to get the answer. As far as I know, that there is no way to increase the response timeout in API.ai
So, I have created 2 intents. The first one simply will call my webhook to start the processing the result, and at the same time the webhook will reply to the user, "Your request is under processing...".
The second intent has an event and action. The purpose of the new event is just to display the result to the user.
Once the result is ready, my backend application will send a curl statement to trigger the event in the second intent with the necessary parameter modifications like sessionID, v, and time zone … etc.
I have received the following JSON from API.AI (I created an example to simplify my case):
{ "id": "de31ee96-c42f-4f2d-8461-ee39279ec2ed", "timestamp": "2017-09-27T13:39:46.932Z", "lang": "en", "result": {
"source": "agent",
"resolvedQuery": "custom_event",
"action": "test",
"actionIncomplete": false,
"parameters": {
"user_name": "Sam"
},
"contexts": [
{
"name": "welcoming-followup",
"parameters": {
"name.original": "",
"user_name": "Sam",
"name": "",
"user_name.original": ""
},
"lifespan": 2
}
],
"metadata": {
"intentId": "c196a388-16ac-4966-b55c-7cd999a7d680",
"webhookUsed": false,
"webhookForSlotFillingUsed": "false",
"intentName": "Welcoming"
},
"fulfillment": {
"speech": "Hello Sam",
"messages": [
{
"type": 0,
"speech": "Hello Sam"
}
]
},
"score": 1.0 }, "status": {
"code": 200,
"errorType": "success" }, "sessionId": "67cb28fd-6871-750c-d668-d0b736b763ec" }
Here is the curl statement that was sent by my backend.
The curl statement is: curl -X POST -H "Content-Type: application/json; charset=utf-8" -H "Authorization: Bearer I INSERTED THE CORRECT CODE HERE" --data "{'event':{ 'name': 'custom_event', 'data': {'name': 'Sam'}}, 'timezone':'America/New_York', 'lang':'en', 'sessionId':'a6ac2555-4b19-40f8-92ec-397f6a042dde'}" "https://api.api.ai/v1/query?v=20150910"
As shown from the above JSON, the API.ai agent received the trigger successfully. But, The response that I have specified in the “Response Section” does not appear to the user.
I attached a screenshot for the second intent in the API.ai agent.
Note: I tried the agent in developer console, WebDemo and Slack. None of them shown to me (as a user) the specified response.
I am not sure if I did something wrong?
screenshot of the second intent
API.AI is not really meant to handle event-driven activities. It is meant to be the intermediary in a conversation - so the normal pattern is:
User says something
API.AI processes this, possibly with a webhook, and sends a response.
Devices such as Google Home do not have a way to get a notification, so unless the user says something (step 1), then you will never get to step 2.
When you try to trigger it manually, API.AI is treating your trigger as the step 1, and it is replying to your trigger. It has no way to send that reply back to the Assistant because it isn't having a conversation with the Assistant at that moment - it is having a conversation with however you manually triggered it.
There isn't really a good way to do what you want right now. We know notifications are coming to the Assistant eventually (it was announced at I/O 2017), but we don't know if it will have an API or what it will look like. The Transaction API does have notifications as part of it, but Transactions are meant for activities where you are purchasing or reserving something. If you need to, you can use something like Firebase Cloud Messaging to let your user know they can ask for the result, but that's a sub-optimal experience.

Outlook Mail REST API: send message with attachment

I'm trying to use next API method: https://msdn.microsoft.com/office/office365/APi/mail-rest-operations#SendMessages. Sending messages without attachments works just fine, but I can not understand how to send message with attachments.
According to docs, Message structure can contain array of Attachments with items of type https://msdn.microsoft.com/office/office365/APi/complex-types-for-mail-contacts-calendar#RESTAPIResourcesFileAttachment . Problem is in the field ContentBytes -- it is impossible to dump bytes to JSON before sending request to this API method (actually dumping any BLOB to JSON is nonsense).
How should I pass Attachments using REST API at all?
Thanks.
There's an example of passing the attachment on that page: https://msdn.microsoft.com/office/office365/APi/mail-rest-operations#SendMessageOnTheFly
I know I'm 3 years late but, you can look at this example:
https://msdn.microsoft.com/office/office365/APi/mail-rest-operations#create-and-send-messages (if you don't get forwarded to the section "Create and send messages", please scroll manually).
I know it is 365 and not Microsoft Graph but request is absolutely same.
This is basically how JSON representation of the post method looks:
https://outlook.office.com/api/v2.0/me/sendmail
{
"Message":
{
"Subject": "Meet for lunch?",
"Body": {
"ContentType": "Text",
"Content": "The new cafeteria is open."
},
"ToRecipients": [
{
"EmailAddress": {
"Address": "garthf#a830edad9050849NDA1.onmicrosoft.com"
}
}
],
"Attachments": [
{
"#odata.type": "#Microsoft.OutlookServices.FileAttachment",
"Name": "menu.txt",
"ContentBytes": "bWFjIGFuZCBjaGVlc2UgdG9kYXk="
}
]
}
}

Resources