How to request synthesis with a positive volume gain? - google-text-to-speech

The API for Google Cloud Text-to-speech provide an option to add/remove volume gain when requesting synthesis.
Link: Documentation
The field that enable that option is volume_gain_db
I'm using the RPC APIv1 (Google Text-to-Speech) on a project using the Go library.
The code is running from an instance inside Google Cloud virtual machine instance.
The API (Google Text-to-Speech) access is enabled and granted for that virtual machine.
Here is an example of a request:
import texttospeechpb "google.golang.org/genproto/googleapis/cloud/texttospeech/v1"
// Setting up the client..
req := texttospeechpb.SynthesizeSpeechRequest{
Input: &texttospeechpb.SynthesisInput{
InputSource: &texttospeechpb.SynthesisInput_Ssml{Ssml: "Hello this is a test"},
},
Voice: &texttospeechpb.VoiceSelectionParams{
LanguageCode: "en",
SsmlGender: texttospeechpb.SsmlVoiceGender_MALE,
},
AudioConfig: &texttospeechpb.AudioConfig{
AudioEncoding: texttospeechpb.AudioEncoding_OGG_OPUS,
VolumeGainDb: 6,
},
}
// Making the request..
The current problem is that setting a positive gain ex: [0, 1, 6, 16]db, throws the following error:
Unable to get speech rpc error:
code = InvalidArgument
desc = Request contains an invalid argument.
Testing with negative value ex: [-6, -0.1, 0]db is working.
Testing with invalid positive/negative value ex: 20db/-100db is not working as expected.
Unable to get speech rpc error:
code = OutOfRange
desc = Out of range: valid volume_gain_db is between -96.0 and 16.0.
I would like to know if there is an option I need to enable somewhere in order to have positive volume gain for the synthesis or if it is a bug on the API?

Related

Attempting a Google Drive partial Download (Flutter) throws a header error

