Skip to content

Commit

Permalink
Whoops. Fixed formatting.
Browse files Browse the repository at this point in the history
  • Loading branch information
vagrant committed Mar 28, 2016
1 parent 8de9696 commit 2048c87
Showing 1 changed file with 19 additions and 12 deletions.
31 changes: 19 additions & 12 deletions client/stt.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand All @@ -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:
Expand Down

0 comments on commit 2048c87

Please sign in to comment.