Skip to content

Commit e0d4e0b

Browse files
committed
formatting
1 parent 39ca1c6 commit e0d4e0b

12 files changed

+32
-73
lines changed

Xamarin.Cognitive.BingSpeech/AuthenticationClient.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ class AuthenticationClient
1616

1717
internal string Token { get; private set; }
1818

19-
2019
/// <summary>
2120
/// Initializes a new instance of the <see cref="T:Xamarin.Cognitive.BingSpeech.AuthenticationClient"/> class.
2221
/// </summary>
@@ -31,7 +30,6 @@ public AuthenticationClient (Endpoint authEndpoint, string subscriptionKey)
3130
client.DefaultRequestHeaders.Add (Constants.Keys.SubscriptionKey, subscriptionKey);
3231
}
3332

34-
3533
/// <summary>
3634
/// Calls to the authentication endpoint to get a JWT token that is cached.
3735
/// </summary>
@@ -45,13 +43,11 @@ public async Task Authenticate (bool forceNewToken = false)
4543
}
4644
}
4745

48-
4946
public void ClearToken ()
5047
{
5148
Token = null;
5249
}
5350

54-
5551
async Task<string> FetchToken ()
5652
{
5753
try

Xamarin.Cognitive.BingSpeech/BingSpeechApiClient.cs

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ public class BingSpeechApiClient
1717
const int ChunkSize = 1024;
1818
const int DefaultChannelCount = 1;
1919
const int DefaultBitsPerSample = 16;
20+
2021
readonly string subscriptionKey;
2122
readonly HttpClient client;
2223

@@ -28,7 +29,6 @@ public class BingSpeechApiClient
2829
/// <value>The auth client.</value>
2930
AuthenticationClient AuthClient { get; set; }
3031

31-
3232
/// <summary>
3333
/// Gets or sets the endpoint used to get the authentication token for the Speech API.
3434
/// </summary>
@@ -38,21 +38,18 @@ public class BingSpeechApiClient
3838
/// </remarks>
3939
public Endpoint AuthEndpoint { get; set; } = Endpoints.Authentication;
4040

41-
4241
/// <summary>
4342
/// Gets and sets the <see cref="AuthenticationMode"/> used by the the speech client.
4443
/// </summary>
4544
public AuthenticationMode AuthenticationMode { get; set; }
4645

47-
4846
/// <summary>
4947
/// Gets or sets the endpoint used to talk to the Speech API.
5048
/// </summary>
5149
/// <value>The endpoint.</value>
5250
/// <remarks>Defaults to <see cref="Endpoints.BingSpeechApi"/>. To use a CRIS/Custom Speech Service endpoint, set this to a new <see cref="Endpoint"/> with the details for your CRIS service.</remarks>
5351
public Endpoint SpeechEndpoint { get; set; } = Endpoints.BingSpeechApi;
5452

55-
5653
/// <summary>
5754
/// Gets or sets the Recognition language.
5855
/// </summary>
@@ -62,7 +59,6 @@ public class BingSpeechApiClient
6259
/// </remarks>
6360
public string RecognitionLanguage { get; set; } = "en-US";
6461

65-
6662
/// <summary>
6763
/// Gets or sets the recognition mode.
6864
/// </summary>
@@ -75,7 +71,6 @@ public class BingSpeechApiClient
7571
/// </remarks>
7672
public RecognitionMode RecognitionMode { get; set; }
7773

78-
7974
/// <summary>
8075
/// Gets or sets the profanity mode.
8176
/// </summary>
@@ -86,14 +81,12 @@ public class BingSpeechApiClient
8681
/// </remarks>
8782
public ProfanityMode ProfanityMode { get; set; }
8883

89-
9084
/// <summary>
9185
/// Gets or sets the API version.
9286
/// </summary>
9387
/// <value>The API version. Defaults to "v1"</value>
9488
public string ApiVersion { get; set; } = "v1";
9589

96-
9790
/// <summary>
9891
/// Initializes a new instance of the <see cref="T:Xamarin.Cognitive.BingSpeech.BingSpeechApiClient"/> class.
9992
/// </summary>
@@ -106,7 +99,6 @@ public BingSpeechApiClient (string subscriptionKey)
10699
AuthClient = new AuthenticationClient (AuthEndpoint, subscriptionKey);
107100
}
108101

109-
110102
/// <summary>
111103
/// Calls to the <see cref="AuthEndpoint"/> authentication endpoint to get a JWT token for authentication to the Bing Speech API. Token is cached and valid for 10 minutes.
112104
/// </summary>
@@ -117,7 +109,6 @@ public async Task AuthenticateWithToken (bool forceNewToken = false)
117109
await AuthClient.Authenticate (forceNewToken);
118110
}
119111

120-
121112
/// <summary>
122113
/// Clears any cached auth token.
123114
/// </summary>
@@ -126,7 +117,6 @@ public void ClearAuthToken ()
126117
AuthClient.ClearToken ();
127118
}
128119

