You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- flake8 --ignore=E501,E701 speech_recognition # ignore errors for long lines and multi-statement lines
14
+
- rstcheck README.rst reference/*.rst # ensure RST is well-formed
15
+
sudo: false # this allows TravisCI to use the fast Docker build environment rather than the slower VMs
16
+
env:
17
+
global:
18
+
- secure: "jFHi/NK+hkf8Jw/bA06utypMRAzOcpeKPEZz/P2U79c70aIcmeAOGNUG6t5x2hmaeNpaP1STDtOLVdDawLY904rv/2sAhdMExlLUYubVQrJumvfgwyHRep0NLxrWV/Sf7y6FBPsvS0We29sn5HeEUlSzFwLrANyagpZYGeeWI3SGfdseDK/n4SlD436i7n5jM0Vlbmo07JDtdTN5Ov17APtuqy0ZViNhhTG+wvU8RCd/0/1IvstaaOhSa/82jABXNzH12hY4ynSuK75EVdVLj/WstSmH90r+8TS+YHH1D68yFeoub8kjTzZirqDuwb1s0nGOzx3VAC03+Fb48jHNfz2X0LJEj6gOpaaxgXOr4qkb1+Bx4L1bUkMk3ywjKoXFF0BU/haZfPbzG0fFUDubEXYjhC88gM1CR0LrFf4qtIqFcdM4sjasfv7TD2peiuWqVRZeHzjcvQVC8aDxVFFbTF+Cx1xZ1qLxAY5iJ/dUPWpOVcSs0GIJaJw7LQJU5uQbiU0vg17k9QcVYbASJu0cFAt/OsWGDZp/uArSWrMcSoexe8wI8/k5u9XFnOmlEu5kUJXOrZANjniUk5ilFUe+lag2Zl/ZasNtW16qke+vaWfBnpKl7NOoQemWNdYOxgyc/4x9B3x8gryf5XAmfBeqneh7k10O18u6GYpt33r0zuQ="# encrypted version of "WIT_AI_KEY=(my key)"
19
+
- secure: "NUTqadJCac2g6n44Phw6qsKSB+cGGPYDQI0nB+jJ1p+R4K7SYo46ECU0Xs+UexNwcZbmUxxAwekXyVS8Rd7GGadsM4rw0wPmZ//ul24dg+ek8/tDZ96U85yGvcSWoPTYsBbwqvKqxFfWZNLLwkd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umQ+/FTYjaafOVZ6ZAiZ+xvgge0+foB94GCoV/8LUm5rVTtk8vV3c3oJu9jdzsyiOSargYPSYg7iy1kzkC/eQ12rX89EWLGjoP+mveLGBpUebQNbB8vxaVRd8uaozW/G3Vwgelqg7gzrvmwkaYK3g6a1TAVpcs="# encrypted version of "HOUNDIFY_CLIENT_ID=(my client ID) HOUNDIFY_CLIENT_KEY=(my client key)"
21
+
- secure: "uj5LUKDtf214EZPqsjpy6tk8iXEfydC3z/px98xbXa/H6PVN6wMPTHsF1DuuTWCbLrqNyi9/rMbpJFiNuqMm+q0LarrvvuTKHA9JFe/ZA11R1w3WI2ZMTvub6vzCbmcznIkjq981BjFWz5aCazPXhLt18e0iMit2FR+D6jwZ4al8TIo9i6RjkJ3MimH2/Sgm2BnXZ7qHsmDlG+4VsABiPiH0SPzrxqJJ4WSOb8EnNkNcOujiHuYvDNR+6R566bXjV1x+z2ewKb2nae5LOEl8L+6B/CsNT2cyeds2imYWAw9vTZoTajXf2u21M3pqRINQ67CuWhGFOdUXiEd6E/jTQFcsE4GuB7eMIYcHCmPzhhHn1b6XzNJtf923+YlSnayf63Y5jHjeSWSWs6pjJOUjJquuXS8vQYuJYX4n8sXDeEsZg0yD2jdxFMqMmjZoKKJzWPTPUkDTLawZdZs2q6bOF+xBQysUPozgSnxe3koCMFLeA1cU6fUkXWWIFDuAehR0JqYQHaUovoO0ZYx8Env0Ojhl6IZclONxaLVA41CbzkSUC1pg0k/VeMiv6YB2SQsFxV1riKM/OPDxq7AAuUuNVDCj/SGya4BJEYrxtagtmq0em8Q8SJzLq7IFNBNq5pO8IaqA0JO/tieSIsutrhdRzVMI35apuwbE+5jxoDmiGW0="# encrypted version of "IBM_USERNAME=(my username) IBM_PASSWORD=(my password)"
Performs speech recognition on ``audio_data`` (an ``AudioData`` instance), using the Google Cloud Speech API.
747
747
748
748
This requires a Google Cloud Platform account; see the `Google Cloud Speech API Quickstart <https://cloud.google.com/speech/docs/getting-started>`__ for details and instructions.
749
749
750
750
The recognition language is determined by ``language``, which is a BCP-47 language tag like ``"en-US"`` (US English). For more information see the `RecognitionConfig documentation <https://cloud.google.com/speech/reference/rest/v1beta1/RecognitionConfig>`__.
751
751
752
-
By default profanity will not be filtered. To filter it set ``filter_profanity`` to True.
753
-
754
-
To provide words and phrases likely to be used in the context specify a list of those words and phrases as ``speech_context``. See `Usage Limits <https://cloud.google.com/speech/limits#content>`__ for limitations.
752
+
If ``preferred_phrases`` is a list of phrase strings, those given phrases will be more likely to be recognized over similar-sounding alternatives. This is useful for things like keyword/command recognition or adding new phrases that aren't in Google's vocabulary. Note that the API imposes certain `restrictions on the list of phrase strings <https://cloud.google.com/speech/limits#content>`__.
755
753
756
754
Returns the most likely transcription if ``show_all`` is False (the default). Otherwise, returns the raw API response as a JSON dictionary.
757
755
758
756
Raises a ``speech_recognition.UnknownValueError`` exception if the speech is unintelligible. Raises a ``speech_recognition.RequestError`` exception if the speech recognition operation failed, if the credentials aren't valid, or if there is no Internet connection.
759
757
"""
760
-
ifspeech_contextisNone:
761
-
speech_context= []
762
-
763
758
assertisinstance(audio_data, AudioData), "`audio_data` must be audio data"
764
759
assertisinstance(language, str), "`language` must be a string"
765
-
assertisinstance(filter_profanity, bool), "`filter_profanity` must be a bool"
766
-
assertisinstance(speech_context, list), "`speech_context` must be a list"
760
+
assertpreferred_phrasesisNoneorall(isinstance(preferred_phrases, str) forpreferred_phrasesinpreferred_phrases), "`preferred_phrases` must be a list of strings"
767
761
768
762
# See https://cloud.google.com/speech/reference/rest/v1beta1/RecognitionConfig
769
763
flac_data=audio_data.get_flac_data(
770
-
# Audio samples must be at least 8 kHz and at most 48 kHz. Do not
771
-
# convert if in the range; if outside of it convert to clamped to
convert_rate=Noneif8000<=audio_data.sample_rate<=48000elsemax(8000, min(audio_data.sample_rate, 48000)), # audio sample rate must be between 8 kHz and 48 kHz inclusive - clamp sample rate into this range
0 commit comments