GRPC create channel link for Google Assistant API - c++

I'm trying to write a C++ code to create Google Assistant on UDOO x86 board (See https://developers.google.com/assistant/sdk/).
I have tried to follow all the steps regarding in the tutorial, but I'm not sure what URL I should have when I call the creatChannel method?
I do have the credentials JSON downloaded and using it through the "GOOGLE_APPLICATION_CREDENTIALS" environment variable
Object creation:
GAssistantClient greeter(grpc::CreateChannel(
"google.com", grpc::GoogleDefaultCredentials()));
Contructor:
GAssistantClient(std::shared_ptr<Channel> channel)
: stub_(Greeter::NewStub(channel)) {}
When I put google.com in there, I get the following error:
E0505 18:30:34.959710444 7635 ssl_transport_security.c:1226] Invalid toplevel subdomain: com
E0505 18:30:34.959836517 7635 ssl_transport_security.c:1226] Invalid toplevel subdomain: com

You have to authenticate using your credentials and then create a channel, after that you have send audio config request about your audio and then send an audio data request which contains your audio captured etc.
You can use ALSA sound API library to capture and playback audio.
and then send and receive in api requests and responses.
You should follow the following order in this doc

The Service name for the Google Assistant API is embeddedassistant.googleapis.com. So your object creation call would look like:
GAssistantClient greeter(grpc::CreateChannel(
"embeddedassistant.googleapis.com", grpc::GoogleDefaultCredentials()));

Related

Video streaming in react-native using custom API

I'm working on a react-native app using expo-av to show videos, and whne I put in source the uri: 'http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ElephantsDream.mp4', from google samples, it acutally works, but if I try to put a uri for a video contained in my django media folder, the following error occur:
The server is not correctly configured. - The AVPlayerItem instance has failed with the error code -11850 and domain "AVFoundationErrorDomain".
How can I solve?
Thank you

How to use AWS WebRTC signed url in the frontend?

The aws repo https://github.com/awslabs/amazon-kinesis-video-streams-webrtc-sdk-js provides the backend code to generate a presigned url.
I was able to log it and it looks like this (modified by adding/removing some characters to avoid misuse):
wss://v-7bd53a347.kinesisvideo.ap-south-1.amazonaws.com/?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-ChannelARN=arn%3Aaws%3Akinesisvideo%3Aap-south-1%3A3514502525359%3Achannel%2Fwebcam-signalling-channel-4%2F1637856477339&X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EaMAbg94eSnHpFLmPWYJwHj61eBU4JzIUsmzhxLF5x4MADUjxf1yOTRyx3FhIiO51gutW1fbgTt7z9lPn9szDXi76NBjqFAiE7AMy1zOl4hnXhjO60JRiKgHL0YuKsHJPAV02UmAdgf7lY%2Bl14ABncq4q1HSv%2BRKA2rr1ZM9JfgjMGHD0Xw9a8qFjN0RX5N%2FMw0F5nvVV9oGC8lYmT%2BLwW7DfyinSIA30SMzfXVfIEcGhEil900hoZMQZyvOWM4q7F%2Bye%2FN4%2FzS1RqMNHQGIT%2FdgOZkSJwyho6cpH1kEZXZMfhlWjOnTBjcqQzGYd9g9GLocDq8ZivrAKCtEM6yR%2Bh%2FsLhtGinqpsVFM%2BhaxK9G929tvlIQ3ZxA4GRAuTBepucoeVhmOwWv0f%2Fk82xjET%2FD5zVYvtMEpoU76aPal7pYNis98DspPB9ugrAw%3D%3D&X-Amz-Signature=8303b836351e231e9e7850cdd565a21073eaa4cb699b06d50c9e7f7e15a933e&X-Amz-SignedHeaders=host
I am not able to understand how to use it in the frontend to view the video stream.
I have come across other comments seeking examples but there are no responses:
How to use Kinesis Video Stream WebRTC SDK in the browser without providing credentials?
Has anyone been able to use it?
In case you are still looking for an answer, the signed url can be used while creating a signalling client in the front end code and can be used for connecting with AWS WebRTC Signalling service. You may find an example at below
https://blog.learningdollars.com/2021/05/09/aws-kinesis-video-stream-with-signed-url/
I implemented the above but was unable to see request from one front-end module to the other front-end module using AWS Kinesis WebRTC.

Playing an mp3 created by AWS api gateway in an Alexa skill