129-
130120
HttpRequestMessage CreateRequest (OutputMode outputMode)
131121
{
132122
try
@@ -170,7 +160,6 @@ HttpRequestMessage CreateRequest (OutputMode outputMode)
170160
}
171161
}
172162

173-
174163
async Task<string> SendRequest (Func<HttpRequestMessage> requestFactory, Func<HttpContent> contentFactory)
175164
{
176165
try
@@ -219,7 +208,6 @@ async Task<string> SendRequest (Func<HttpRequestMessage> requestFactory, Func<Ht
219208
throw new Exception ("SendRequest: Unable to send successful request - unknown error or null response received");
220209
}
221210

222-
223211
HttpContent CopyRequestContent (HttpContent content)
224212
{
225213
return new PushStreamContent (async (outputStream, httpContext, transportContext) =>
@@ -257,7 +245,6 @@ HttpContent CopyRequestContent (HttpContent content)
257245
}, new MediaTypeHeaderValue (Constants.MimeTypes.WavAudio));
258246
}
259247

260-
261248
HttpContent PopulateRequestContent (string audioFilePath)
262249
{
263250
return new PushStreamContent (async (outputStream, httpContext, transportContext) =>
@@ -289,7 +276,6 @@ HttpContent PopulateRequestContent (string audioFilePath)
289276
}, new MediaTypeHeaderValue (Constants.MimeTypes.WavAudio));
290277
}
291278

292-
293279
HttpContent PopulateRequestContent (Stream audioStream, int? channelCount = null, int? sampleRate = null, int? bitsPerSample = null, Task recordingTask = null, int streamReadDelay = 30)
294280
{
295281
const int audioDataWaitInterval = 100; //ms
@@ -366,7 +352,6 @@ HttpContent PopulateRequestContent (Stream audioStream, int? channelCount = null
366352
}, new MediaTypeHeaderValue (Constants.MimeTypes.WavAudio));
367353
}
368354

369-
370355
/// <summary>
371356
/// Returns Speech to Text results for the given audio input. Begins sending the audio stream to the server immediately.
372357
/// </summary>
@@ -407,7 +392,6 @@ public async Task<RecognitionSpeechResult> SpeechToTextSimple (string audioFileP
407392
}
408393
}
409394

410-
411395
/// <summary>
412396
/// Returns Speech to Text results for the given audio input. Assumes the audio stream already contains a WAV file/RIFF header and WILL NOT write one.
413397
/// </summary>
@@ -422,7 +406,6 @@ public Task<RecognitionSpeechResult> SpeechToTextSimple (Stream audioStream, Tas
422406
return SpeechToTextSimple (audioStream, null, null, null, recordingTask);
423407
}
424408

425-
426409
/// <summary>
427410
/// Returns Speech to Text results for the given audio input. Assumes single channel (mono) audio at 16 bits per sample and will write a WAV/RIFF header to the output stream accordingly.
428411
/// </summary>
@@ -438,7 +421,6 @@ public Task<RecognitionSpeechResult> SpeechToTextSimple (Stream audioStream, int
438421
return SpeechToTextSimple (audioStream, sampleRate, DefaultChannelCount, DefaultBitsPerSample, recordingTask: recordingTask);
439422
}
440423

441-
442424
/// <summary>
443425
/// Returns Speech to Text results for the given audio input. Will write a WAV/RIFF header to the output stream with the audio details provided.
444426
/// If ANY audio details are passed in with a null value, a RIFF header will not be written.
@@ -479,7 +461,6 @@ public async Task<RecognitionSpeechResult> SpeechToTextSimple (Stream audioStrea
479461
}
480462
}
481463

482-
483464
/// <summary>
484465
/// Returns Speech to Text results for the given audio input.
485466
/// </summary>
@@ -515,7 +496,6 @@ public async Task<RecognitionResult> SpeechToTextDetailed (string audioFilePath)
515496
}
516497
}
517498

518-
519499
/// <summary>
520500
/// Returns Speech to Text results for the given audio input. Assumes the audio stream already contains a WAV file/RIFF header and WILL NOT write one.
521501
/// </summary>
@@ -530,7 +510,6 @@ public Task<RecognitionResult> SpeechToTextDetailed (Stream audioStream, Task re
530510
return SpeechToTextDetailed (audioStream, null, null, null, recordingTask);
531511
}
532512

533-
534513
/// <summary>
535514
/// Returns Speech to Text results for the given audio input. Assumes single channel (mono) audio at 16 bits per sample and will write a WAV/RIFF header to the output stream accordingly.
536515
/// </summary>
@@ -546,7 +525,6 @@ public Task<RecognitionResult> SpeechToTextDetailed (Stream audioStream, int sam
546525
return SpeechToTextDetailed (audioStream, sampleRate, DefaultChannelCount, DefaultBitsPerSample, recordingTask);
547526
}
548527

