Skip to content

Commit 6af8c69

Browse files
committed
feat(Speech to Text): Added LanguageCustomizationId, deprecated CustomizationId
1 parent aed0425 commit 6af8c69

File tree

1 file changed

+28
-3
lines changed

1 file changed

+28
-3
lines changed

Scripts/Services/SpeechToText/v1/SpeechToText.cs

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,9 @@ public class SpeechToText : IWatsonService
106106
private int _recordingHZ = -1;
107107
private int _inactivityTimeout = 60;
108108
private string _customization_id = null;
109+
private string _languageCustomizationId = null;
109110
private string _acoustic_customization_id = null;
110-
private float _customization_weight = 0.3f;
111+
private float? _customization_weight = null;
111112
private bool _streamMultipart = false; // If true sets `Transfer-Encoding` header of multipart request to `chunked`.
112113
private float _silenceDuration = 0.0f;
113114
private float _silenceCutoff = 1.0f;
@@ -242,15 +243,20 @@ public Credentials Credentials
242243
/// <summary>
243244
/// Specifies the Globally Unique Identifier (GUID) of a custom language model that is to be used for all requests sent over the connection. The base model of the custom language model must match the value of the model parameter. By default, no custom language model is used. For more information, see https://console.bluemix.net/docs/services/speech-to-text/custom.html.
244245
/// </summary>
246+
[Obsolete("Use LanguageCustomizationId instead.")]
245247
public string CustomizationId { get { return _customization_id; } set { _customization_id = value; } }
246248
/// <summary>
249+
/// Specifies the Globally Unique Identifier (GUID) of a custom language model that is to be used for all requests sent over the connection. The base model of the custom language model must match the value of the model parameter. By default, no custom language model is used. For more information, see https://console.bluemix.net/docs/services/speech-to-text/custom.html.
250+
/// </summary>
251+
public string LanguageCustomizationId { get { return _languageCustomizationId; } set { _languageCustomizationId = value; } }
252+
/// <summary>
247253
/// Specifies the Globally Unique Identifier (GUID) of a custom acoustic model that is to be used for all requests sent over the connection. The base model of the custom acoustic model must match the value of the model parameter. By default, no custom acoustic model is used. For more information, see https://console.bluemix.net/docs/services/speech-to-text/custom.html.
248254
/// </summary>
249255
public string AcousticCustomizationId { get { return _acoustic_customization_id; } set { _acoustic_customization_id = value; } }
250256
/// <summary>
251257
/// Specifies the weight the service gives to words from a specified custom language model compared to those from the base model for all requests sent over the connection. Specify a value between 0.0 and 1.0; the default value is 0.3. For more information, see https://console.bluemix.net/docs/services/speech-to-text/language-use.html#weight.
252258
/// </summary>
253-
public float CustomizationWeight { get { return _customization_weight; } set { _customization_weight = value; } }
259+
public float? CustomizationWeight { get { return _customization_weight; } set { _customization_weight = value; } }
254260
/// <summary>
255261
/// If true sets `Transfer-Encoding` request header to `chunked` causing the audio to be streamed to the service. By default, audio is sent all at once as a one-shot delivery. See https://console.bluemix.net/docs/services/speech-to-text/input.html#transmission.
256262
/// </summary>
@@ -650,11 +656,21 @@ private bool CreateListenConnector()
650656
{
651657
Dictionary<string, string> queryParams = new Dictionary<string, string>();
652658
if (!string.IsNullOrEmpty(CustomizationId))
659+
{
653660
queryParams["customization_id"] = CustomizationId;
661+
}
662+
if (!string.IsNullOrEmpty(LanguageCustomizationId))
663+
{
664+
queryParams["language_customization_id"] = LanguageCustomizationId;
665+
}
654666
if (!string.IsNullOrEmpty(AcousticCustomizationId))
667+
{
655668
queryParams["acoustic_customization_id"] = AcousticCustomizationId;
656-
if (!string.IsNullOrEmpty(CustomizationId))
669+
}
670+
if (CustomizationWeight != null)
671+
{
657672
queryParams["customization_weight"] = CustomizationWeight.ToString();
673+
}
658674

659675
string parsedParams = "";
660676

@@ -937,12 +953,21 @@ public bool Recognize(SuccessCallback<SpeechRecognitionEvent> successCallback, F
937953
return false;
938954
}
939955
if (!string.IsNullOrEmpty(AcousticCustomizationId))
956+
{
940957
req.Parameters["acoustic_customization_id"] = AcousticCustomizationId;
958+
}
941959
if (!string.IsNullOrEmpty(CustomizationId))
942960
{
943961
req.Parameters["customization_id"] = CustomizationId;
962+
}
963+
if (CustomizationWeight != null)
964+
{
944965
req.Parameters["customization_weight"] = CustomizationWeight;
945966
}
967+
if (!string.IsNullOrEmpty(LanguageCustomizationId))
968+
{
969+
req.Parameters["language_customization_id"] = LanguageCustomizationId;
970+
}
946971
req.Parameters["inactivity_timeout"] = InactivityTimeout;
947972
req.Parameters["keywords"] = string.Join(",", Keywords);
948973
req.Parameters["keywords_threshold"] = KeywordsThreshold;

0 commit comments

Comments
 (0)