Here's my issue :
I am creating a small application based on audio files stored on Google Drive, in Flutter.
I am using the drive api to make my requests, with these scopes in my google sign in :
GoogleSignIn _googleSignIn = GoogleSignIn(
scopes: [
'email',
'https://www.googleapis.com/auth/userinfo.profile',
'https://www.googleapis.com/auth/contacts.readonly',
'https://www.googleapis.com/auth/drive',
'https://www.googleapis.com/auth/docs',
'https://www.googleapis.com/auth/drive.appdata',
],
);
I have an auth element and handle signing in and out. Until then, no issues.
I can also request my files with an implementation looking like this :
var api = widget.api.getAPI();
var files = await api.files.list($fields: '*');
This works perfectly, and so does :
var api = widget.api.getAPI();
var files = await api.files.get("myFileId"); (//does get a file instance)
But since I'd like to retrieve some of the Metadata included in my audio files, and since the drive API doesn't natively support extracting audio metadata and sending it as a google metadata, I thought I'd extract it with a partial download on the file itself.
Here's the catch : I can't seem to get the partial download to work.
Based on the doc, I thought the implementation would look something like this :
import 'package:googleapis/drive/v3.dart' as ga;
(...)
try {
var partiallyDownloadedFile = await api.files.get(
"myFileIdHere",
downloadOptions: ga.PartialDownloadOptions(ga.ByteRange(0, 10))); //should get a ga.Media instance
print("partial download succeeded");
print(partiallyDownloadedFile);
//(...do stuff...)
return;
} catch (err) {
print('Error occured : ');
print(err);
return;
}
But this always throws this error :
ApiRequestError(message: Attempting partial download but got invalid
'Content-Range' header (was: null, expected: bytes 0-10/).)
I tried using it on Wav files, but also MP4 files. The error is always the same, which leads me to believe it's my implementation that's somehow wrong, but I'm not sure what I'm supposed to do to fix it. Is it my request missing the header ? The response not including it ?
While very clear, that error doesn't help me troubleshoot my issue at all. I can't seem to find any documentation on how to conduct a partial media request. I haven't found any example projects to compare it with.
PartialDownloadOptions does not have much documentation.
I could handmake a partial request through the download links (which is how I can read the music to begin with) but the drive API supposedly allows this. Could anyone familiar with Flutter/the google APIs help me correct my implementation?
EDIT : This was due to an error within the commons library in the Dart google APIs, and was (at the very least superficially) fixed thanks to Kevmoo's efforts : https://github.com/google/googleapis.dart/issues/462
It was a Content-Range error happening due to browser specifications with access-control-expose-header compared to iOS/Android-type requests that typically expose every header.

Getting response from API - DialogFlow Chatbot

I am creating a chatbot using DialogFlow. Here, I am trying to get response from the API, which has been created by my development team (using python). They provided the API URL and requested to fetch data from it according to the users query. I have created a function in the inline editor and pasted the given API URL.
Below is the API format they have created,
{
“data”: [{
“pincode”: “”,
“location_formatted_address”: “”,
“user_id”: “”,
“department_name”: “Education”,
“locality”: “”,
“status”: “Select_Status”
}]
}
Here, when a user gives a department name, it must respond the user with locality of that specific department.
In the Inline editor, I have applied the following logic to fetch the locality,
function getDatafromApI(agent){
const name = agent.parameters.name;
return getAPIData().then(res => {
res.data.map(issues => {
if(issues.department_name === name)
agent.add(`${name}. ${issues.locality}`);
intentMap.set('Fetch API', APIData);
In the above code, "name" is the parameter given in the intent section.
But, I am not getting any response. Any help?
The inline editor uses Firebase. You will have to upgrade to Firebase "Blaze" OR "Flame" plan as the "Spark"(free) plan does not allow external api calls.
However if you have already upgraded Firebase plan and still seeing this error, you can see the execution logs by clicking "view execution logs" link at bottom of Dialogflow fulfillment window.

How to use API in actions-on-google

I have tried the following javascript code, using a railway API in aog for getting names of trains between 2 stations.
train : function(conv,src,dst) {
const options={
method:'GET',
url : `https://api.railwayapi.com/v2/between/source/${src}/dest/${dst}/date/23-09-2018/apikey/<api_key>/`,
json : true
};
var data=[];
return rp(options)
.then(function(parseBody){
for(var i=0;i<2;i++){
data.push(parseBody.trains[i].name);
}
console.log(data);
return conv.ask(data[0] + data[1]);
}).catch(err=>{
console.log("api error" + err);
});
}
When I run it in my computer using terminal(node filename.js) it shows the data[] array with correct values. But when I try to run it from actions-on-google simulator it catches an error as follows...
api errorRequestError: Error: getaddrinfo ENOTFOUND api.railwayapi.com api.railwayapi.com:443
If you are trying to do this using Firebase Cloud Functions (FCF) or the Dialogflow Built-In editor (which uses FCF under the covers), the most likely cause is that you are using the free tier of FCF which does not allow calls outside Google's network.
You can upgrade to the Blaze Plan to get around this. While this does require a credit card to be on file, it includes a free tier which is quite sufficient for some basic testing and probably even some very light usage once you're in production. Once you have your Action approved, you will be eligible to receive cloud credits from Google which can be used to offset costs associated with using Cloud Functions.

Integrate extent reports with jmeter for test reporting

I would like to uses jmeter for api functional testing, the jmeter dashboard reporting is not ideal for functional testing.
I have attempted to integrate extent 2.41.2 reporting with groovy script that validates responses (http and expected response code).
I have attempted to use the idea given in Using extentreports for jmeter test results
However that has failed. I used a js2322 assertion to check for valid responses, but then I get errors whenever attempt to run.
I'm not sure whether it should be setup as post processor step instead of an assertion.
Has anyone got any ideas on how this can be achieved?
You can assert result by using prev which is SampleResult:
prev - (SampleResult) - gives access to the previous SampleResult (if any)
Here's example of checking token exists in response and if not return relevant assertion:
import org.apache.jmeter.assertions.AssertionResult;
boolean assertToken = prev.getResponseDataAsString().contains("token");
prev.setSuccessful(assertToken);
if (!assertToken) {
AssertionResult assertionResult = new AssertionResult("Assertion expected to contain token")
assertionResult.setFailureMessage("Assertion failure message: Test failed: text expected to contain /token/");
assertionResult.setFailure(true);
prev.addAssertionResult(assertionResult);
}

Facebook error (#100) Could not resolve object at URL" when creating a user owned object

I'm trying to use the Graph api on Facebook SDK for Unity (package 6.2.2) to create an object for each user to hold data on the levels they have completed.
Using the code:
Dictionary<string, object> dataD = new Dictionary<string, object>();
dataD.Add("title", "Level Score");
Dictionary<string, object> dataS = new Dictionary<string, object>();
dataS.Add("score", score.ToString());
dataS.Add("userid", FB.UserId);
dataD.Add("data", dataS);
Dictionary<string, string> objectData = new Dictionary<string, string>();
objectData.Add("object", Json.Serialize(dataD));
FB.API("me/objects/<namespace>:<objectname>", Facebook.HttpMethod.POST, CreateObjectCallback, objectData);
About 90% of the time the code, replacing the namespace and objectname with the correct names, to create an object works, the app receives a successfull callback and the object is created. The times when it fails the error message in the log reads as:
E/Unity (19602): You are trying to load data from a www stream which had the following error when downloading.
E/Unity (19602): java.io.FileNotFoundException: https://graph.facebook.com/me/objects/<namespace>:<objectname>
E/Unity (19602):
E/Unity (19602): (Filename: Line: 253)
After getting this problem to occur fairly consistantly I attempted to see if I could get any more information by using Facebook's Graph API Explorer and maybe determine if the problem is something in my code but I get the same problem there as well at about the same rate. When it fails in the explorer I can normally send the exact same data straight after the error and it will succeed.
The error code when it decides to fail in the Graph API Explorer is:
{
"error": {
"message": "(#100) Could not resolve object at URL 836692929751565.",
"type": "OAuthException",
"code": 100
}
}
I'm assuming this message means that Facebook has failed to create the object and so is giving me the error that it can't return the object it tried to create but I have been unable to find any information online pertaining to this kind of error.
Is there something I'm missing in the data I'm sending that could cause this or in this situation should I just catch this error and retry creating the object?
From what I could find on the subject it looks like you have some missing registry items. Error 100 is a general error that could mean:
• Access Denied Error 100
• Error 100 Access Denied Windstream
• Yahoo SiteBuilder Error 100
• Error 100 Time Warner Cable
• Microsoft Silverlight Error Code 100
How to fix a numeric error, you have to first know what the numeric code means. Each numeric code will have its own solution that can be done manually or you can use a product that will fix it automatically. To find out what the error code that you are seeing means, you can either refer to your computer’s manual or you can look up the number online and see what the results are.
Some of the more common fixes for a numeric error include:
•Making certain all programs on the computer are updated.
•Making certain that the Windows operating system being used is updated.
•Uninstalling and then reinstalling your Windows operating system.
While these fixes may or may not work for your particular numeric error, they are a start.
http://www.erroranswers.com/troubleshooting/NM_100.php
I hope this helps....