549-
550528
/// <summary>
551529
/// Returns Speech to Text results for the given audio input. Will write a WAV/RIFF header to the output stream with the audio details provided.
552530
/// If ANY audio details are passed in with a null value, a RIFF header will not be written.

Xamarin.Cognitive.BingSpeech/Extensions.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ public static void WriteWaveHeader (this Stream stream, int channelCount, int sa
6262
}
6363
}
6464

65-
6665
/// <summary>
6766
/// Checks if the Exception is a <see cref="WebException"/> and if so, evaluates if the StatusCode is equal to the given status code.
6867
/// </summary>

Xamarin.Cognitive.BingSpeech/Model/Endpoint.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,21 @@ public class Endpoint
1010
/// </summary>
1111
public string Protocol { get; private set; } = "https";
1212

13-
1413
/// <summary>
1514
/// Gets the host.
1615
/// </summary>
1716
public string Host { get; private set; }
1817

19-
2018
/// <summary>
2119
/// Gets the port.
2220
/// </summary>
2321
public int Port { get; private set; } = 443;
2422

25-
2623
/// <summary>
2724
/// Gets the path.
2825
/// </summary>
2926
public string Path { get; private set; }
3027

31-
3228
/// <summary>
3329
/// Initializes a new instance of the <see cref="T:Xamarin.Cognitive.BingSpeech.Endpoint"/> class.
3430
/// </summary>
@@ -44,7 +40,6 @@ public Endpoint (string protocol, string host, int port, string path)
4440
Path = path;
4541
}
4642

47-
4843
/// <summary>
4944
/// Initializes a new instance of the <see cref="T:Xamarin.Cognitive.BingSpeech.Endpoint"/> class.
5045
/// Assumes Https protocol.
@@ -59,7 +54,6 @@ public Endpoint (string host, int port, string path)
5954
Path = path;
6055
}
6156

62-
6357
/// <summary>
6458
/// Initializes a new instance of the <see cref="T:Xamarin.Cognitive.BingSpeech.Endpoint"/> class.
6559
/// Assumes Https protocol and port 443.

Xamarin.Cognitive.BingSpeech/Model/OutputMode.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace Xamarin.Cognitive.BingSpeech
1+
namespace Xamarin.Cognitive.BingSpeech
22
{
33
/// <summary>
44
/// Output mode.

Xamarin.Cognitive.BingSpeech/Model/ProfanityMode.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace Xamarin.Cognitive.BingSpeech
1+
namespace Xamarin.Cognitive.BingSpeech
22
{
33
/// <summary>
44
/// ProfanityMode defines the possible modes in which the service can handle profanity.

Xamarin.Cognitive.BingSpeech/Model/RecognitionMode.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace Xamarin.Cognitive.BingSpeech
1+
namespace Xamarin.Cognitive.BingSpeech
22
{
33
/// <summary>
44
/// Recognition mode.

Xamarin.Cognitive.BingSpeech/Model/RecognitionResult.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System.Collections.Generic;
1+
using System.Collections.Generic;
22
using Newtonsoft.Json;
33

44
namespace Xamarin.Cognitive.BingSpeech
@@ -13,21 +13,18 @@ public class RecognitionResult
1313
/// </summary>
1414
public RecognitionStatus RecognitionStatus { get; set; }
1515

16-
1716
/// <summary>
1817
/// Gets or sets the offset.
1918
/// The Offset element specifies the offset (in 100-nanosecond units) at which the phrase was recognized, relative to the start of the audio stream.
2019
/// </summary>
2120
public long Offset { get; set; }
2221

23-
2422
/// <summary>
2523
/// The duration of speech.
2624
/// The Duration element specifies the duration (in 100-nanosecond units) of this speech phrase.
2725
/// </summary>
2826
public long Duration { get; set; }
2927

30-
3128
/// <summary>
3229
/// A list of <see cref="SpeechResult"/> containing the N-best results (top result + any alternatives), ordered by their confidence.
3330
/// </summary>

Xamarin.Cognitive.BingSpeech/Model/RecognitionSpeechResult.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace Xamarin.Cognitive.BingSpeech
1+
namespace Xamarin.Cognitive.BingSpeech
22
{
33
/// <summary>
44
/// A single speech result combining Recogniton result with Speech result. This is used for Simple result mode.
@@ -16,14 +16,12 @@ public class RecognitionSpeechResult
1616
/// </summary>
1717
public long Offset { get; set; }
1818

19-
2019
/// <summary>
2120
/// The duration of speech.
2221
/// The Duration element specifies the duration (in 100-nanosecond units) of this speech phrase.
2322
/// </summary>
2423
public long Duration { get; set; }
2524

26-
2725
/// <summary>
2826
/// The top result (by confidence), returned in Display Form.
2927
/// </summary>

0 commit comments

Comments
 (0)