Skip to content

Commit eb2978d

Browse files
authored
Merge pull request #90 from watson-developer-cloud/gh-13-abstractSpeechToText
Gh 13 abstract speech to text
2 parents 77c8e0b + 10b8810 commit eb2978d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+6750
-576
lines changed

IBM.WatsonDeveloperCloud.sln

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ Global
234234
EndGlobalSection
235235
GlobalSection(NestedProjects) = preSolution
236236
{1A587AA2-5F1B-4A6C-B084-57DC46019668} = {FF4673C9-CB33-4D4F-9116-776A792A2189}
237-
{4A6D2C37-7500-4E47-A4DA-849B25E5F24D} = {28E61676-E9FF-4DA9-99CC-5E0D16F02380}
237+
{4A6D2C37-7500-4E47-A4DA-849B25E5F24D} = {BE946662-3884-45E9-A3B1-B28F3081AD1B}
238238
{423DC6CA-8FF9-48D3-9B9D-B2D3B9DCFFD4} = {4A6D2C37-7500-4E47-A4DA-849B25E5F24D}
239239
{254924C9-64CD-4902-97C4-5F9E48DCDF7F} = {28E61676-E9FF-4DA9-99CC-5E0D16F02380}
240240
{B8A228E3-E05B-451B-8504-7BB9ED05E1B3} = {254924C9-64CD-4902-97C4-5F9E48DCDF7F}

examples/IBM.WatsonDeveloperCloud.SpeechToText.Example/SpeechToTextServiceExample.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
using IBM.WatsonDeveloperCloud.SpeechToText.v1;
1919
using IBM.WatsonDeveloperCloud.SpeechToText.v1.Model;
20+
using IBM.WatsonDeveloperCloud.SpeechToText.v1.Util;
2021
using System;
2122
using System.IO;
2223

