Replying with SSML for Phone Gateway - dialogflow-cx

As part of my response JSON, I am sending the following to the Dialogflow CX Phone Gateway:
"fulfillmentResponse": {
"messages": [
{
"outputAudioText": {
"ssml": "<speak>That is <break time=\"500ms\"/> <emphasis level=\"strong\">correct</emphasis></speak>",
"allowPlaybackInterruption": true
}
},
{
"outputAudioText": {
"ssml": "<speak>What would you like to do now?</speak>",
"allowPlaybackInterruption": true
}
}
]
}
If I understand the documentation for ResponseMessage correctly, then these should be used for audio output.
But if the OutputAudioText object are the only messages included, then nothing is said in response. If I then add a Text object, then the (plain) text object is used for TTS.
Is SSML actually supported for the Dialogflow CX Phone Gateway? If so, how?

This appears to be a known bug at the moment.
See the thread on twitter which is partially excerpted below.
From Lee Boonstra: I tested this, and I can reproduce. I wouldn't be surprised if this is a bug since the telephony gateway is still in early preview and the output audio text seems to be a new feature. - I am checking it with the team.
From Lee Boonstra: Yes, I can confirm myself :) - the bug was already filed. Will be fixed very soon, but for the competition you will likely not been able to use SSML in the phone gateway. (It depends per integration tho)
From Allen "Prisoner" Firstenberg: Thanks for checking on and confirming this, Lee! Very much appreciated. To make sure I'm on the right track, "outputAudioText" is the correct way to do this?
From Lee Boonstra: Yes it is, and it takes a string with <speak> tags

Related

Convert Video to text(transcript) by google cloud speech to text with Rails Application

