diff --git a/client/stt.py b/client/stt.py index 5b40808ea..eae42a372 100644 --- a/client/stt.py +++ b/client/stt.py @@ -429,17 +429,20 @@ def is_available(cls): class WatsonSTT(AbstractSTTEngine): """ - Speech-To-Text implementation which relies on the IBM Watson Speech-To-Text API. This requires an - IBM Bluemix account, but the first 1000 minutes of transcribing per month are free. + Speech-To-Text implementation which relies on the IBM Watson Speech-To-Text + API. This requires an IBM Bluemix account, but the first 1000 minutes of + transcribing per month are free. To obtain a login: - 1. Register for IBM Bluemix here: https://console.ng.bluemix.net/registration/ - 2. Once you've logged in, click the "Use Services & APIs" link on the dashboard + 1. Register for IBM Bluemix here: + https://console.ng.bluemix.net/registration/ + 2. Once you've logged in, click the "Use Services & APIs" link on the + dashboard 3. Click the "Speech To Text" icon 4. In the form on the right, leave all options as defaults and click Create - 5. You'll now have a new service listed on your dashboard. If you click that service - there will be a navigation option for "Service Credentials" in the left hand nav. - Find your username and password there. + 5. You'll now have a new service listed on your dashboard. If you click + that service there will be a navigation option for "Service Credentials" + in the left hand nav. Find your username and password there. Excerpt from sample profile.yml: @@ -507,8 +510,8 @@ def get_config(cls): def transcribe(self, fp): """ - Performs STT via the Watson Speech-to-Text API, transcribing an audio file and - returning an English string. + Performs STT via the Watson Speech-to-Text API, transcribing an audio + file and returning an English string. Arguments: fp -- the path to the .wav file to be transcribed @@ -528,9 +531,13 @@ def transcribe(self, fp): wav.close() data = fp.read() - headers = {'content-type': 'audio/l16; rate=%s; channels=1' % frame_rate} - r = self._http.post('https://stream.watsonplatform.net/speech-to-text/api/v1/recognize?continuous=true', - data=data, headers=headers, auth=(self.username, self.password)) + headers = {'content-type': + 'audio/l16; rate=%s; channels=1' % frame_rate} + r = self._http.post( + 'https://stream.watsonplatform.net/' + + 'speech-to-text/api/v1/recognize?continuous=true', + data=data, headers=headers, auth=(self.username, self.password) + ) try: r.raise_for_status() except requests.exceptions.HTTPError as e: