Skip to content

Commit 3bf6924

Browse files
committed
feat(speech to text v1): Added Grammars support
1 parent ea72cee commit 3bf6924

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

Scripts/Services/SpeechToText/v1/SpeechToText.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,14 @@ public Credentials Credentials
273273
/// 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://cloud.ibm.com/docs/services/speech-to-text/input.html#transmission.
274274
/// </summary>
275275
public bool StreamMultipart { get { return _streamMultipart; } set { _streamMultipart = value; } }
276+
/// <summary>
277+
/// The name of a grammar that is to be used with the recognition request. If you specify a grammar, you must also use the `language_customization_id` parameter to specify the name of the custom language model for which the grammar is defined. The service recognizes only strings that are recognized by the specified grammar; it does not recognize other custom words from the model's words resource. See [Grammars](https://cloud.ibm.com/docs/services/speech-to-text/output.html).
278+
/// </summary>
279+
public string GrammarName { get; set; }
280+
/// <summary>
281+
/// If `true`, the service redacts, or masks, numeric data from final transcripts. The feature redacts any number that has three or more consecutive digits by replacing each digit with an `X` character. It is intended to redact sensitive numeric data, such as credit card numbers. By default, the service performs no redaction. \n\nWhen you enable redaction, the service automatically enables smart formatting, regardless of whether you explicitly disable that feature. To ensure maximum security, the service also disables keyword spotting (ignores the `keywords` and `keywords_threshold` parameters) and returns only a single final transcript (forces the `max_alternatives` parameter to be `1`). \n\n**Note:** Applies to US English, Japanese, and Korean transcription only. \n\nSee [Numeric redaction](https://cloud.ibm.com/docs/services/speech-to-text/output.html#redaction).
282+
/// </summary>
283+
public string Redaction { get; set; }
276284
#endregion
277285

278286
#region Constructor
@@ -748,6 +756,10 @@ private void SendStart()
748756
if (WordAlternativesThreshold != null)
749757
start["word_alternatives_threshold"] = WordAlternativesThreshold;
750758
start["word_confidence"] = EnableWordConfidence;
759+
if (GrammarName != null)
760+
start["grammar_name"] = GrammarName;
761+
if (Redaction != null)
762+
start["redaction"] = Redaction;
751763

752764
_listenSocket.Send(new WSConnector.TextMessage(Json.Serialize(start)));
753765
#if ENABLE_DEBUGGING

0 commit comments

Comments
 (0)