Working on a WebAppon Ruby on Rails.
I want to get subtitle for Pre recorded video and also for new videos going to record.
I have implemented the gem 'google-cloud-speech'.
But now I'm not able to get text for my video. I get a suggestion from Google Cloud API doc to add model but when I add model: 'video' to configuration, it says there is no such field model in initialization map entry.
My code without adding model is as per below.
speech_client = Google::Cloud::Speech.new
config ={ encoding: :LINEAR16,
sample_rate_hertz: 16000,
language_code: "en-US",
}
audio = { uri: #uri }
response = speech.recognize config, audio
which is giving me error message like below.
Google::Gax::RetryError: GaxError Exception occurred in retry method that was not classified as transient, caused by 3:Request contains an invalid argument.
from /Users/hiren/.rvm/gems/ruby-2.5.1#Snip/gems/google-gax-1.3.0/lib/google/gax/api_callable.rb:369:in `rescue in block in retryable'
Any help is appreciated.
Thanks
Regarding the model issue, this might be due to that the video model is not available yet for Ruby V1 API version as this feature it's part of the v1p1beta1 version.
Regarding your code issue, I just did the example shown here successfully. It would be helpful if you attach your full code as the documented code works well.

Go Youtube API The field startWithSlate is required, startWithSlateRequired

I'm trying to update broadcast event with Go's youtube data API v3
But it always show an Error if I set it to false: The field startWithSlate is required, startWithSlateRequired unless I set startWithSlate to true or remove the lib's source code on youtube/v3/youtube_gen.go from
StartWithSlate bool `json:"startWithSlate,omitempty"`
to
StartWithSlate bool `json:"startWithSlate"`
Is there any other solution for this? or if this a bug, where can I send the bug report? since the site told me to post on stackoverflow.

How do I retrieve step count data from Google Fitness REST api?

Since I installed the Google Fit app on my Nexus 5 it has been tracking my step count and time spent walking. I'd like to retrieve this info via the Google Fitness REST api (docs) but I can't work out how to get any of that data from the REST api.
I've used the OAuth 2.0 playground to successfully list dataSources but none of the examples I have tried have returned any fitness data whatsoever. I feel like I need to use something similar to a DataReadRequest from the (Android SDK) but I'm not building an Android app -- I just want to access fitness data already stored by the Google Fit app.
Is it even possible to get the data gathered by the Google Fit app? If so, how can I read and aggregate step count data using the REST api?
It turns out that the answer is in the docs after all. Here is the format of the request.
GET https://www.googleapis.com/fitness/v1/users/{userId}/dataSources/{dataSourceId}/datasets/{datasetId}
The only supported {userId} value is me (with authentication).
Possible values for {dataSourceId} are avaiable by running a different request.
The bit I missed was that {datasetId} is not really an ID, but actually where you define the timespan in which you are interested. The format for that variable is {startTime}-{endTime} where the times are in nanoseconds since the epoch.
I was able to get this working by going through the google php client and noticed that they append their start and finish times for the GET request with extra 0's - nine infact.
Use the same GET request format as mentioned in an answer above:
https://www.googleapis.com/fitness/v1/users/{userId}/dataSources/{dataSourceId}/datasets/{datasetId}
Now here is an example with the unix timestamp (php's time() function uses this)
https://www.googleapis.com/fitness/v1/users/me/dataSources/derived:com.google.step_count.delta:com.google.android.gms:estimated_steps/datasets/1470475368-1471080168
This is the response I get:
{
"minStartTimeNs": "1470475368",
"maxEndTimeNs": "1471080168",
"dataSourceId":
"derived:com.google.step_count.delta:com.google.android.gms:estimated_steps
}
However if you append your start and finish times with nine 0's that you put in your GET requests and shape your request like this:
https://www.googleapis.com/fitness/v1/users/me/dataSources/derived:com.google.step_count.delta:com.google.android.gms:estimated_steps/datasets/1470475368000000000-1471080168000000000
It worked - this is the response I got:
{
"minStartTimeNs": "1470475368000000000",
"maxEndTimeNs": "1471080168000000000",
"dataSourceId":
"derived:com.google.step_count.delta:com.google.android.gms:estimated_steps",
"point": [
{
"modifiedTimeMillis": "1470804762704",
"startTimeNanos": "1470801347560000000",
"endTimeNanos": "1470801347567000000",
"value": [
{
"intVal": -3
}
],
"dataTypeName": "com.google.step_count.delta",
"originDataSourceId": "raw:com.google.step_count.delta:com.dsi.ant.plugins.antplus:AntPlus.0.124"
},
The response is a lot longer but I truncated it for the sake of this post. So when passing your datasets parameter into the request:
1470475368-1471080168 will not work, but 1470475368000000000-1471080168000000000 will.
This did the trick for me, hopes it helps someone!
I tried post method with below URL & body. This will work, please check inline comments too.
Use URL: https://www.googleapis.com/fitness/v1/users/me/dataset:aggregate
Method: POST
Body:
{
"aggregateBy": [{
"dataTypeName": "com.google.step_count.delta",
"dataSourceId": "derived:com.google.step_count.delta:com.google.android.gms:estimated_steps"
}],
"bucketByTime": { "durationMillis": 86400000 }, // This is 24 hours
"startTimeMillis": 1504137600000, //start time
"endTimeMillis": 1504310400000 // End Time
}

YouTube Data API - Number of Results - Maven

I am trying to get videos from youtube in two different ways
a) First using youtube-google-api client library following the guidelines and sample code from here https://developers.google.com/youtube/v3/code_samples/java#search_by_keyword
Nevertheless, since I am implementing in a mavenized project Ihave difficulty in finding the dependency for 'com.google.api.services.samples.youtube.cmdline.Auth" which is required for the following block of code:
try {
youtube = new YouTube.Builder(Auth.HTTP_TRANSPORT, Auth.JSON_FACTORY, new HttpRequestInitializer() {
public void initialize(HttpRequest request) throws IOException {
}
}).setApplicationName("youtube-cmdline-search-sample").build();
b)Second I simply send a GET request to YouTube like this:
https://www.googleapis.com/youtube/v3/search?part=snippet&q=madonna&type=video&key={API_KEY}
but I am able to receive only 5 results, although I've read in several Stackoverflow related questions that I can receive up to 50 videos.This is not feasible even if I set the "max-results" parameter.
Could anyone help me to deal with these issues? Thank you in advance.
In your second way Write maxResults=50 as a parameter instead of max-results=50.
Use YouTube Data Api v3 api explorer to understand parameters very well.
https://developers.google.com/apis-explorer/#s/youtube/v3/
https://www.googleapis.com/youtube/v3/search?part=snippet&q=madonna&maxResults=50&type=video&key={API_KEY}

Bing translator HTTP API throws bad request error, how to solve this?

Whenever I call Bing Translation API [HTTP] to translate some text, first time it works fine, and second time onwards it gives me 'bad request' [status code 400] error. If I wait for 10 or so minutes and then try again, then first request is successful, but second one onwards same story. I have a free account [2million chars translation] with Bing Translation APIs, are there any other limitations calling this API?
Thanks, Madhu
Answer:
hi, i missed to subscribing to Microsoft Translator DATA set subscription. Once i get the same, then things have solved. i.e; once i have signed up for https://datamarket.azure.com/dataset/bing/microsofttranslator then things are working.
i was generating the access_token correctly, so that is not an issue.
thanks, madhu
i missed to subscribing to Microsoft Translator DATA set subscription. Once i get the same, then things have solved. i.e; once i have signed up for https://datamarket.azure.com/dataset/bing/microsofttranslator then things are working.
i was
thanks, madhu
As a note to anyone else having problems, I figured out that the service only allows the token to be used once when using the free subscription. You have to have a paid subscription to call the Translate service more than once with each token. This limitation is, of course, undocumented.
I don't know if you can simply keep getting new tokens -- I suspect not.
And regardless of subscription, the tokens do expire every 10 minutes, so ensure you track when you receive a token and get a new one if needed, e.g. (not thread-safe):
private string _headerValue;
private DateTime _headerValueCreated = DateTime.MinValue;
public string headerValue {
get {
if(_headerValueCreated < DateTime.Now.AddMinutes(-9)) {
var admAuth = new AdmAuthentication("myclientid", "mysecret");
_headerValue = "Bearer " + admAuth.GetAccessToken();
_headerValueCreated = DateTime.Now;
}
return _headerValue;
}
}

Resources