Speech Alternative#

Representation of Speech Alternative for the Google Speech API.

class google.cloud.speech.alternative.Alternative(transcript, confidence)[source]#

Bases: object

Representation of Speech Alternative.

Parameters:
  • transcript (str) – String of transcribed data.
  • confidence (float) – The confidence estimate between 0.0 and 1.0.
confidence#

Confidence score for recognized speech.

Return type:float
Returns:Confidence score of recognized speech [0-1].
classmethod from_api_repr(alternative)[source]#

Factory: construct Alternative from JSON response.

Parameters:alternative (dict) – Dictionary response from the REST API.
Return type:Alternative
Returns:Instance of Alternative.
classmethod from_pb(alternative)[source]#

Factory: construct Alternative from protobuf response.

Parameters:alternative (google.cloud.speech.v1.SpeechRecognitionAlternative) – Instance of SpeechRecognitionAlternative from protobuf.
Return type:Alternative
Returns:Instance of Alternative.
transcript#

Transcript text from audio.

Return type:str
Returns:Text detected in audio.