@@ -110,7 +111,8 @@ private void Recognize()
110111
using (FileStream fs = File.OpenRead(_path))
111112
{
112113
Console.WriteLine("Calling Recognize...");
113-
var speechEvent = _speechToText.Recognize(fs);
114+
var speechEvent = _speechToText.Recognize(fs.GetMediaTypeFromFile(),
115+
fs);
114116

115117
Console.WriteLine("speechEvent received...");
116118
if (speechEvent.Results != null || speechEvent.Results.Count > 0)

src/IBM.WatsonDeveloperCloud.SpeechToText/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,12 @@ Retrieves information about a single specified model that is available for use w
6060
var results = _speechToText.GetModel("<model-name>");
6161
```
6262

63-
<!-- #### Recognize audio via websockets
63+
#### Recognize audio via websockets
6464
Sends audio and returns transcription results for recognition requests over a WebSocket connection. Requests and responses are enabled over a single TCP connection that abstracts much of the complexity of the request to offer efficient implementation, low latency, high throughput, and an asynchronous response. By default, only final results are returned for any request; to enable interim results, set the interim_results parameter to true.
6565

6666
The service imposes a data size limit of 100 MB per connection. It automatically detects the endianness of the incoming audio and, for audio that includes multiple channels, downmixes the audio to one-channel mono during transcoding.
6767
```cs
68-
``` -->
68+
```
6969

7070
#### Recognize audio via file
7171
Sends audio and returns transcription results for a sessionless recognition request. Returns only the final results.

src/IBM.WatsonDeveloperCloud.SpeechToText/v1/ISpeechToTextService.cs

Lines changed: 341 additions & 17 deletions
Large diffs are not rendered by default.
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/**
2+
* Copyright 2017 IBM Corp. All Rights Reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
*/
17+
18+
using Newtonsoft.Json;
19+
using System.Collections.Generic;
20+
21+
namespace IBM.WatsonDeveloperCloud.SpeechToText.v1.Model
22+
{
23+
public class Corpora
24+
{
25+
/// <summary>
26+
/// Gets or sets information about corpora of the custom model. The
27+
/// array is empty if the custom model has no corpora.
28+
/// </summary>
29+
[JsonProperty(PropertyName = "corpora")]
30+
public IList<Corpus> CorporaProperty { get; set; }
31+
}
32+
}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
/**
2+
* Copyright 2017 IBM Corp. All Rights Reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
*/
17+
18+
using Newtonsoft.Json;
19+
20+
namespace IBM.WatsonDeveloperCloud.SpeechToText.v1.Model
21+
{
22+
public class Corpus
23+
{
24+
/// <summary>
25+
/// Gets or sets the name of the corpus.
26+
/// </summary>
27+
[JsonProperty(PropertyName = "name")]
28+
public string Name { get; set; }
29+
30+
/// <summary>
31+
/// Gets or sets the total number of words in the corpus. The value is
32+
/// `0` while the corpus is being processed.
33+
/// </summary>
34+
[JsonProperty(PropertyName = "total_words")]
35+
public int TotalWords { get; set; }
36+
37+
/// <summary>
38+
/// Gets or sets the number of OOV words in the corpus. The value is
39+
/// `0` while the corpus is being processed.
40+
/// </summary>
41+
[JsonProperty(PropertyName = "out_of_vocabulary_words")]
42+
public int OutOfVocabularyWords { get; set; }
43+
44+
/// <summary>
45+
/// Gets or sets the status of the corpus: `analyzed` indicates that
46+
/// the service has successfully analyzed the corpus; the custom
47+
/// model can be trained with data from the corpus. `being_processed`
48+
/// indicates that the service is still analyzing the corpus; the
49+
/// service cannot accept requests to add new corpora or words, or to
50+
/// train the custom model. `undetermined` indicates that the service
51+
/// encountered an error while processing the corpus. Possible values
52+
/// include: 'analyzed', 'being_processed', 'undetermined'
53+
/// </summary>
54+
[JsonProperty(PropertyName = "status")]
55+
public string Status { get; set; }
56+
57+
/// <summary>
58+
/// Gets or sets if the status of the corpus is `undetermined`, the
59+
/// following message: `Analysis of corpus 'name' failed. Please try
60+
/// adding the corpus again by setting the 'allow_overwrite' flag to
61+
/// 'true'`.
62+
/// </summary>
63+
[JsonProperty(PropertyName = "error")]
64+
public string Error { get; set; }
65+
}
66+
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/**
2+
* Copyright 2017 IBM Corp. All Rights Reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
*/
17+
using System;
18+
using Newtonsoft.Json;
19+
20+
namespace IBM.WatsonDeveloperCloud.SpeechToText.v1.Model
21+
{
22+
public class CustomModel
23+
{
24+
/// <summary>
25+
/// Gets or sets the name of the new custom model. Use a name that is
26+
/// unique among all custom models that are owned by the calling
27+
/// user. Use a localized name that matches the language of the
28+
/// custom model.
29+
/// </summary>
30+
[JsonProperty(PropertyName = "name")]
31+
public string Name { get; set; }
32+
33+
/// <summary>
34+
/// Gets or sets the name of the language model that is to be
35+
/// customized by the new model. You must use the name of one of the
36+
/// US English or Japanese models that is returned by the `GET
37+
/// /v1/models` method. The new custom model can be used only with
38+
/// the base language model that it customizes. Possible values
39+
/// include: 'en-US_BroadbandModel', 'en-US_NarrowbandModel',
40+
/// 'ja-JP_BroadbandModel', 'ja-JP_NarrowbandModel'
41+
/// </summary>
42+
[JsonProperty(PropertyName = "base_model_name")]
43+
public string BaseModelName { get; set; }
44+
45+
/// <summary>
46+
/// Gets or sets a description of the new custom model. Use a
47+
/// localized description that matches the language of the custom
48+
/// model.
49+
/// </summary>
50+
[JsonProperty(PropertyName = "description")]
51+
public string Description { get; set; }
52+
}
53+
}
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
/**
2+
* Copyright 2017 IBM Corp. All Rights Reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
*/
17+
18+
namespace IBM.WatsonDeveloperCloud.SpeechToText.v1.Model
19+
{
20+
public class Customization
21+
{
22+
/// <summary>
23+
/// Gets or sets the GUID of the custom language model.
24+
/// </summary>
25+
[Newtonsoft.Json.JsonProperty(PropertyName = "customization_id")]
26+
public string CustomizationId { get; set; }
27+
28+
/// <summary>
29+
/// Gets or sets the date and time in Coordinated Universal Time (UTC)
30+
/// at which the custom language model was created. The value is
31+
/// provided in full ISO 8601 format (`YYYY-MM-DDThh:mm:ss.sTZD`).
32+
/// </summary>
33+
[Newtonsoft.Json.JsonProperty(PropertyName = "created")]
34+
public string Created { get; set; }
35+
36+
/// <summary>
37+
/// Gets or sets the language of the custom language model, `en-US` or
38+
/// `ja-JP`.
39+
/// </summary>
40+
[Newtonsoft.Json.JsonProperty(PropertyName = "language")]
41+
public string Language { get; set; }
42+
43+
/// <summary>
44+
/// Gets or sets the GUID of the service credentials for the owner of
45+
/// the custom language model.
46+
/// </summary>
47+
[Newtonsoft.Json.JsonProperty(PropertyName = "owner")]
48+
public string Owner { get; set; }
49+
50+
/// <summary>
51+
/// Gets or sets the name of the custom language model.
52+
/// </summary>
53+
[Newtonsoft.Json.JsonProperty(PropertyName = "name")]
54+
public string Name { get; set; }
55+
56+
/// <summary>
57+
/// Gets or sets the description of the custom language model.
58+
/// </summary>
59+
[Newtonsoft.Json.JsonProperty(PropertyName = "description")]
60+
public string Description { get; set; }
61+
62+
/// <summary>
63+
/// Gets or sets the name of the base language model for which the
64+
/// custom language model was created. Possible values include:
65+
/// 'en-US_BroadbandModel', 'en-US_NarrowbandModel'
66+
/// </summary>
67+
[Newtonsoft.Json.JsonProperty(PropertyName = "base_model_name")]
68+
public string BaseModelName { get; set; }
69+
70+
/// <summary>
71+
/// Gets or sets the current status of the custom language model:
72+
/// `pending` indicates that the model was created but is waiting
73+
/// either for training data to be added or for the service to finish
74+
/// analyzing added data. `ready` indicates that the model contains
75+
/// data and is ready to be trained. `training` indicates that the
76+
/// model is currently being trained. `available` indicates that the
77+
/// model is trained and ready to use. `failed` indicates that
78+
/// training of the model failed. Possible values include: 'pending',
79+
/// 'ready', 'training', 'available', 'failed'
80+
/// </summary>
81+
[Newtonsoft.Json.JsonProperty(PropertyName = "status")]
82+
public string Status { get; set; }
83+
84+
/// <summary>
85+
/// Gets or sets a percentage that indicates the progress of the
86+
/// model's current training. A value of `100` means that the model
87+
/// is fully trained. For this beta release, the `progress` field
88+
/// does not reflect the current progress of the training; the field
89+
/// changes from `0` to `100` when training is complete.
90+
/// </summary>
91+
[Newtonsoft.Json.JsonProperty(PropertyName = "progress")]
92+
public int Progress { get; set; }
93+
94+
/// <summary>
95+
/// Gets or sets if the request included unknown query parameters, the
96+
/// following message: `Unexpected query parameter(s) ['parameters']
97+
/// detected`, where `parameters` is a list that includes a quoted
98+
/// string for each unknown parameter.
99+
/// </summary>
100+
[Newtonsoft.Json.JsonProperty(PropertyName = "warnings")]
101+
public string Warnings { get; set; }
102+
}
103+
}
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,30 @@
1-
/**
2-
* Copyright 2017 IBM Corp. All Rights Reserved.
3-
*
4-
* Licensed under the Apache License, Version 2.0 (the "License");
5-
* you may not use this file except in compliance with the License.
6-
* You may obtain a copy of the License at
7-
*
8-
* http://www.apache.org/licenses/LICENSE-2.0
9-
*
10-
* Unless required by applicable law or agreed to in writing, software
11-
* distributed under the License is distributed on an "AS IS" BASIS,
12-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
* See the License for the specific language governing permissions and
14-
* limitations under the License.
15-
*
16-
*/
17-
18-
using Newtonsoft.Json;
19-
20-
namespace IBM.WatsonDeveloperCloud.SpeechToText.v1.Model
21-
{
22-
public class JobStatusNew
23-
{
24-
[JsonProperty("created")]
25-
public string Created { get; set; }
26-
27-
[JsonProperty("id")]
28-
public string Id { get; set; }
29-
30-
[JsonProperty("url")]
31-
public string Url { get; set; }
32-
33-
[JsonProperty("status")]
34-
public string Status { get; set; }
35-
}
1+
/**
2+
* Copyright 2017 IBM Corp. All Rights Reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
*/
17+
18+
using Newtonsoft.Json;
19+
20+
namespace IBM.WatsonDeveloperCloud.SpeechToText.v1.Model
21+
{
22+
public class CustomizationID
23+
{
24+
/// <summary>
25+
/// The GUID of the new custom language model.
26+
/// </summary>
27+
[JsonProperty("customization_id")]
28+
public string CustomizationId { get; set; }
29+
}
3630
}

0 commit comments

Comments
 (0)