Reference documentation and code samples for the Cloud Speech-to-Text V1 API class Google::Cloud::Speech::V1::SpeechContext.
Provides "hints" to the speech recognizer to favor specific words and phrases
in the results.
Inherits
Object
Extended By
Google::Protobuf::MessageExts::ClassMethods
Includes
Google::Protobuf::MessageExts
Methods
#boost
defboost()->::Float
Returns
(::Float) — Hint Boost. Positive value will increase the probability that a specific
phrase will be recognized over other similar sounding phrases. The higher
the boost, the higher the chance of false positive recognition as well.
Negative boost values would correspond to anti-biasing. Anti-biasing is not
enabled, so negative boost will simply be ignored. Though boost can
accept a wide range of positive values, most use cases are best served with
values between 0 and 20. We recommend using a binary search approach to
finding the optimal value for your use case.
#boost=
defboost=(value)->::Float
Parameter
value (::Float) — Hint Boost. Positive value will increase the probability that a specific
phrase will be recognized over other similar sounding phrases. The higher
the boost, the higher the chance of false positive recognition as well.
Negative boost values would correspond to anti-biasing. Anti-biasing is not
enabled, so negative boost will simply be ignored. Though boost can
accept a wide range of positive values, most use cases are best served with
values between 0 and 20. We recommend using a binary search approach to
finding the optimal value for your use case.
Returns
(::Float) — Hint Boost. Positive value will increase the probability that a specific
phrase will be recognized over other similar sounding phrases. The higher
the boost, the higher the chance of false positive recognition as well.
Negative boost values would correspond to anti-biasing. Anti-biasing is not
enabled, so negative boost will simply be ignored. Though boost can
accept a wide range of positive values, most use cases are best served with
values between 0 and 20. We recommend using a binary search approach to
finding the optimal value for your use case.
#phrases
defphrases()->::Array<::String>
Returns
(::Array<::String>) — A list of strings containing words and phrases "hints" so that
the speech recognition is more likely to recognize them. This can be used
to improve the accuracy for specific words and phrases, for example, if
specific commands are typically spoken by the user. This can also be used
to add additional words to the vocabulary of the recognizer. See
usage limits.
List items can also be set to classes for groups of words that represent
common concepts that occur in natural language. For example, rather than
providing phrase hints for every month of the year, using the $MONTH class
improves the likelihood of correctly transcribing audio that includes
months.
#phrases=
defphrases=(value)->::Array<::String>
Parameter
value (::Array<::String>) — A list of strings containing words and phrases "hints" so that
the speech recognition is more likely to recognize them. This can be used
to improve the accuracy for specific words and phrases, for example, if
specific commands are typically spoken by the user. This can also be used
to add additional words to the vocabulary of the recognizer. See
usage limits.
List items can also be set to classes for groups of words that represent
common concepts that occur in natural language. For example, rather than
providing phrase hints for every month of the year, using the $MONTH class
improves the likelihood of correctly transcribing audio that includes
months.
Returns
(::Array<::String>) — A list of strings containing words and phrases "hints" so that
the speech recognition is more likely to recognize them. This can be used
to improve the accuracy for specific words and phrases, for example, if
specific commands are typically spoken by the user. This can also be used
to add additional words to the vocabulary of the recognizer. See
usage limits.
List items can also be set to classes for groups of words that represent
common concepts that occur in natural language. For example, rather than
providing phrase hints for every month of the year, using the $MONTH class
improves the likelihood of correctly transcribing audio that includes
months.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-28 UTC."],[],[],null,["# Cloud Speech-to-Text V1 API - Class Google::Cloud::Speech::V1::SpeechContext (v1.3.0)\n\nVersion latestkeyboard_arrow_down\n\n- [1.3.0 (latest)](/ruby/docs/reference/google-cloud-speech-v1/latest/Google-Cloud-Speech-V1-SpeechContext)\n- [1.2.1](/ruby/docs/reference/google-cloud-speech-v1/1.2.1/Google-Cloud-Speech-V1-SpeechContext)\n- [1.1.0](/ruby/docs/reference/google-cloud-speech-v1/1.1.0/Google-Cloud-Speech-V1-SpeechContext)\n- [1.0.1](/ruby/docs/reference/google-cloud-speech-v1/1.0.1/Google-Cloud-Speech-V1-SpeechContext)\n- [0.17.0](/ruby/docs/reference/google-cloud-speech-v1/0.17.0/Google-Cloud-Speech-V1-SpeechContext)\n- [0.16.2](/ruby/docs/reference/google-cloud-speech-v1/0.16.2/Google-Cloud-Speech-V1-SpeechContext)\n- [0.15.0](/ruby/docs/reference/google-cloud-speech-v1/0.15.0/Google-Cloud-Speech-V1-SpeechContext)\n- [0.14.0](/ruby/docs/reference/google-cloud-speech-v1/0.14.0/Google-Cloud-Speech-V1-SpeechContext)\n- [0.13.1](/ruby/docs/reference/google-cloud-speech-v1/0.13.1/Google-Cloud-Speech-V1-SpeechContext)\n- [0.12.1](/ruby/docs/reference/google-cloud-speech-v1/0.12.1/Google-Cloud-Speech-V1-SpeechContext)\n- [0.11.0](/ruby/docs/reference/google-cloud-speech-v1/0.11.0/Google-Cloud-Speech-V1-SpeechContext)\n- [0.10.2](/ruby/docs/reference/google-cloud-speech-v1/0.10.2/Google-Cloud-Speech-V1-SpeechContext)\n- [0.9.0](/ruby/docs/reference/google-cloud-speech-v1/0.9.0/Google-Cloud-Speech-V1-SpeechContext)\n- [0.8.0](/ruby/docs/reference/google-cloud-speech-v1/0.8.0/Google-Cloud-Speech-V1-SpeechContext)\n- [0.7.3](/ruby/docs/reference/google-cloud-speech-v1/0.7.3/Google-Cloud-Speech-V1-SpeechContext) \nReference documentation and code samples for the Cloud Speech-to-Text V1 API class Google::Cloud::Speech::V1::SpeechContext.\n\nProvides \"hints\" to the speech recognizer to favor specific words and phrases\nin the results. \n\nInherits\n--------\n\n- Object \n\nExtended By\n-----------\n\n- Google::Protobuf::MessageExts::ClassMethods \n\nIncludes\n--------\n\n- Google::Protobuf::MessageExts\n\nMethods\n-------\n\n### #boost\n\n def boost() -\u003e ::Float\n\n**Returns**\n\n- (::Float) --- Hint Boost. Positive value will increase the probability that a specific phrase will be recognized over other similar sounding phrases. The higher the boost, the higher the chance of false positive recognition as well. Negative boost values would correspond to anti-biasing. Anti-biasing is not enabled, so negative boost will simply be ignored. Though `boost` can accept a wide range of positive values, most use cases are best served with values between 0 and 20. We recommend using a binary search approach to finding the optimal value for your use case.\n\n### #boost=\n\n def boost=(value) -\u003e ::Float\n\n**Parameter**\n\n- **value** (::Float) --- Hint Boost. Positive value will increase the probability that a specific phrase will be recognized over other similar sounding phrases. The higher the boost, the higher the chance of false positive recognition as well. Negative boost values would correspond to anti-biasing. Anti-biasing is not enabled, so negative boost will simply be ignored. Though `boost` can accept a wide range of positive values, most use cases are best served with values between 0 and 20. We recommend using a binary search approach to finding the optimal value for your use case. \n**Returns**\n\n- (::Float) --- Hint Boost. Positive value will increase the probability that a specific phrase will be recognized over other similar sounding phrases. The higher the boost, the higher the chance of false positive recognition as well. Negative boost values would correspond to anti-biasing. Anti-biasing is not enabled, so negative boost will simply be ignored. Though `boost` can accept a wide range of positive values, most use cases are best served with values between 0 and 20. We recommend using a binary search approach to finding the optimal value for your use case.\n\n### #phrases\n\n def phrases() -\u003e ::Array\u003c::String\u003e\n\n**Returns**\n\n- (::Array\\\u003c::String\\\u003e) --- A list of strings containing words and phrases \"hints\" so that the speech recognition is more likely to recognize them. This can be used to improve the accuracy for specific words and phrases, for example, if specific commands are typically spoken by the user. This can also be used to add additional words to the vocabulary of the recognizer. See [usage limits](https://cloud.google.com/speech-to-text/quotas#content).\n\n\n List items can also be set to classes for groups of words that represent\n common concepts that occur in natural language. For example, rather than\n providing phrase hints for every month of the year, using the $MONTH class\n improves the likelihood of correctly transcribing audio that includes\n months.\n\n### #phrases=\n\n def phrases=(value) -\u003e ::Array\u003c::String\u003e\n\n**Parameter**\n\n- **value** (::Array\\\u003c::String\\\u003e) --- A list of strings containing words and phrases \"hints\" so that the speech recognition is more likely to recognize them. This can be used to improve the accuracy for specific words and phrases, for example, if specific commands are typically spoken by the user. This can also be used to add additional words to the vocabulary of the recognizer. See [usage limits](https://cloud.google.com/speech-to-text/quotas#content).\n\n\n List items can also be set to classes for groups of words that represent\n common concepts that occur in natural language. For example, rather than\n providing phrase hints for every month of the year, using the $MONTH class\n improves the likelihood of correctly transcribing audio that includes\nmonths. \n**Returns**\n\n- (::Array\\\u003c::String\\\u003e) --- A list of strings containing words and phrases \"hints\" so that the speech recognition is more likely to recognize them. This can be used to improve the accuracy for specific words and phrases, for example, if specific commands are typically spoken by the user. This can also be used to add additional words to the vocabulary of the recognizer. See [usage limits](https://cloud.google.com/speech-to-text/quotas#content).\n\n\n List items can also be set to classes for groups of words that represent\n common concepts that occur in natural language. For example, rather than\n providing phrase hints for every month of the year, using the $MONTH class\n improves the likelihood of correctly transcribing audio that includes\n months."]]