Comments (1)
I've figured out how to solve this. You shold add this method to your code:
public async Task<Enrollment> EnrollAsyncRedone( Stream audioStream, Guid id ) {
try {
// Initialization and preparation stuff
string _BASE_URI = "https://api.projectoxford.ai/spid/v1.0/verificationProfiles";
string _JSON_HEADER = "application/json";
string _OCP_SUBSCRIPTION_KEY_HEADER = "Ocp-Apim-Subscription-Key";
HttpClient _DefaultHttpClient = new HttpClient();
_DefaultHttpClient.DefaultRequestHeaders.Accept.Add( new MediaTypeWithQualityHeaderValue( _JSON_HEADER ) );
// Don't forget to change "yourAPIkeyString" to your actual API key!
_DefaultHttpClient.DefaultRequestHeaders.Add( _OCP_SUBSCRIPTION_KEY_HEADER, yourAPIkeyString );
// This line caused the exception:
//var content = new MultipartFormDataContent( "Upload----" + DateTime.Now.ToString( "u" ) );
// Now it is changed to this (no arguments in braces => correct boundaries generation)
var content = new MultipartFormDataContent( );
content.Add( new StreamContent( audioStream ), "enrollmentData", id.ToString( "D" ) + "_" + DateTime.Now.ToString( "u" ) );
var requestUrl = _BASE_URI + "/" + id.ToString( "D" ) + "/enroll";
var result = await _DefaultHttpClient.PostAsync( requestUrl, content ).ConfigureAwait( false );
string resultStr = await result.Content.ReadAsStringAsync().ConfigureAwait( false );
if (result.StatusCode == HttpStatusCode.OK) {
//parse response
Enrollment response = JsonConvert.DeserializeObject<Enrollment>( resultStr );
return response;
} else {
throw new EnrollmentException( resultStr );
}
} catch (TaskCanceledException exception) {
throw new TimeoutException( "Connection timed out: " + exception.Message );
}
}
And then you should call EnrollAsyncRedone(stream, profile); instead of client.EnrollAsync(stream, profile); - so the error will disappear. I've got EnrollAsync's source code from here: https://github.com/Microsoft/ProjectOxford-ClientSDK/blob/master/SpeakerRecognition/Windows/ClientLibrary/SpeakerVerificationServiceClient.cs
from projectoxford-clientsdk.
Related Issues (20)
- Invalid subscription Key HOT 2
- Target host must not be null or set in parameters in create group HOT 1
- EmotionServiceClient does not return scores HOT 2
- a error "Image is too small" occurs when detect face HOT 8
- How to parse Linguistis Analysis Token Output
- This repo is missing important files HOT 2
- change link to new repo HOT 1
- Exception in emotion detection HOT 1
- Moved why Project HOT 2
- Including .wav file in Identification Profile Enrollment request via Ruby HOT 2
- Transport error SpeechClentStatus_LoginFaild HOT 2
- " API call threw an Exception" HOT 1
- "message": "Invalid Audio Format: Not a WAVE file - no RIFF header" HOT 2
- IEmotionServiceClient should be public
- [Error executing POST request error 401] please give solution for this im using project oxford api
- Speaker Recognition API returns bad request with no further message HOT 1
- Error Executing Post request! Received Error code:400
- API Call counting
- Get Project Oxford Key HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from projectoxford-clientsdk.