I have an AWS lambda function that is called by AWS api gateway. The function takes URLs from multiple mp3 files hosted on AWS S3 and concatenates them into a single mp3 file. When I call the api from a browser all is good (the browser opens a media player and the combined audio mp3 is played).
The URL request looks like this:
https://0xxxxxxxx.execute-api.eu-west-1.amazonaws.com/alpha/files?file=https://xxx.s3-eu-west-1.amazonaws.com/file1.mp3&file=https://xxx.s3-eu-west-1.amazonaws.com/file2.mp3&file=https://xxx.s3-eu-west-1.amazonaws.com/file3.mp3
the HTTP response is of type audio/mpeg, about 10 seconds long, and is base64 encoded.
I've tried to wrap this into SSML in my skill and it fails. From the Alexa skills kit voice and tone simulator, I get the error message "error retrieving text to speech; the input was incompatible"
In the simulator, this is what I wrote:
<speak>
<audio src='https://0xxxxxxxx.execute-api.eu-west-1.amazonaws.com/alpha/files?file=https://xxx.s3-eu-west-1.amazonaws.com/file1.mp3&file=https://xxx.s3-eu-west-1.amazonaws.com/file2.mp3&file=https://xxx.s3-eu-west-1.amazonaws.com/file3.mp3'/>
</speak>
and I used this to confirm that S3 access works in the simulator:
<speak>
<audio src='https://s3.amazonaws.com/ask-soundlibrary/human/amzn_sfx_crowd_applause_05.mp3'/>
</speak>
Any ideas what is wrong? Is the issue with the http response from my lambda skill, or does something need to be enabled in api gateway? From my api gateway logs, it seems that the skill never tries to access the gateway.
Should I be using a different approach to fetch the mp3 for playback? Note, i want to use SSML as my audio is an effect and therefore shouldn't use the audioplayer (This is an Amazon requirement).
I might help you with this. The same problem happened to me. And after researching I resolved it. The problem here is "&" in you link which you provide in SSML. The solution you provided worked because there is no "&" now in your link. Too many parameters is not the problem.
I will suggest you to replace "&" with "&"
In python -
url = 'https://0xxxxxxxx.execute-api.eu-west-1.amazonaws.com/alpha/files?file=https://xxx.s3-eu-west-1.amazonaws.com/file1.mp3&file=https://xxx.s3-eu-west-1.amazonaws.com/file2.mp3&file=https://xxx.s3-eu-west-1.amazonaws.com/file3.mp3'
url = url.replace("&","&")
<speak>
"<audio src='" + url + "'/>"
</speak>
I hope this helps you. Please let me know if doesn't work.
Ok, I've worked it out myself.
It seems that SSML audio src doesn't like too many parameters in the URL call. I now just pass 1 parameter in the URL and use my lambda function to strip out the multiple filenames frome that single parameter.
https://0xxxxxxxx.execute-api.eu-west-1.amazonaws.com/alpha/files?file=/file1.mp3file=file2.mp3file=file3.mp3

Microsoft Cognitive-Speaker Recognition - Verification profile - Create Enrollment

I am trying to make a call in Postman for the Microsoft Cognitive Service - Create Enrollment for Verification profile.
This is what I am using: https://westus.dev.cognitive.microsoft.com/docs/services/563309b6778daf02acc0a508/operations/5645c3271984551c84ec6797
I have an API URL created: https://internspeaker.cognitiveservices.azure.com/spid/v1.0 And the Subscription-Key.
I started by using their testing console and all of them worked perfectly until the enrollment process where I have to add an audio file in a specific format (.WAV with different characteristics). The Microsoft console asked me for binary data for the audio file and I could not get the audio file converted. So I found another way of testing by using Postman.
I took all other processes and they worked perfectly until I tried Create Enrollment for the Verification Profile. Here I added all the details + the audio file but I could not pass the error(the error is shown in the next link)
This is the error I am getting:
This is how I added the audio file in Postman:
This is a successful call with the same URL and subscription-Key:
Does anyone know how to deal with this problem?
Thank you very much
Your url is not in right format.
Your url should be https://internspeaker.cognitiveservices.azure.com/spid/v1.0/identificationProfiles/{your identificationProfileId}/enroll. You could find the success url format is correct.
And your way to add audio is fine.
Update:
if want to use verification profile to create enrollment, the url should be:https://internspeaker.cognitiveservices.azure.com/spid/v1.0/verificationProfiles/{your verificationProfileId}/enroll.

RESTful webservice API : how to handle a web URI route for a 100 music files

I am a totally newbie to the world of REST API. from what I have read and I think I understand 2 main things .
1) REST uses the the same HTTP methods (GET PUT etc) for a specific resource on the server.
2) Every resource on my server must be accessible from a unique URI.
So Combining 1 and 2, I can send a HTTP request to send a resource URI (eg. Radio.com/Music/1 and a GET request which will then fetch Music song 1).
Now I have a simple HTML page which has links to 100 Music files on the server. The idea is that the client will click on a link and then Should be able to play/download the music file (I am not so concerned about the how part related to audio). So the server must provide the links to each Music file eg: Radio.com/Music/1 .
My Question:
Q1) In this way must the should the client be exposed to each and every URI for the resource. So When the hosting the html page should i put these links individually for each music file link
Q2) We need to have a route to each and every resource for the 100 music files on the server . If I am doing in Sinatra like do I need a do route for every of the 100 music files ?
Something link '/do' /Music/1 , '/do' /Music/2 and so on
(Isn't this cumbersome and if I add another 100 music files , then I need to add another 100 routes in Sinatra).
Is this how the REST API would work, or have I totally got it wrong?
Imagine you have two servers.
First server is your api server: http://api.yourhost.com/v1/... (java, node.js, etc...)
This REST-server will return a simple json response:
{
"base_url" : "http://static.yourhost.com/music/",
"tracks" : [
{
"name" : "track1",
"file_name" : "track1.mp3"
"file_size" : "3.43MB"
},
{
"name" : "track2",
"file_name" : "track2.mp3"
"file_size" : "6.12MB"
}
[...]
]
}
The second server: http://static.yourhost.com/ is your content delivery server (apache, nginx, etc...)
The idea is, that your api REST server should never send binary data like audio or image. It sends json/xml only.
You can also send the full url for every audio file, but this information could be redundant.
ad 1)
When the hosting the html page should i put these links individually for each music file link
If you take REST seriously and if you see this HTML page as a representation of the collection resource of all music files, you should do this. One basic mechanism of REST is links for the client. The client should be able to just follow links without having to build them himself.
ad 2)
We need to have a route to each and every resource for the 100 music files on the server.
Every library that implements a RESTful server is able to have routes with path paramters. Usually such a route is defined using a pattern like
/Music/{id}
where {id} is the path parameter. The code that is bound to this route will then have available a variable named id. Using this approach you need only one route.